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

Function analyze

lib/vf_analyzers.cpp:646–673  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

644 }
645
646 Action analyze(const Token* tok, Direction d) const override {
647 if (invalid())
648 return Action::Invalid;
649 // Follow references
650 // TODO: avoid copy
651 auto refs = tok->refs();
652 const bool inconclusiveRefs = refs.size() != 1;
653 if (std::none_of(refs.cbegin(), refs.cend(), [&](const ReferenceToken& ref) {
654 return tok == ref.token;
655 }))
656 refs.emplace_back(ReferenceToken{tok, {}});
657 for (const ReferenceToken& ref:refs) {
658 Action a = analyzeToken(ref.token, tok, d, inconclusiveRefs && ref.token != tok);
659 if (internalMatch(ref.token))
660 a |= Action::Internal;
661 if (a != Action::None)
662 return a;
663 }
664 if (dependsOnThis() && exprDependsOnThis(tok, !isClassVariable()))
665 return isThisModified(tok);
666
667 // bailout: global non-const variables
668 if (isGlobal() && !dependsOnThis() && Token::Match(tok, "%name% (") && !tok->variable() &&
669 !Token::simpleMatch(tok->linkAt(1), ") {")) {
670 return isGlobalModified(tok);
671 }
672 return Action::None;
673 }
674
675 template<class F>
676 std::vector<MathLib::bigint> evaluateInt(const Token* tok, F getProgramMemoryFunc) const

Callers 1

analyzeConditionFunction · 0.85

Calls 13

invalidFunction · 0.85
analyzeTokenFunction · 0.85
internalMatchFunction · 0.85
dependsOnThisFunction · 0.85
exprDependsOnThisFunction · 0.85
isClassVariableFunction · 0.85
isThisModifiedFunction · 0.85
isGlobalModifiedFunction · 0.85
variableMethod · 0.80
linkAtMethod · 0.80
isGlobalFunction · 0.70
simpleMatchFunction · 0.70

Tested by

no test coverage detected