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

Function isVariablesChanged

lib/astutils.cpp:3028–3052  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3026}
3027
3028bool isVariablesChanged(const Token* start,
3029 const Token* end,
3030 int indirect,
3031 const std::vector<const Variable*> &vars,
3032 const Settings& settings)
3033{
3034 std::set<int> varids;
3035 std::transform(vars.cbegin(), vars.cend(), std::inserter(varids, varids.begin()), [](const Variable* var) {
3036 return var->declarationId();
3037 });
3038 const bool globalvar = std::any_of(vars.cbegin(), vars.cend(), [](const Variable* var) {
3039 return var->isGlobal();
3040 });
3041 for (const Token* tok = start; tok && tok != end; tok = tok->next()) {
3042 if (tok->varId() == 0 || varids.count(tok->varId()) == 0) {
3043 if (globalvar && Token::Match(tok, "%name% ("))
3044 // TODO: Is global variable really changed by function call?
3045 return true;
3046 continue;
3047 }
3048 if (isVariableChanged(tok, indirect, settings))
3049 return true;
3050 }
3051 return false;
3052}
3053
3054bool isThisChanged(const Token* tok, int indirect, const Settings& settings)
3055{

Callers 2

multiCondition2Method · 0.85
invalidFunctionUsageMethod · 0.85

Calls 4

isVariableChangedFunction · 0.85
nextMethod · 0.80
beginMethod · 0.45
isGlobalMethod · 0.45

Tested by

no test coverage detected