Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 32 additions & 34 deletions lib/valueflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3972,45 +3972,43 @@ static void valueFlowForwardConst(Token* start,
for (const ValueFlow::Value& value : values)
setTokenValue(tok, value, settings);
} else {
[&] {
// Follow references
auto refs = followAllReferences(tok);
auto it = std::find_if(refs.cbegin(), refs.cend(), [&](const ReferenceToken& ref) {
return ref.token->varId() == var->declarationId();
});
if (it != refs.end()) {
for (ValueFlow::Value value : values) {
if (refs.size() > 1)
value.setInconclusive();
value.errorPath.insert(value.errorPath.end(), it->errors.cbegin(), it->errors.cend());
setTokenValue(tok, std::move(value), settings);
}
return;
// Follow references
auto refs = followAllReferences(tok);
auto it = std::find_if(refs.cbegin(), refs.cend(), [&](const ReferenceToken& ref) {
return ref.token->varId() == var->declarationId();
});
if (it != refs.end()) {
for (ValueFlow::Value value : values) {
if (refs.size() > 1)
value.setInconclusive();
value.errorPath.insert(value.errorPath.end(), it->errors.cbegin(), it->errors.cend());
setTokenValue(tok, std::move(value), settings);
}
// Follow symbolic values
for (const ValueFlow::Value& v : tok->values()) {
if (!v.isSymbolicValue())
continue;
if (!v.tokvalue)
continue;
if (v.tokvalue->varId() != var->declarationId())
return;
}
// Follow symbolic values
for (const ValueFlow::Value& v : tok->values()) {
if (!v.isSymbolicValue())
continue;
if (!v.tokvalue)
continue;
if (v.tokvalue->varId() != var->declarationId())
continue;
for (ValueFlow::Value value : values) {
if (!v.isKnown() && value.isImpossible())
continue;
for (ValueFlow::Value value : values) {
if (!v.isKnown() && value.isImpossible())
if (v.intvalue != 0) {
if (!value.isIntValue())
continue;
if (v.intvalue != 0) {
if (!value.isIntValue())
continue;
value.intvalue += v.intvalue;
}
if (!value.isImpossible())
value.valueKind = v.valueKind;
value.bound = v.bound;
value.errorPath.insert(value.errorPath.end(), v.errorPath.cbegin(), v.errorPath.cend());
setTokenValue(tok, std::move(value), settings);
value.intvalue += v.intvalue;
}
if (!value.isImpossible())
value.valueKind = v.valueKind;
value.bound = v.bound;
value.errorPath.insert(value.errorPath.end(), v.errorPath.cbegin(), v.errorPath.cend());
setTokenValue(tok, std::move(value), settings);
}
}();
}
}
}
}
Expand Down
Loading