@@ -3723,24 +3723,23 @@ template<class ContainerOfValue>
37233723static void valueFlowForwardConst (Token* start,
37243724 const Token* end,
37253725 const Variable* var,
3726- const ContainerOfValue& values,
3727- const Settings& settings,
3728- int /* unused*/ = 0 )
3726+ ContainerOfValue values,
3727+ const Settings& settings)
37293728{
37303729 if (!precedes (start, end))
37313730 throw InternalError (var->nameToken (), " valueFlowForwardConst: start token does not precede the end token." );
37323731 for (Token* tok = start; tok != end; tok = tok->next ()) {
37333732 if (tok->varId () == var->declarationId ()) {
3734- for (const ValueFlow::Value& value : values)
3735- setTokenValue (tok, value, settings);
3733+ for (ValueFlow::Value& value : values)
3734+ setTokenValue (tok, std::move ( value) , settings);
37363735 } else {
37373736 // Follow references
37383737 auto refs = followAllReferences (tok);
37393738 auto it = std::find_if (refs.cbegin (), refs.cend (), [&](const ReferenceToken& ref) {
37403739 return ref.token ->varId () == var->declarationId ();
37413740 });
37423741 if (it != refs.end ()) {
3743- for (ValueFlow::Value value : values) {
3742+ for (ValueFlow::Value& value : values) {
37443743 if (refs.size () > 1 )
37453744 value.setInconclusive ();
37463745 value.errorPath .insert (value.errorPath .end (), it->errors .cbegin (), it->errors .cend ());
@@ -3756,7 +3755,7 @@ static void valueFlowForwardConst(Token* start,
37563755 continue ;
37573756 if (v.tokvalue ->varId () != var->declarationId ())
37583757 continue ;
3759- for (ValueFlow::Value value : values) {
3758+ for (ValueFlow::Value& value : values) {
37603759 if (!v.isKnown () && value.isImpossible ())
37613760 continue ;
37623761 if (v.intvalue != 0 ) {
@@ -3775,15 +3774,6 @@ static void valueFlowForwardConst(Token* start,
37753774 }
37763775}
37773776
3778- static void valueFlowForwardConst (Token* start,
3779- const Token* end,
3780- const Variable* var,
3781- const std::initializer_list<ValueFlow::Value>& values,
3782- const Settings& settings)
3783- {
3784- valueFlowForwardConst (start, end, var, values, settings, 0 );
3785- }
3786-
37873777static ValueFlow::Value::Bound findVarBound (const Variable* var,
37883778 const Token* start,
37893779 const Token* end,
@@ -3911,7 +3901,7 @@ static void valueFlowForwardAssign(Token* const tok,
39113901 });
39123902 std::list<ValueFlow::Value> constValues;
39133903 constValues.splice (constValues.end (), values, it, values.end ());
3914- valueFlowForwardConst (nextExpression, endOfVarScope, expr->variable (), constValues, settings);
3904+ valueFlowForwardConst (nextExpression, endOfVarScope, expr->variable (), std::move ( constValues) , settings);
39153905 }
39163906 if (isInitialVarAssign (expr)) {
39173907 // Check if variable is only incremented or decremented
@@ -3927,7 +3917,7 @@ static void valueFlowForwardAssign(Token* const tok,
39273917 value.bound = b;
39283918 value.invertRange ();
39293919 value.setImpossible ();
3930- valueFlowForwardConst (nextExpression, endOfVarScope, expr->variable (), {std::move (value)}, settings);
3920+ valueFlowForwardConst (nextExpression, endOfVarScope, expr->variable (), std::list<ValueFlow::Value> {std::move (value)}, settings);
39313921 }
39323922 }
39333923 }
@@ -6478,7 +6468,7 @@ static void valueFlowContainerSetTokValue(const TokenList& tokenlist, ErrorLogge
64786468 value.setKnown ();
64796469 Token* start = initList->link () ? initList->link () : initList->next ();
64806470 if (tok->variable () && tok->variable ()->isConst ()) {
6481- valueFlowForwardConst (start, tok->variable ()->scope ()->bodyEnd , tok->variable (), {std::move (value)}, settings);
6471+ valueFlowForwardConst (start, tok->variable ()->scope ()->bodyEnd , tok->variable (), std::list<ValueFlow::Value> {std::move (value)}, settings);
64826472 } else {
64836473 valueFlowForward (start, tok, std::move (value), tokenlist, errorLogger, settings);
64846474 }
0 commit comments