File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed
Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -3364,12 +3364,6 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
33643364 // Combine tokens..
33653365 combineOperators ();
33663366
3367- // simplify simple calculations
3368- for (Token *tok = list.front () ? list.front ()->next () : nullptr ; tok; tok = tok->next ()) {
3369- if (tok->isNumber ())
3370- TemplateSimplifier::simplifyNumericCalculations (tok->previous ());
3371- }
3372-
33733367 // remove extern "C" and extern "C" {}
33743368 if (isCPP ())
33753369 simplifyExternC ();
@@ -3405,6 +3399,25 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
34053399 // Remove "volatile", "inline", "register", and "restrict"
34063400 simplifyKeyword ();
34073401
3402+ // simplify simple calculations inside <..>
3403+ if (isCPP ()) {
3404+ Token *lt = nullptr ;
3405+ for (Token *tok = list.front (); tok; tok = tok->next ()) {
3406+ if (Token::Match (tok, " [;{}]" ))
3407+ lt = nullptr ;
3408+ else if (Token::Match (tok, " %type <" ))
3409+ lt = tok->next ();
3410+ else if (lt && Token::Match (tok, " >|>> %name%|::|(" )) {
3411+ const Token * const end = tok;
3412+ for (tok = lt; tok != end; tok = tok->next ()) {
3413+ if (tok->isNumber ())
3414+ TemplateSimplifier::simplifyNumericCalculations (tok->previous ());
3415+ }
3416+ lt = tok->next ();
3417+ }
3418+ }
3419+ }
3420+
34083421 // Convert K&R function declarations to modern C
34093422 simplifyVarDecl (true );
34103423 simplifyFunctionParameters ();
Original file line number Diff line number Diff line change @@ -765,6 +765,9 @@ static void valueFlowBitAnd(TokenList *tokenlist)
765765 if (tok->str () != " &" )
766766 continue ;
767767
768+ if (tok->values .size () == 1U && tok->values .front ().isKnown ())
769+ continue ;
770+
768771 if (!tok->astOperand1 () || !tok->astOperand2 ())
769772 continue ;
770773
You can’t perform that action at this time.
0 commit comments