Break loop early, cleanup declarations

This commit is contained in:
Dmitry-Me 2014-08-24 20:17:41 +02:00 committed by Daniel Marjamäki
parent 37f3c6881b
commit 67ea470275
1 changed files with 10 additions and 8 deletions

View File

@ -7607,16 +7607,16 @@ void Tokenizer::simplifyEnum()
// previous value or 0 if it is the first one. // previous value or 0 if it is the first one.
std::map<std::string,EnumValue> enumValues; std::map<std::string,EnumValue> enumValues;
for (; tok1 && tok1 != end; tok1 = tok1->next()) { for (; tok1 && tok1 != end; tok1 = tok1->next()) {
Token * enumName = 0;
Token * enumValue = 0;
Token * enumValueStart = 0;
Token * enumValueEnd = 0;
if (tok1->str() == "(") { if (tok1->str() == "(") {
tok1 = tok1->link(); tok1 = tok1->link();
continue; continue;
} }
Token * enumName = 0;
Token * enumValue = 0;
Token * enumValueStart = 0;
Token * enumValueEnd = 0;
if (Token::Match(tok1->previous(), ",|{ %type% ,|}")) { if (Token::Match(tok1->previous(), ",|{ %type% ,|}")) {
// no value specified // no value specified
enumName = tok1; enumName = tok1;
@ -7872,8 +7872,10 @@ void Tokenizer::simplifyEnum()
++indentlevel; ++indentlevel;
else if (enumtok->str() == ")") else if (enumtok->str() == ")")
--indentlevel; --indentlevel;
if (indentlevel == 0) if (indentlevel == 0 && enumtok->isOp()) {
hasOp |= enumtok->isOp(); hasOp = true;
break;
}
} }
if (!hasOp) if (!hasOp)
tok2 = copyTokens(tok2, ev->start, ev->end); tok2 = copyTokens(tok2, ev->start, ev->end);
@ -8128,7 +8130,7 @@ void Tokenizer::eraseDeadCode(Token *begin, const Token *end)
{ {
if (!begin) if (!begin)
return; return;
bool isgoto = Token::Match(begin->tokAt(-2), "goto %var% ;"); const bool isgoto = Token::Match(begin->tokAt(-2), "goto %var% ;");
unsigned int indentlevel = 1, unsigned int indentlevel = 1,
indentcase = 0, indentcase = 0,
indentswitch = 0, indentswitch = 0,