Cleanup to removeReduntantConditions()

This commit is contained in:
Reijo Tomperi 2008-12-24 15:43:05 +00:00
parent 3bcd14ebac
commit 2692866694
1 changed files with 4 additions and 24 deletions

View File

@ -1078,7 +1078,10 @@ bool Tokenizer::removeReduntantConditions()
for ( TOKEN *tok = _tokens; tok; tok = tok->next() )
{
if (!TOKEN::Match(tok, "if ( %bool% ) {"))
if (!TOKEN::simpleMatch(tok, "if"))
continue;
if (!TOKEN::Match(tok->tokAt(1), "( %bool% ) {"))
continue;
// Find matching else
@ -1141,29 +1144,6 @@ bool Tokenizer::removeReduntantConditions()
// Remove the "else { aaa; }"
TOKEN::eraseTokens( elseTag->previous(), end->tokAt( 1 ) );
}
else
{
// Convert "if( true ) {aaa;} else bbb;" => "{aaa;}"
// Find the closing ";"
const TOKEN *end = 0;
for ( const TOKEN *closing = elseTag->tokAt( 1 ); closing; closing = closing->next() )
{
if( closing->str() == ";" )
{
end = closing;
break;
}
}
if( !end )
{
// Possibly syntax error
return false;
}
TOKEN::eraseTokens( elseTag->previous(), end->next() );
}
// Remove "if( true )"
if( tok->previous() )