From 141dd78b0e47082394f81726681cd2c412847dda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Mon, 12 Oct 2015 09:19:35 +0200 Subject: [PATCH] Tokenizer: Added a define CPPCHECK2 that can be used to test cppcheck without various simplifications I want to get rid of in the long run --- lib/tokenize.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index bf4d44848..33454f05a 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3280,17 +3280,21 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) // replace 'NULL' and similar '0'-defined macros with '0' simplifyNull(); +#ifndef CPPCHECK2 // replace 'sin(0)' to '0' and other similar math expressions simplifyMathExpressions(); +#endif // combine "- %num%" concatenateNegativeNumberAndAnyPositive(); +#ifndef CPPCHECK2 // simplify simple calculations for (Token *tok = list.front() ? list.front()->next() : nullptr; tok; tok = tok->next()) { if (tok->isNumber()) TemplateSimplifier::simplifyNumericCalculations(tok->previous()); } +#endif // remove extern "C" and extern "C" {} if (isCPP()) @@ -3370,11 +3374,13 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) // remove unnecessary member qualification.. removeUnnecessaryQualification(); +#ifndef CPPCHECK2 // convert Microsoft memory functions simplifyMicrosoftMemoryFunctions(); // convert Microsoft string functions simplifyMicrosoftStringFunctions(); +#endif if (_settings->terminated()) return false; @@ -3480,11 +3486,13 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) // operator = => operator= simplifyOperatorName(); +#ifndef CPPCHECK2 // Remove redundant parentheses simplifyRedundantParentheses(); for (Token *tok = list.front(); tok; tok = tok->next()) while (TemplateSimplifier::simplifyNumericCalculations(tok)) ; +#endif // Handle templates.. simplifyTemplates(); @@ -3539,8 +3547,10 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) // Change initialisation of variable to assignment simplifyInitVar(); +#ifndef CPPCHECK2 // Convert e.g. atol("0") into 0 simplifyMathFunctions(); +#endif simplifyDoublePlusAndDoubleMinus(); @@ -3621,6 +3631,7 @@ bool Tokenizer::simplifyTokenList2() simplifyIfAndWhileAssign(); +#ifndef CPPCHECK2 // replace strlen(str) for (Token *tok = list.front(); tok; tok = tok->next()) { if (Token::Match(tok, "strlen ( %str% )")) { @@ -3646,7 +3657,7 @@ bool Tokenizer::simplifyTokenList2() modified |= simplifyCalculations(); validate(); } - +#endif // simplify redundant loops simplifyWhile0();