Fixed #6872 (Major performance regression - valueFlowSwitchVariable)

This commit is contained in:
Daniel Marjamäki 2015-07-27 06:43:43 +02:00
parent 29fbbef001
commit 5cc744b941
1 changed files with 20 additions and 2 deletions

View File

@ -1202,11 +1202,29 @@ static bool valueFlowForward(Token * const startToken,
tok2 = tok2->linkAt(2);
}
else if (indentlevel <= 0 && Token::Match(tok2, "break|continue|goto")) {
if (tok2->str() == "break") {
else if (Token::Match(tok2, "break|continue|goto")) {
const Scope *scope = tok2->scope();
if (indentlevel > 0) {
const Token *tok3 = tok2->tokAt(2);
int indentlevel2 = indentlevel;
while (indentlevel2 > 0 &&
tok3->str() == "}" &&
Token::Match(tok3->link()->previous(), "!!)")) {
indentlevel2--;
tok3 = tok3->next();
if (tok3 && tok3->str() == ";")
tok3 = tok3->next();
}
if (indentlevel2 > 0)
continue;
scope = tok3->scope();
indentlevel = 0;
}
if (tok2->str() == "break") {
if (scope && scope->type == Scope::eSwitch) {
tok2 = const_cast<Token *>(scope->classEnd);
if (tok2 == endToken)
break;
--indentlevel;
for (std::list<ValueFlow::Value>::iterator it = values.begin(); it != values.end(); ++it) {
it->changeKnownToPossible();