Tokenizer: simplify 'case 0: x += y;'
This commit is contained in:
parent
94fc13f0c4
commit
1b9de20f9b
|
@ -4369,8 +4369,14 @@ void Tokenizer::simplifyCompoundAssignment()
|
|||
// "a+=b" => "a = a + b"
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
if (Token::Match(tok, "[;{}] %var%"))
|
||||
if (Token::Match(tok, "[;{}:] %var%"))
|
||||
{
|
||||
if (tok->str() == ":")
|
||||
{
|
||||
if (tok->strAt(-2) != "case")
|
||||
continue;
|
||||
}
|
||||
|
||||
const Token * const vartok = tok->next();
|
||||
const std::string str = tok->strAt(2);
|
||||
|
||||
|
|
|
@ -4609,6 +4609,8 @@ private:
|
|||
ASSERT_EQUALS("{ x = x ^ y ; }", tokenizeAndStringify("{ x ^= y;}"));
|
||||
ASSERT_EQUALS("{ x = x << y ; }", tokenizeAndStringify("{ x <<= y;}"));
|
||||
ASSERT_EQUALS("{ x = x >> y ; }", tokenizeAndStringify("{ x >>= y;}"));
|
||||
|
||||
ASSERT_EQUALS("case 0 : x = x + y ; break ;", tokenizeAndStringify("case 0: x += y; break;"));
|
||||
}
|
||||
|
||||
void simplifyAssignmentInFunctionCall()
|
||||
|
|
Loading…
Reference in New Issue