Reverted some changes in commits 4b05c3e19f and 4b08b13845.

This commit is contained in:
Edoardo Prezioso 2012-01-16 10:51:13 +01:00
parent 4b05c3e19f
commit 40739eb3fb
1 changed files with 11 additions and 18 deletions

View File

@ -4167,9 +4167,8 @@ bool Tokenizer::simplifyIfAddBraces()
} }
else if (tok->str() == "else") { else if (tok->str() == "else") {
const Token *tok2 = tok->next();
// An else followed by an if or brace don't need to be processed further // An else followed by an if or brace don't need to be processed further
if (tok2 && (tok2->str() == "if" || tok2->str() == "{")) if (Token::Match(tok, "else if|{"))
continue; continue;
} }
@ -4214,17 +4213,12 @@ bool Tokenizer::simplifyIfAddBraces()
break; break;
} }
tempToken = tempToken->link(); tempToken = tempToken->link();
const Token *tempToken1 = tempToken->next(); if (!tempToken || !tempToken->next())
if (!tempToken1)
break; break;
if (tempToken1->isName()) { if (Token::simpleMatch(tempToken, "} else") && !Token::Match(tempToken->tokAt(2), "if|{"))
if (tempToken1->str() == "else") {
tempToken1 = tempToken1->next();
if (!tempToken1 || (tempToken1->str() != "if" && tempToken1->str() != "{"))
innerIf = false; innerIf = false;
} else else if (tempToken->next()->isName() && tempToken->next()->str() != "else")
break; break;
}
continue; continue;
} }
@ -4243,12 +4237,11 @@ bool Tokenizer::simplifyIfAddBraces()
if (!innerIf) if (!innerIf)
break; break;
const Token *tempToken1 = tempToken->next(); if (Token::simpleMatch(tempToken, "; else if"))
if (tempToken1 && tempToken1->str() == "else") { ;
tempToken1 = tempToken1->next(); else if (Token::simpleMatch(tempToken, "; else"))
if (!tempToken1 || tempToken1->str() != "if")
innerIf = false; innerIf = false;
} else else
break; break;
} }
} }