Fixed order of simplifications (#6029)

This commit is contained in:
PKEuS 2014-08-06 08:38:30 +02:00
parent 8bbbb54f94
commit 83a80cebeb
3 changed files with 10 additions and 4 deletions

View File

@ -3167,6 +3167,9 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
if (_settings->terminated()) if (_settings->terminated())
return false; return false;
// Simplify the C alternative tokens (and, or, etc.)
simplifyCAlternativeTokens();
// replace 'NULL' and similar '0'-defined macros with '0' // replace 'NULL' and similar '0'-defined macros with '0'
simplifyNull(); simplifyNull();
@ -3480,9 +3483,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
// Link < with > // Link < with >
createLinks2(); createLinks2();
// Simplify the C alternative tokens (and, or, etc.)
simplifyCAlternativeTokens();
// The simplify enum might have inner loops // The simplify enum might have inner loops
if (_settings->terminated()) if (_settings->terminated())
return false; return false;

View File

@ -2814,7 +2814,7 @@ private:
} }
void cAlternativeTokens() { void cAlternativeTokens() {
ASSERT_EQUALS("void f ( ) { err |= ( ( r & s ) && ! t ) ; }", ASSERT_EQUALS("void f ( ) { err = err | ( ( r & s ) && ! t ) ; }",
tok("void f() { err or_eq ((r bitand s) and not t); }", false)); tok("void f() { err or_eq ((r bitand s) and not t); }", false));
ASSERT_EQUALS("void f ( ) const { r = f ( a [ 4 ] | 15 , ~ c , ! d ) ; }", ASSERT_EQUALS("void f ( ) const { r = f ( a [ 4 ] | 15 , ~ c , ! d ) ; }",
tok("void f() const { r = f(a[4] bitor 0x0F, compl c, not d) ; }", false)); tok("void f() const { r = f(a[4] bitor 0x0F, compl c, not d) ; }", false));

View File

@ -8186,6 +8186,12 @@ private:
ASSERT_EQUALS("void f ( ) { if ( ~ b ) { ; } }", tokenizeAndStringify("void f() { if (compl b); }")); ASSERT_EQUALS("void f ( ) { if ( ~ b ) { ; } }", tokenizeAndStringify("void f() { if (compl b); }"));
ASSERT_EQUALS("void f ( ) { if ( ! b ) { ; } }", tokenizeAndStringify("void f() { if (not b); }")); ASSERT_EQUALS("void f ( ) { if ( ! b ) { ; } }", tokenizeAndStringify("void f() { if (not b); }"));
ASSERT_EQUALS("void f ( ) { if ( a != b ) { ; } }", tokenizeAndStringify("void f() { if (a not_eq b); }")); ASSERT_EQUALS("void f ( ) { if ( a != b ) { ; } }", tokenizeAndStringify("void f() { if (a not_eq b); }"));
ASSERT_EQUALS("\n" // #6029
"\n"
"##file 0\n"
"1: void f ( bool b@1 ) { if ( ! b@1 ) { ; } }\n",
tokenizeDebugListing("void f(bool b) { if (not b); }"));
} }
void simplifyCalculations() { void simplifyCalculations() {