Skip to content

Commit

Permalink
vf_analyzers.cpp: avoid unnecessary copy in `ValueFlowAnaylzer::analy…
Browse files Browse the repository at this point in the history
…ze()`
  • Loading branch information
firewave committed Jan 14, 2025
1 parent d3e35a0 commit a36380e
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions lib/vf_analyzers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,16 +627,25 @@ struct ValueFlowAnalyzer : Analyzer {
if (invalid())
return Action::Invalid;
// Follow references
auto refs = tok->refs();
const auto& refs = tok->refs();
const bool inconclusiveRefs = refs.size() != 1;
if (std::none_of(refs.cbegin(), refs.cend(), [&](const ReferenceToken& ref) {
const bool analyzeTok = std::none_of(refs.cbegin(), refs.cend(), [&](const ReferenceToken& ref) {
return tok == ref.token;
}))
refs.emplace_back(ReferenceToken{tok, {}});
for (const ReferenceToken& ref:refs) {
Action a = analyzeToken(ref.token, tok, d, inconclusiveRefs && ref.token != tok);
if (internalMatch(ref.token))
});
auto analyze_f = [&](const Token* ref_token) -> Action
{
Action a = analyzeToken(ref_token, tok, d, inconclusiveRefs && ref_token != tok);
if (internalMatch(ref_token))
a |= Action::Internal;
return a;
};
for (const ReferenceToken& ref:refs) {
auto a = analyze_f(ref.token);
if (a != Action::None)
return a;
}
if (analyzeTok) {
auto a = analyze_f(tok);
if (a != Action::None)
return a;
}
Expand Down

0 comments on commit a36380e

Please sign in to comment.