Skip to content

Commit 42278dd

Browse files
committed
Tokenizer: skip constant folding in normal token list for C code. In C++ code we should only fold constants in template arguments.
1 parent d252583 commit 42278dd

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

lib/tokenize.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3584,22 +3584,23 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
35843584

35853585
// Remove redundant parentheses
35863586
simplifyRedundantParentheses();
3587-
for (Token *tok = list.front(); tok; tok = tok->next())
3588-
while (TemplateSimplifier::simplifyNumericCalculations(tok))
3589-
;
35903587

3591-
// Handle templates..
3592-
simplifyTemplates();
3588+
if (!isC()) {
3589+
// TODO: Only simplify template parameters
3590+
for (Token *tok = list.front(); tok; tok = tok->next())
3591+
while (TemplateSimplifier::simplifyNumericCalculations(tok))
3592+
;
35933593

3594-
// The simplifyTemplates have inner loops
3595-
if (_settings->terminated())
3596-
return false;
3594+
// Handle templates..
3595+
simplifyTemplates();
35973596

3598-
// Simplify templates.. sometimes the "simplifyTemplates" fail and
3599-
// then unsimplified function calls etc remain. These have the
3600-
// "wrong" syntax. So this function will just fix so that the
3601-
// syntax is corrected.
3602-
if (!isC()) {
3597+
// The simplifyTemplates have inner loops
3598+
if (_settings->terminated())
3599+
return false;
3600+
3601+
// sometimes the "simplifyTemplates" fail and then unsimplified
3602+
// function calls etc remain. These have the "wrong" syntax. So
3603+
// this function will just fix so that the syntax is corrected.
36033604
validate(); // #6847 - invalid code
36043605
TemplateSimplifier::cleanupAfterSimplify(list.front());
36053606
}

0 commit comments

Comments
 (0)