avoid boolean argument trap: introduce QMakeParser::ParseFlag
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>
Wed, 24 Jul 2013 17:28:33 +0000 (19:28 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 29 Jul 2013 15:46:29 +0000 (17:46 +0200)
Change-Id: I26ce032a1aa044e9a4da0c8708a4490b07374992
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
src/linguist/shared/qmakeevaluator.cpp
src/linguist/shared/qmakeparser.cpp
src/linguist/shared/qmakeparser.h

index 33befc0..eb9e24c 100644 (file)
@@ -1807,7 +1807,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();
index d4e9e57..690a1c0 100644 (file)
@@ -150,10 +150,10 @@ QMakeParser::QMakeParser(ProFileCache *cache, QMakeParserHandler *handler)
     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);
index 8d5c3ed..51e3033 100644 (file)
@@ -86,11 +86,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, 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);
 
@@ -182,6 +188,8 @@ private:
     friend class ProFileCache;
 };
 
+Q_DECLARE_OPERATORS_FOR_FLAGS(QMakeParser::ParseFlags)
+
 class QMAKE_EXPORT ProFileCache
 {
 public: