TemplateSimplifier::simplifyCalculations: Add some more tests and make sure they pass
This commit is contained in:
parent
cb48e63f92
commit
c1ea873e1c
|
@ -1152,10 +1152,10 @@ bool TemplateSimplifier::simplifyCalculations(Token *_tokens)
|
|||
ret = true;
|
||||
}
|
||||
|
||||
if (Token::simpleMatch(tok->previous(), "( 0 |") ||
|
||||
Token::simpleMatch(tok->previous(), "| 0 )")) {
|
||||
if (Token::Match(tok->previous(), "( 0 [|+]") ||
|
||||
Token::Match(tok->previous(), "[|+-] 0 )")) {
|
||||
tok = tok->previous();
|
||||
if (tok->str() == "|")
|
||||
if (Token::Match(tok, "[|+-]"))
|
||||
tok = tok->previous();
|
||||
tok->deleteNext(2);
|
||||
ret = true;
|
||||
|
|
|
@ -5753,6 +5753,18 @@ private:
|
|||
void simplifyCalculations() {
|
||||
ASSERT_EQUALS("void foo ( char str [ ] ) { char x ; x = * str ; }",
|
||||
tokenizeAndStringify("void foo ( char str [ ] ) { char x = 0 | ( * str ) ; }", true));
|
||||
ASSERT_EQUALS("void foo ( ) { if ( b ) { } }",
|
||||
tokenizeAndStringify("void foo ( ) { if (b + 0) { } }", true));
|
||||
ASSERT_EQUALS("void foo ( ) { if ( b ) { } }",
|
||||
tokenizeAndStringify("void foo ( ) { if (0 + b) { } }", true));
|
||||
ASSERT_EQUALS("void foo ( ) { if ( b ) { } }",
|
||||
tokenizeAndStringify("void foo ( ) { if (b - 0) { } }", true));
|
||||
ASSERT_EQUALS("void foo ( ) { if ( b ) { } }",
|
||||
tokenizeAndStringify("void foo ( ) { if (b * 1) { } }", true));
|
||||
ASSERT_EQUALS("void foo ( ) { if ( b ) { } }",
|
||||
tokenizeAndStringify("void foo ( ) { if (1 * b) { } }", true));
|
||||
//ASSERT_EQUALS("void foo ( ) { if ( b ) { } }",
|
||||
// tokenizeAndStringify("void foo ( ) { if (b / 1) { } }", true));
|
||||
ASSERT_EQUALS("void foo ( ) { if ( b ) { } }",
|
||||
tokenizeAndStringify("void foo ( ) { if (b | 0) { } }", true));
|
||||
ASSERT_EQUALS("void foo ( ) { if ( b ) { } }",
|
||||
|
|
Loading…
Reference in New Issue