From 41b1684a6d9fcb6388a4f7243719563f1bd50f6e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Date: Wed, 24 Jul 2013 19:28:33 +0200 Subject: [PATCH] avoid boolean argument trap: introduce QMakeParser::ParseFlag Change-Id: I26ce032a1aa044e9a4da0c8708a4490b07374992 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com> (cherry picked from qtbase/0a1faaa9eb7807bf11d796c2eca624e2f3b378a7) --- src/shared/proparser/qmakeevaluator.cpp | 2 +- src/shared/proparser/qmakeparser.cpp | 4 ++-- src/shared/proparser/qmakeparser.h | 10 +++++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/shared/proparser/qmakeevaluator.cpp b/src/shared/proparser/qmakeevaluator.cpp index 08a71757012..9f6b8bf01e5 100644 --- a/src/shared/proparser/qmakeevaluator.cpp +++ b/src/shared/proparser/qmakeevaluator.cpp @@ -1804,7 +1804,7 @@ ProString QMakeEvaluator::first(const ProKey &variableName) const QMakeEvaluator::VisitReturn QMakeEvaluator::evaluateFile( const QString &fileName, QMakeHandler::EvalFileType type, LoadFlags flags) { - if (ProFile *pro = m_parser->parsedProFile(fileName, true)) { + if (ProFile *pro = m_parser->parsedProFile(fileName, QMakeParser::ParseUseCache)) { m_locationStack.push(m_current); VisitReturn ok = visitProFile(pro, type, flags); m_current = m_locationStack.pop(); diff --git a/src/shared/proparser/qmakeparser.cpp b/src/shared/proparser/qmakeparser.cpp index 9dd10ac448e..9f2d42d107e 100644 --- a/src/shared/proparser/qmakeparser.cpp +++ b/src/shared/proparser/qmakeparser.cpp @@ -140,10 +140,10 @@ QMakeParser::QMakeParser(ProFileCache *cache, QMakeVfs *vfs, QMakeParserHandler initialize(); } -ProFile *QMakeParser::parsedProFile(const QString &fileName, bool cache) +ProFile *QMakeParser::parsedProFile(const QString &fileName, ParseFlags flags) { ProFile *pro; - if (cache && m_cache) { + if ((flags & ParseUseCache) && m_cache) { ProFileCache::Entry *ent; #ifdef PROPARSER_THREAD_SAFE QMutexLocker locker(&m_cache->mutex); diff --git a/src/shared/proparser/qmakeparser.h b/src/shared/proparser/qmakeparser.h index 87cd8c2244a..06fa2c70fbe 100644 --- a/src/shared/proparser/qmakeparser.h +++ b/src/shared/proparser/qmakeparser.h @@ -75,11 +75,17 @@ public: // Call this from a concurrency-free context static void initialize(); + enum ParseFlag { + ParseDefault = 0, + ParseUseCache = 1 + }; + Q_DECLARE_FLAGS(ParseFlags, ParseFlag) + QMakeParser(ProFileCache *cache, QMakeVfs *vfs, QMakeParserHandler *handler); enum SubGrammar { FullGrammar, TestGrammar, ValueGrammar }; // fileName is expected to be absolute and cleanPath()ed. - ProFile *parsedProFile(const QString &fileName, bool cache = false); + ProFile *parsedProFile(const QString &fileName, ParseFlags flags = ParseDefault); ProFile *parsedProBlock(const QString &contents, const QString &name, int line = 0, SubGrammar grammar = FullGrammar); @@ -172,6 +178,8 @@ private: friend class ProFileCache; }; +Q_DECLARE_OPERATORS_FOR_FLAGS(QMakeParser::ParseFlags) + class QMAKE_EXPORT ProFileCache { public: -- GitLab