simplify tokens: remove redundant parantheses around variable.. 'p = (q);'

This commit is contained in:
Daniel Marjamäki 2009-02-25 19:55:24 +00:00
parent 35583293ec
commit c1da4ae57d
2 changed files with 17 additions and 0 deletions

View File

@ -923,6 +923,16 @@ void Tokenizer::simplifyTokenList()
tok->deleteNext();
done = false;
}
// Remove parantheses around variable..
// keep parantheses here: dynamic_cast<Fred *>(p);
if (!tok->isName() && tok->str() != ">" && Token::Match(tok->next(), "( %var% )"))
{
tok->deleteNext();
tok = tok->next();
tok->deleteNext();
done = false;
}
}
}

View File

@ -64,6 +64,7 @@ private:
TEST_CASE(double_plus);
TEST_CASE(redundant_plus);
TEST_CASE(parantheses1);
TEST_CASE(parantheses2);
TEST_CASE(elseif1);
}
@ -312,6 +313,12 @@ private:
ASSERT_EQUALS("<= 110 ; ", tok(code1));
}
void parantheses2()
{
const char code1[] = "= (p);";
ASSERT_EQUALS("= p ; ", tok(code1));
}
std::string elseif(const char code[])
{