@@ -3734,45 +3734,43 @@ static void valueFlowForwardConst(Token* start,
37343734 for (const ValueFlow::Value& value : values)
37353735 setTokenValue (tok, value, settings);
37363736 } else {
3737- [&] {
3738- // Follow references
3739- auto refs = followAllReferences (tok);
3740- auto it = std::find_if (refs.cbegin (), refs.cend (), [&](const ReferenceToken& ref) {
3741- return ref.token ->varId () == var->declarationId ();
3742- });
3743- if (it != refs.end ()) {
3744- for (ValueFlow::Value value : values) {
3745- if (refs.size () > 1 )
3746- value.setInconclusive ();
3747- value.errorPath .insert (value.errorPath .end (), it->errors .cbegin (), it->errors .cend ());
3748- setTokenValue (tok, std::move (value), settings);
3749- }
3750- return ;
3737+ // Follow references
3738+ auto refs = followAllReferences (tok);
3739+ auto it = std::find_if (refs.cbegin (), refs.cend (), [&](const ReferenceToken& ref) {
3740+ return ref.token ->varId () == var->declarationId ();
3741+ });
3742+ if (it != refs.end ()) {
3743+ for (ValueFlow::Value value : values) {
3744+ if (refs.size () > 1 )
3745+ value.setInconclusive ();
3746+ value.errorPath .insert (value.errorPath .end (), it->errors .cbegin (), it->errors .cend ());
3747+ setTokenValue (tok, std::move (value), settings);
37513748 }
3752- // Follow symbolic values
3753- for (const ValueFlow::Value& v : tok->values ()) {
3754- if (!v.isSymbolicValue ())
3755- continue ;
3756- if (!v.tokvalue )
3757- continue ;
3758- if (v.tokvalue ->varId () != var->declarationId ())
3749+ return ;
3750+ }
3751+ // Follow symbolic values
3752+ for (const ValueFlow::Value& v : tok->values ()) {
3753+ if (!v.isSymbolicValue ())
3754+ continue ;
3755+ if (!v.tokvalue )
3756+ continue ;
3757+ if (v.tokvalue ->varId () != var->declarationId ())
3758+ continue ;
3759+ for (ValueFlow::Value value : values) {
3760+ if (!v.isKnown () && value.isImpossible ())
37593761 continue ;
3760- for (ValueFlow::Value value : values ) {
3761- if (!v. isKnown () && value.isImpossible ())
3762+ if (v. intvalue != 0 ) {
3763+ if (!value.isIntValue ())
37623764 continue ;
3763- if (v.intvalue != 0 ) {
3764- if (!value.isIntValue ())
3765- continue ;
3766- value.intvalue += v.intvalue ;
3767- }
3768- if (!value.isImpossible ())
3769- value.valueKind = v.valueKind ;
3770- value.bound = v.bound ;
3771- value.errorPath .insert (value.errorPath .end (), v.errorPath .cbegin (), v.errorPath .cend ());
3772- setTokenValue (tok, std::move (value), settings);
3765+ value.intvalue += v.intvalue ;
37733766 }
3767+ if (!value.isImpossible ())
3768+ value.valueKind = v.valueKind ;
3769+ value.bound = v.bound ;
3770+ value.errorPath .insert (value.errorPath .end (), v.errorPath .cbegin (), v.errorPath .cend ());
3771+ setTokenValue (tok, std::move (value), settings);
37743772 }
3775- }();
3773+ }
37763774 }
37773775 }
37783776}
0 commit comments