From e4495d83219c7f057e5b345752a281d0c52c68dd Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Tue, 3 Dec 2024 13:18:20 +0100 Subject: [PATCH] Fix build of lexgen tool Use QMultiHash explicitly, and build list of values in a QSet via the range constructor. Task-number: QTBUG-131842 Change-Id: I9cbcddeada0bfd88b11515262f5476e5d59e0fad Reviewed-by: Thiago Macieira Reviewed-by: Edward Welbourne (cherry picked from commit e1217cc52bd367b7e040edeb86700dc923df39a8) Reviewed-by: Qt Cherry-pick Bot --- util/lexgen/generator.cpp | 2 +- util/lexgen/generator.h | 4 ++-- util/lexgen/nfa.cpp | 15 ++++++++------- util/lexgen/nfa.h | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/util/lexgen/generator.cpp b/util/lexgen/generator.cpp index 01de30d5c53..991091d9500 100644 --- a/util/lexgen/generator.cpp +++ b/util/lexgen/generator.cpp @@ -157,7 +157,7 @@ QString Class::definition() const Generator::Generator(const DFA &_dfa, const Config &config) : dfa(_dfa), cfg(config) { - QList lst = cfg.maxInputSet.toList(); + QList lst(cfg.maxInputSet.cbegin(), cfg.maxInputSet.cend()); std::sort(lst.begin(), lst.end()); minInput = lst.first(); maxInput = lst.last(); diff --git a/util/lexgen/generator.h b/util/lexgen/generator.h index 4ee6fe9811d..70d63338b29 100644 --- a/util/lexgen/generator.h +++ b/util/lexgen/generator.h @@ -40,7 +40,7 @@ public: ~LineStream() { if (!--shared->ref) { - (*shared->stream) << endl; + (*shared->stream) << Qt::endl; delete shared; } } @@ -64,7 +64,7 @@ public: LineStream operator<<(const T &value) { stream << indentStr; stream << value; return LineStream(&stream); } - inline void addNewLine() { stream << endl; } + inline void addNewLine() { stream << Qt::endl; } inline QString toString() const { stream.flush(); return output; } diff --git a/util/lexgen/nfa.cpp b/util/lexgen/nfa.cpp index 2564b15df24..6676acbd567 100644 --- a/util/lexgen/nfa.cpp +++ b/util/lexgen/nfa.cpp @@ -32,7 +32,7 @@ void NFA::addTransition(int from, InputType input, int to) assertValidState(from); assertValidState(to); - states[from].transitions.insertMulti(input, to); + states[from].transitions.insert(input, to); } void NFA::copyFrom(const NFA &other, int baseState) @@ -449,12 +449,13 @@ DFA DFA::minimize() const } } while (!done); - QHash statesToEliminate; - for (int i = 0; i < count(); ++i) - for (int j = 0; j < i; ++j) - if (!inequivalentStates[i * count() + j]) { - statesToEliminate.insertMulti(i, j); - } + QMultiHash statesToEliminate; + for (int i = 0; i < count(); ++i) { + for (int j = 0; j < i; ++j) { + if (!inequivalentStates[i * count() + j]) + statesToEliminate.insert(i, j); + } + } /* qDebug() << "states to eliminiate:" << statesToEliminate.count(); diff --git a/util/lexgen/nfa.h b/util/lexgen/nfa.h index f806670b07a..70f1f1e34d0 100644 --- a/util/lexgen/nfa.h +++ b/util/lexgen/nfa.h @@ -14,7 +14,7 @@ #include "global.h" -typedef QHash TransitionMap; +typedef QMultiHash TransitionMap; struct State {