From 67c77a31aa4f4826cb295f56b7f1373a939ccddb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Fri, 16 Aug 2013 18:39:56 +0200 Subject: [PATCH] Fixed #4942 (1.61 is very slow (compared to 1.60.1)) --- lib/tokenize.cpp | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index dd1500d30..4d76f5385 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -7565,14 +7565,11 @@ void Tokenizer::simplifyEnum() bool hasClass = false; EnumValue *ev = NULL; - int executableScopeLevel = 0; - if (!tok1) return; for (Token *tok2 = tok1->next(); tok2; tok2 = tok2->next()) { if (tok2->str() == "}") { --level; - --executableScopeLevel; if (level < 0) inScope = false; @@ -7596,40 +7593,23 @@ void Tokenizer::simplifyEnum() // Not a duplicate enum.. ++level; - if (executableScopeLevel > 0) - ++executableScopeLevel; - // Create a copy of the shadow ids for the inner scope if (!shadowId.empty()) shadowId.push(shadowId.top()); // are there shadow arguments? if (Token::simpleMatch(tok2->previous(), ") {") || Token::simpleMatch(tok2->tokAt(-2), ") const {")) { - // Determine if this is a executable scope.. - if (executableScopeLevel <= 0) { - const Token *prev = tok2->previous(); - while (prev) { - if (prev->str() == "}" || prev->str() == ")") - prev = prev->link(); - else if (prev->str() == "{") { - while ((prev = prev->previous()) && (prev->isName())); - if (!prev || prev->str() == ")") - break; - } - prev = prev->previous(); - } - - if (prev) - executableScopeLevel = 1; - } - - bool executableScope = (executableScopeLevel > 0); - std::set shadowArg; for (const Token* arg = tok2; arg && arg->str() != "("; arg = arg->previous()) { if (Token::Match(arg->previous(), "%type%|*|& %type% [,)]") && enumValues.find(arg->str()) != enumValues.end()) { - if (executableScope && Token::Match(arg->previous(), "[*&]")) + // is this a variable declaration + const Token *prev = arg; + while (Token::Match(prev,"%type%|*|&")) + prev = prev->previous(); + if (!Token::Match(prev,"[,(] %type%")) + continue; + if (prev->str() == "(" && (!Token::Match(prev->tokAt(-2), "%type%|::|*|& %type% (") || prev->strAt(-2) == "else")) continue; shadowArg.insert(arg->str()); if (inScope && _settings->isEnabled("style")) {