Merge branch 'master' of git@github.com:danmar/cppcheck

This commit is contained in:
Slava Semushin 2009-05-31 20:50:55 +07:00
commit 5f57e4ac2d
2 changed files with 19 additions and 9 deletions

View File

@ -2458,15 +2458,6 @@ bool Tokenizer::simplifyRedundantParanthesis()
tok->deleteNext();
ret = true;
}
if (Token::Match(tok, "( %bool% ) )") ||
Token::Match(tok, "( %num% ) )"))
{
tok = tok->next();
tok->deleteNext();
tok->previous()->deleteThis();
ret = true;
}
}
return ret;
}

View File

@ -1652,6 +1652,25 @@ private:
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void foo ( ) { { } }"), ostr.str());
}
{
const char code[] = "void foo()\n"
"{\n"
" if( g(10)){}\n"
"}";
// tokenize..
Tokenizer tokenizer;
std::istringstream istr(code);
tokenizer.tokenize(istr, "test.cpp");
tokenizer.simplifyTokenList();
std::ostringstream ostr;
for (const Token *tok = tokenizer.tokens(); tok; tok = tok->next())
ostr << " " << tok->str();
ASSERT_EQUALS(std::string(" void foo ( ) { if ( g ( 10 ) ) { } }"), ostr.str());
}
}
void simplify_numeric_condition()