@@ -3795,16 +3795,15 @@ template<class ContainerOfValue>
37953795static void valueFlowForwardConst (Token* start,
37963796 const Token* end,
37973797 const Variable* var,
3798- const ContainerOfValue& values,
3799- const Settings& settings,
3800- int /* unused*/ = 0 )
3798+ ContainerOfValue values,
3799+ const Settings& settings)
38013800{
38023801 if (!precedes (start, end))
38033802 throw InternalError (var->nameToken (), " valueFlowForwardConst: start token does not precede the end token." );
38043803 for (Token* tok = start; tok != end; tok = tok->next ()) {
38053804 if (tok->varId () == var->declarationId ()) {
3806- for (const ValueFlow::Value& value : values)
3807- setTokenValue (tok, value, settings);
3805+ for (ValueFlow::Value& value : values)
3806+ setTokenValue (tok, std::move ( value) , settings);
38083807 } else {
38093808 [&] {
38103809 // Follow references
@@ -3813,7 +3812,7 @@ static void valueFlowForwardConst(Token* start,
38133812 return ref.token ->varId () == var->declarationId ();
38143813 });
38153814 if (it != refs.end ()) {
3816- for (ValueFlow::Value value : values) {
3815+ for (ValueFlow::Value& value : values) {
38173816 if (refs.size () > 1 )
38183817 value.setInconclusive ();
38193818 value.errorPath .insert (value.errorPath .end (), it->errors .cbegin (), it->errors .cend ());
@@ -3829,7 +3828,7 @@ static void valueFlowForwardConst(Token* start,
38293828 continue ;
38303829 if (v.tokvalue ->varId () != var->declarationId ())
38313830 continue ;
3832- for (ValueFlow::Value value : values) {
3831+ for (ValueFlow::Value& value : values) {
38333832 if (!v.isKnown () && value.isImpossible ())
38343833 continue ;
38353834 if (v.intvalue != 0 ) {
@@ -3849,15 +3848,6 @@ static void valueFlowForwardConst(Token* start,
38493848 }
38503849}
38513850
3852- static void valueFlowForwardConst (Token* start,
3853- const Token* end,
3854- const Variable* var,
3855- const std::initializer_list<ValueFlow::Value>& values,
3856- const Settings& settings)
3857- {
3858- valueFlowForwardConst (start, end, var, values, settings, 0 );
3859- }
3860-
38613851static ValueFlow::Value::Bound findVarBound (const Variable* var,
38623852 const Token* start,
38633853 const Token* end,
@@ -3985,7 +3975,7 @@ static void valueFlowForwardAssign(Token* const tok,
39853975 });
39863976 std::list<ValueFlow::Value> constValues;
39873977 constValues.splice (constValues.end (), values, it, values.end ());
3988- valueFlowForwardConst (nextExpression, endOfVarScope, expr->variable (), constValues, settings);
3978+ valueFlowForwardConst (nextExpression, endOfVarScope, expr->variable (), std::move ( constValues) , settings);
39893979 }
39903980 if (isInitialVarAssign (expr)) {
39913981 // Check if variable is only incremented or decremented
@@ -4001,7 +3991,7 @@ static void valueFlowForwardAssign(Token* const tok,
40013991 value.bound = b;
40023992 value.invertRange ();
40033993 value.setImpossible ();
4004- valueFlowForwardConst (nextExpression, endOfVarScope, expr->variable (), {std::move (value)}, settings);
3994+ valueFlowForwardConst (nextExpression, endOfVarScope, expr->variable (), std::list<ValueFlow::Value> {std::move (value)}, settings);
40053995 }
40063996 }
40073997 }
@@ -6579,7 +6569,7 @@ static void valueFlowContainerSetTokValue(const TokenList& tokenlist, ErrorLogge
65796569 value.setKnown ();
65806570 Token* start = initList->link () ? initList->link () : initList->next ();
65816571 if (tok->variable () && tok->variable ()->isConst ()) {
6582- valueFlowForwardConst (start, tok->variable ()->scope ()->bodyEnd , tok->variable (), {std::move (value)}, settings);
6572+ valueFlowForwardConst (start, tok->variable ()->scope ()->bodyEnd , tok->variable (), std::list<ValueFlow::Value> {std::move (value)}, settings);
65836573 } else {
65846574 valueFlowForward (start, tok, std::move (value), tokenlist, errorLogger, settings);
65856575 }
0 commit comments