From 42278dd133f616a94118f97009e00b16772f62c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 6 Feb 2016 17:25:51 +0100 Subject: [PATCH] Tokenizer: skip constant folding in normal token list for C code. In C++ code we should only fold constants in template arguments. --- lib/tokenize.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/tokenize.cpp b/lib/tokenize.cpp index 52b23996b..fd38ff2aa 100644 --- a/lib/tokenize.cpp +++ b/lib/tokenize.cpp @@ -3584,22 +3584,23 @@ bool Tokenizer::simplifyTokenList1(const char FileName[]) // Remove redundant parentheses simplifyRedundantParentheses(); - for (Token *tok = list.front(); tok; tok = tok->next()) - while (TemplateSimplifier::simplifyNumericCalculations(tok)) - ; - // Handle templates.. - simplifyTemplates(); - - // The simplifyTemplates have inner loops - if (_settings->terminated()) - return false; - - // Simplify templates.. sometimes the "simplifyTemplates" fail and - // then unsimplified function calls etc remain. These have the - // "wrong" syntax. So this function will just fix so that the - // syntax is corrected. if (!isC()) { + // TODO: Only simplify template parameters + for (Token *tok = list.front(); tok; tok = tok->next()) + while (TemplateSimplifier::simplifyNumericCalculations(tok)) + ; + + // Handle templates.. + simplifyTemplates(); + + // The simplifyTemplates have inner loops + if (_settings->terminated()) + return false; + + // sometimes the "simplifyTemplates" fail and then unsimplified + // function calls etc remain. These have the "wrong" syntax. So + // this function will just fix so that the syntax is corrected. validate(); // #6847 - invalid code TemplateSimplifier::cleanupAfterSimplify(list.front()); }