MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / updateScope

Method updateScope

lib/vf_analyzers.cpp:1041–1072  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1039 }
1040
1041 bool updateScope(const Token* endBlock, bool /*modified*/) const override {
1042 const Scope* scope = endBlock->scope();
1043 if (!scope)
1044 return false;
1045 if (scope->type == ScopeType::eLambda) {
1046 return std::all_of(values.cbegin(), values.cend(), [](const std::pair<nonneg int, ValueFlow::Value>& p) {
1047 return p.second.isLifetimeValue();
1048 });
1049 }
1050 if (scope->type == ScopeType::eIf || scope->type == ScopeType::eElse || scope->type == ScopeType::eWhile ||
1051 scope->type == ScopeType::eFor) {
1052 auto pred = [](const ValueFlow::Value& value) {
1053 if (value.isKnown())
1054 return true;
1055 if (value.isImpossible())
1056 return true;
1057 if (value.isLifetimeValue())
1058 return true;
1059 return false;
1060 };
1061 if (std::all_of(values.cbegin(), values.cend(), std::bind(pred, std::bind(SelectMapValues{}, std::placeholders::_1))))
1062 return true;
1063 if (isConditional())
1064 return false;
1065 const Token* condTok = getCondTokFromEnd(endBlock);
1066 std::set<nonneg int> varids;
1067 std::transform(getVars().cbegin(), getVars().cend(), std::inserter(varids, varids.begin()), SelectMapKeys{});
1068 return bifurcate(condTok, varids, getSettings());
1069 }
1070
1071 return false;
1072 }
1073
1074 bool match(const Token* tok) const override {
1075 return values.count(tok->varId()) > 0;

Callers 5

tryForkScopeFunction · 0.45
tryForkUpdateScopeFunction · 0.45
checkBranchFunction · 0.45
reentersLoopFunction · 0.45
updateRangeFunction · 0.45

Calls 6

getCondTokFromEndFunction · 0.85
bifurcateFunction · 0.85
scopeMethod · 0.80
isKnownMethod · 0.80
isImpossibleMethod · 0.80
beginMethod · 0.45

Tested by

no test coverage detected