@@ -3815,16 +3815,15 @@ template<class ContainerOfValue>
38153815static void valueFlowForwardConst (Token* start,
38163816 const Token* end,
38173817 const Variable* var,
3818- const ContainerOfValue& values,
3819- const Settings& settings,
3820- int /* unused*/ = 0 )
3818+ ContainerOfValue values,
3819+ const Settings& settings)
38213820{
38223821 if (!precedes (start, end))
38233822 throw InternalError (var->nameToken (), " valueFlowForwardConst: start token does not precede the end token." );
38243823 for (Token* tok = start; tok != end; tok = tok->next ()) {
38253824 if (tok->varId () == var->declarationId ()) {
3826- for (const ValueFlow::Value& value : values)
3827- setTokenValue (tok, value, settings);
3825+ for (ValueFlow::Value& value : values)
3826+ setTokenValue (tok, std::move ( value) , settings);
38283827 } else {
38293828 [&] {
38303829 // Follow references
@@ -3833,7 +3832,7 @@ static void valueFlowForwardConst(Token* start,
38333832 return ref.token ->varId () == var->declarationId ();
38343833 });
38353834 if (it != refs.end ()) {
3836- for (ValueFlow::Value value : values) {
3835+ for (ValueFlow::Value& value : values) {
38373836 if (refs.size () > 1 )
38383837 value.setInconclusive ();
38393838 value.errorPath .insert (value.errorPath .end (), it->errors .cbegin (), it->errors .cend ());
@@ -3849,7 +3848,7 @@ static void valueFlowForwardConst(Token* start,
38493848 continue ;
38503849 if (v.tokvalue ->varId () != var->declarationId ())
38513850 continue ;
3852- for (ValueFlow::Value value : values) {
3851+ for (ValueFlow::Value& value : values) {
38533852 if (!v.isKnown () && value.isImpossible ())
38543853 continue ;
38553854 if (v.intvalue != 0 ) {
@@ -3869,15 +3868,6 @@ static void valueFlowForwardConst(Token* start,
38693868 }
38703869}
38713870
3872- static void valueFlowForwardConst (Token* start,
3873- const Token* end,
3874- const Variable* var,
3875- const std::initializer_list<ValueFlow::Value>& values,
3876- const Settings& settings)
3877- {
3878- valueFlowForwardConst (start, end, var, values, settings, 0 );
3879- }
3880-
38813871static ValueFlow::Value::Bound findVarBound (const Variable* var,
38823872 const Token* start,
38833873 const Token* end,
@@ -4005,7 +3995,7 @@ static void valueFlowForwardAssign(Token* const tok,
40053995 });
40063996 std::list<ValueFlow::Value> constValues;
40073997 constValues.splice (constValues.end (), values, it, values.end ());
4008- valueFlowForwardConst (nextExpression, endOfVarScope, expr->variable (), constValues, settings);
3998+ valueFlowForwardConst (nextExpression, endOfVarScope, expr->variable (), std::move ( constValues) , settings);
40093999 }
40104000 if (isInitialVarAssign (expr)) {
40114001 // Check if variable is only incremented or decremented
@@ -4021,7 +4011,7 @@ static void valueFlowForwardAssign(Token* const tok,
40214011 value.bound = b;
40224012 value.invertRange ();
40234013 value.setImpossible ();
4024- valueFlowForwardConst (nextExpression, endOfVarScope, expr->variable (), {std::move (value)}, settings);
4014+ valueFlowForwardConst (nextExpression, endOfVarScope, expr->variable (), std::list<ValueFlow::Value> {std::move (value)}, settings);
40254015 }
40264016 }
40274017 }
@@ -6623,7 +6613,7 @@ static void valueFlowContainerSetTokValue(const TokenList& tokenlist, ErrorLogge
66236613 value.setKnown ();
66246614 Token* start = initList->link () ? initList->link () : initList->next ();
66256615 if (tok->variable () && tok->variable ()->isConst ()) {
6626- valueFlowForwardConst (start, tok->variable ()->scope ()->bodyEnd , tok->variable (), {std::move (value)}, settings);
6616+ valueFlowForwardConst (start, tok->variable ()->scope ()->bodyEnd , tok->variable (), std::list<ValueFlow::Value> {std::move (value)}, settings);
66276617 } else {
66286618 valueFlowForward (start, tok, std::move (value), tokenlist, errorLogger, settings);
66296619 }
0 commit comments