Skip to content

Commit 6e60515

Browse files
committed
valueflow.cpp: removed unnecessary lambda encapsulation in valueFlowForwardConst()
1 parent f8eea15 commit 6e60515

1 file changed

Lines changed: 32 additions & 34 deletions

File tree

lib/valueflow.cpp

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -3972,45 +3972,43 @@ static void valueFlowForwardConst(Token* start,
39723972
for (const ValueFlow::Value& value : values)
39733973
setTokenValue(tok, value, settings);
39743974
} else {
3975-
[&] {
3976-
// Follow references
3977-
auto refs = followAllReferences(tok);
3978-
auto it = std::find_if(refs.cbegin(), refs.cend(), [&](const ReferenceToken& ref) {
3979-
return ref.token->varId() == var->declarationId();
3980-
});
3981-
if (it != refs.end()) {
3982-
for (ValueFlow::Value value : values) {
3983-
if (refs.size() > 1)
3984-
value.setInconclusive();
3985-
value.errorPath.insert(value.errorPath.end(), it->errors.cbegin(), it->errors.cend());
3986-
setTokenValue(tok, std::move(value), settings);
3987-
}
3988-
return;
3975+
// Follow references
3976+
auto refs = followAllReferences(tok);
3977+
auto it = std::find_if(refs.cbegin(), refs.cend(), [&](const ReferenceToken& ref) {
3978+
return ref.token->varId() == var->declarationId();
3979+
});
3980+
if (it != refs.end()) {
3981+
for (ValueFlow::Value value : values) {
3982+
if (refs.size() > 1)
3983+
value.setInconclusive();
3984+
value.errorPath.insert(value.errorPath.end(), it->errors.cbegin(), it->errors.cend());
3985+
setTokenValue(tok, std::move(value), settings);
39893986
}
3990-
// Follow symbolic values
3991-
for (const ValueFlow::Value& v : tok->values()) {
3992-
if (!v.isSymbolicValue())
3993-
continue;
3994-
if (!v.tokvalue)
3995-
continue;
3996-
if (v.tokvalue->varId() != var->declarationId())
3987+
return;
3988+
}
3989+
// Follow symbolic values
3990+
for (const ValueFlow::Value& v : tok->values()) {
3991+
if (!v.isSymbolicValue())
3992+
continue;
3993+
if (!v.tokvalue)
3994+
continue;
3995+
if (v.tokvalue->varId() != var->declarationId())
3996+
continue;
3997+
for (ValueFlow::Value value : values) {
3998+
if (!v.isKnown() && value.isImpossible())
39973999
continue;
3998-
for (ValueFlow::Value value : values) {
3999-
if (!v.isKnown() && value.isImpossible())
4000+
if (v.intvalue != 0) {
4001+
if (!value.isIntValue())
40004002
continue;
4001-
if (v.intvalue != 0) {
4002-
if (!value.isIntValue())
4003-
continue;
4004-
value.intvalue += v.intvalue;
4005-
}
4006-
if (!value.isImpossible())
4007-
value.valueKind = v.valueKind;
4008-
value.bound = v.bound;
4009-
value.errorPath.insert(value.errorPath.end(), v.errorPath.cbegin(), v.errorPath.cend());
4010-
setTokenValue(tok, std::move(value), settings);
4003+
value.intvalue += v.intvalue;
40114004
}
4005+
if (!value.isImpossible())
4006+
value.valueKind = v.valueKind;
4007+
value.bound = v.bound;
4008+
value.errorPath.insert(value.errorPath.end(), v.errorPath.cbegin(), v.errorPath.cend());
4009+
setTokenValue(tok, std::move(value), settings);
40124010
}
4013-
}();
4011+
}
40144012
}
40154013
}
40164014
}

0 commit comments

Comments
 (0)