Tokenizer::simplifyTokenList: reduce indent.
No functional change.
This commit is contained in:
parent
dc6168b9d7
commit
fa5cdcb128
|
@ -1151,30 +1151,32 @@ void Tokenizer::simplifyTokenList()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Replace 'sizeof(var)'..
|
// Replace 'sizeof(var)' with 'sizeof(type)'
|
||||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||||
{
|
{
|
||||||
if (Token::Match(tok, "[;{}] %type% %var% ;") && tok->tokAt(2)->varId() > 0)
|
if (! Token::Match(tok, "[;{}] %type% %var% ;"))
|
||||||
{
|
continue;
|
||||||
const unsigned int varid = tok->tokAt(2)->varId();
|
|
||||||
|
|
||||||
// Replace 'sizeof(var)' with 'sizeof(type)'
|
if (tok->tokAt(2)->varId() <= 0)
|
||||||
int indentlevel = 0;
|
continue;
|
||||||
for (Token *tok2 = tok; tok2; tok2 = tok2->next())
|
|
||||||
|
const unsigned int varid = tok->tokAt(2)->varId();
|
||||||
|
|
||||||
|
int indentlevel = 0;
|
||||||
|
for (Token *tok2 = tok; tok2; tok2 = tok2->next())
|
||||||
|
{
|
||||||
|
if (tok2->str() == "{")
|
||||||
|
++indentlevel;
|
||||||
|
else if (tok2->str() == "}")
|
||||||
{
|
{
|
||||||
if (tok2->str() == "{")
|
--indentlevel;
|
||||||
++indentlevel;
|
if (indentlevel < 0)
|
||||||
else if (tok2->str() == "}")
|
break;
|
||||||
{
|
}
|
||||||
--indentlevel;
|
else if (Token::Match(tok2, "sizeof ( %varid% )", varid))
|
||||||
if (indentlevel < 0)
|
{
|
||||||
break;
|
tok2 = tok2->tokAt(2);
|
||||||
}
|
tok2->str(tok->strAt(1));
|
||||||
else if (Token::Match(tok2, "sizeof ( %varid% )", varid))
|
|
||||||
{
|
|
||||||
tok2 = tok2->tokAt(2);
|
|
||||||
tok2->str(tok->strAt(1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue