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
This commit is contained in:
parent
7148ad4239
commit
141dd78b0e
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue