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

Function isAutoVar

lib/checkautovariables.cpp:76–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76static bool isAutoVar(const Token *tok)
77{
78 const Variable *var = tok->variable();
79
80 if (!var || !var->isLocal() || var->isStatic())
81 return false;
82
83 if (var->isReference()) {
84 // address of reference variable can be taken if the address
85 // of the variable it points at is not a auto-var
86 // TODO: check what the reference variable references.
87 return false;
88 }
89
90 if (Token::Match(tok, "%name% .|::")) {
91 do {
92 tok = tok->tokAt(2);
93 } while (Token::Match(tok, "%name% .|::"));
94 if (Token::Match(tok, "%name% ("))
95 return false;
96 if (tok->variable() && tok->variable()->isPointer())
97 return false;
98 }
99 return true;
100}
101
102static bool isAutoVarArray(const Token *tok)
103{

Callers 2

isAddressOfLocalVariableFunction · 0.85
autoVariablesMethod · 0.85

Calls 2

variableMethod · 0.80
tokAtMethod · 0.45

Tested by

no test coverage detected