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'
|
// replace 'NULL' and similar '0'-defined macros with '0'
|
||||||
simplifyNull();
|
simplifyNull();
|
||||||
|
|
||||||
|
#ifndef CPPCHECK2
|
||||||
// replace 'sin(0)' to '0' and other similar math expressions
|
// replace 'sin(0)' to '0' and other similar math expressions
|
||||||
simplifyMathExpressions();
|
simplifyMathExpressions();
|
||||||
|
#endif
|
||||||
|
|
||||||
// combine "- %num%"
|
// combine "- %num%"
|
||||||
concatenateNegativeNumberAndAnyPositive();
|
concatenateNegativeNumberAndAnyPositive();
|
||||||
|
|
||||||
|
#ifndef CPPCHECK2
|
||||||
// simplify simple calculations
|
// simplify simple calculations
|
||||||
for (Token *tok = list.front() ? list.front()->next() : nullptr; tok; tok = tok->next()) {
|
for (Token *tok = list.front() ? list.front()->next() : nullptr; tok; tok = tok->next()) {
|
||||||
if (tok->isNumber())
|
if (tok->isNumber())
|
||||||
TemplateSimplifier::simplifyNumericCalculations(tok->previous());
|
TemplateSimplifier::simplifyNumericCalculations(tok->previous());
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// remove extern "C" and extern "C" {}
|
// remove extern "C" and extern "C" {}
|
||||||
if (isCPP())
|
if (isCPP())
|
||||||
|
@ -3370,11 +3374,13 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
// remove unnecessary member qualification..
|
// remove unnecessary member qualification..
|
||||||
removeUnnecessaryQualification();
|
removeUnnecessaryQualification();
|
||||||
|
|
||||||
|
#ifndef CPPCHECK2
|
||||||
// convert Microsoft memory functions
|
// convert Microsoft memory functions
|
||||||
simplifyMicrosoftMemoryFunctions();
|
simplifyMicrosoftMemoryFunctions();
|
||||||
|
|
||||||
// convert Microsoft string functions
|
// convert Microsoft string functions
|
||||||
simplifyMicrosoftStringFunctions();
|
simplifyMicrosoftStringFunctions();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (_settings->terminated())
|
if (_settings->terminated())
|
||||||
return false;
|
return false;
|
||||||
|
@ -3480,11 +3486,13 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
// operator = => operator=
|
// operator = => operator=
|
||||||
simplifyOperatorName();
|
simplifyOperatorName();
|
||||||
|
|
||||||
|
#ifndef CPPCHECK2
|
||||||
// Remove redundant parentheses
|
// Remove redundant parentheses
|
||||||
simplifyRedundantParentheses();
|
simplifyRedundantParentheses();
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next())
|
for (Token *tok = list.front(); tok; tok = tok->next())
|
||||||
while (TemplateSimplifier::simplifyNumericCalculations(tok))
|
while (TemplateSimplifier::simplifyNumericCalculations(tok))
|
||||||
;
|
;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Handle templates..
|
// Handle templates..
|
||||||
simplifyTemplates();
|
simplifyTemplates();
|
||||||
|
@ -3539,8 +3547,10 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
// Change initialisation of variable to assignment
|
// Change initialisation of variable to assignment
|
||||||
simplifyInitVar();
|
simplifyInitVar();
|
||||||
|
|
||||||
|
#ifndef CPPCHECK2
|
||||||
// Convert e.g. atol("0") into 0
|
// Convert e.g. atol("0") into 0
|
||||||
simplifyMathFunctions();
|
simplifyMathFunctions();
|
||||||
|
#endif
|
||||||
|
|
||||||
simplifyDoublePlusAndDoubleMinus();
|
simplifyDoublePlusAndDoubleMinus();
|
||||||
|
|
||||||
|
@ -3621,6 +3631,7 @@ bool Tokenizer::simplifyTokenList2()
|
||||||
|
|
||||||
simplifyIfAndWhileAssign();
|
simplifyIfAndWhileAssign();
|
||||||
|
|
||||||
|
#ifndef CPPCHECK2
|
||||||
// replace strlen(str)
|
// replace strlen(str)
|
||||||
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
for (Token *tok = list.front(); tok; tok = tok->next()) {
|
||||||
if (Token::Match(tok, "strlen ( %str% )")) {
|
if (Token::Match(tok, "strlen ( %str% )")) {
|
||||||
|
@ -3646,7 +3657,7 @@ bool Tokenizer::simplifyTokenList2()
|
||||||
modified |= simplifyCalculations();
|
modified |= simplifyCalculations();
|
||||||
validate();
|
validate();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// simplify redundant loops
|
// simplify redundant loops
|
||||||
simplifyWhile0();
|
simplifyWhile0();
|
||||||
|
|
Loading…
Reference in New Issue