From 83a80cebeb55eee7bc0f765199321a80eccb7d63 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Wed, 6 Aug 2014 08:38:30 +0200 Subject: [PATCH] Fixed order of simplifications (#6029) --- lib/tokenize.cpp | 6 +++--- test/testsimplifytokens.cpp | 2 +- test/testtokenize.cpp | 6 ++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index e82ae7091..35b307c9b 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3167,6 +3167,9 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) if (_settings->terminated()) return false; + // Simplify the C alternative tokens (and, or, etc.) + simplifyCAlternativeTokens(); + // replace 'NULL' and similar '0'-defined macros with '0' simplifyNull(); @@ -3480,9 +3483,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) // Link < with > createLinks2(); - // Simplify the C alternative tokens (and, or, etc.) - simplifyCAlternativeTokens(); - // The simplify enum might have inner loops if (_settings->terminated()) return false; diff --git a/test/testsimplifytokens.cpp b/test/testsimplifytokens.cpp index 216597e23..72e781158 100644 --- a/test/testsimplifytokens.cpp +++ b/test/testsimplifytokens.cpp @@ -2814,7 +2814,7 @@ private: } 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)); 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)); diff --git a/test/testtokenize.cpp b/test/testtokenize.cpp index 8584086d7..0c1b46e1e 100644 --- a/test/testtokenize.cpp +++ b/test/testtokenize.cpp @@ -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 (not 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() {