initialize/reset parser context properly
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>
Fri, 15 Nov 2013 17:00:28 +0000 (18:00 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Mon, 18 Nov 2013 11:13:26 +0000 (12:13 +0100)
unconsumed context information may persist after finishing processing of
top-level files and includes.
this would confuse the include optimization, which would slow down
lupdate by orders of magnitude for certain inputs.

Task-number: QTBUG-27936
Change-Id: Ifcf6ddd1b54211434ffd8edfbec5e8960ac35f22
Reviewed-by: Christian Kandeler <christian.kandeler@digia.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
src/linguist/lupdate/cpp.cpp

index 6e6bab1..d3a2235 100644 (file)
@@ -1413,7 +1413,6 @@ void CppParser::processInclude(const QString &file, ConversionData &cd, const QS
         parser.namespaces = namespaces;
         parser.functionContext = functionContext;
         parser.functionContextUnresolved = functionContextUnresolved;
-        parser.pendingContext = pendingContext;
         parser.setInput(ts, cleanFile);
         parser.setTranslator(tor);
         QStringList stack = includeStack;
@@ -1423,6 +1422,9 @@ void CppParser::processInclude(const QString &file, ConversionData &cd, const QS
         CppFiles::setBlacklisted(cleanFile);
     }
     inclusions.remove(cleanFile);
+
+    prospectiveContext.clear();
+    pendingContext.clear();
 }
 
 /*
@@ -1610,6 +1612,9 @@ void CppParser::parseInternal(ConversionData &cd, const QStringList &includeStac
     bool yyTokColonSeen = false; // Start of c'tor's initializer list
     metaExpected = true;
 
+    prospectiveContext.clear();
+    pendingContext.clear();
+
     yyWord.reserve(yyInStr.size()); // Rather insane. That's because we do no length checking.
     yyInPtr = (const ushort *)yyInStr.unicode();
     yyCh = getChar();