Refactoring: Use Token::isOp

This commit is contained in:
Daniel Marjamäki 2011-04-09 16:22:47 +02:00
parent f6d910ab3d
commit 575cb242c2
2 changed files with 5 additions and 4 deletions

View File

@ -175,7 +175,7 @@ public:
}
bool isExtendedOp() const
{
return isOp() ||
return isOp() ||
(this && _str.size() == 1 && _str.find_first_of(",[]()?:") != std::string::npos);
}
bool isBoolean() const

View File

@ -5594,11 +5594,12 @@ bool Tokenizer::simplifyFunctionReturn()
else if (indentlevel == 0 && Token::Match(tok, "%var% ( ) { return %num% ; }") && tok->str() != ")")
{
std::ostringstream pattern;
pattern << "[(=+-*/] " << tok->str() << " ( ) [;)+-*/]";
const std::string pattern("%any% " + tok->str() + " ( ) %any%");
for (Token *tok2 = _tokens; tok2; tok2 = tok2->next())
{
if (Token::Match(tok2, pattern.str().c_str()))
if (Token::Match(tok2, pattern.c_str()) &&
(tok2->isOp() || Token::Match(tok2, "(|[|=")) &&
(tok2->tokAt(4)->isOp() || Token::Match(tok2->tokAt(4), ";|]|)")))
{
tok2 = tok2->next();
tok2->str(tok->strAt(5));