Fixed #4942 (1.61 is very slow (compared to 1.60.1))
This commit is contained in:
parent
538e4bd798
commit
67c77a31aa
|
@ -7565,14 +7565,11 @@ void Tokenizer::simplifyEnum()
|
||||||
bool hasClass = false;
|
bool hasClass = false;
|
||||||
EnumValue *ev = NULL;
|
EnumValue *ev = NULL;
|
||||||
|
|
||||||
int executableScopeLevel = 0;
|
|
||||||
|
|
||||||
if (!tok1)
|
if (!tok1)
|
||||||
return;
|
return;
|
||||||
for (Token *tok2 = tok1->next(); tok2; tok2 = tok2->next()) {
|
for (Token *tok2 = tok1->next(); tok2; tok2 = tok2->next()) {
|
||||||
if (tok2->str() == "}") {
|
if (tok2->str() == "}") {
|
||||||
--level;
|
--level;
|
||||||
--executableScopeLevel;
|
|
||||||
if (level < 0)
|
if (level < 0)
|
||||||
inScope = false;
|
inScope = false;
|
||||||
|
|
||||||
|
@ -7596,40 +7593,23 @@ void Tokenizer::simplifyEnum()
|
||||||
// Not a duplicate enum..
|
// Not a duplicate enum..
|
||||||
++level;
|
++level;
|
||||||
|
|
||||||
if (executableScopeLevel > 0)
|
|
||||||
++executableScopeLevel;
|
|
||||||
|
|
||||||
// Create a copy of the shadow ids for the inner scope
|
// Create a copy of the shadow ids for the inner scope
|
||||||
if (!shadowId.empty())
|
if (!shadowId.empty())
|
||||||
shadowId.push(shadowId.top());
|
shadowId.push(shadowId.top());
|
||||||
|
|
||||||
// are there shadow arguments?
|
// are there shadow arguments?
|
||||||
if (Token::simpleMatch(tok2->previous(), ") {") || Token::simpleMatch(tok2->tokAt(-2), ") const {")) {
|
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<std::string> shadowArg;
|
std::set<std::string> shadowArg;
|
||||||
for (const Token* arg = tok2; arg && arg->str() != "("; arg = arg->previous()) {
|
for (const Token* arg = tok2; arg && arg->str() != "("; arg = arg->previous()) {
|
||||||
if (Token::Match(arg->previous(), "%type%|*|& %type% [,)]") &&
|
if (Token::Match(arg->previous(), "%type%|*|& %type% [,)]") &&
|
||||||
enumValues.find(arg->str()) != enumValues.end()) {
|
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;
|
continue;
|
||||||
shadowArg.insert(arg->str());
|
shadowArg.insert(arg->str());
|
||||||
if (inScope && _settings->isEnabled("style")) {
|
if (inScope && _settings->isEnabled("style")) {
|
||||||
|
|
Loading…
Reference in New Issue