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

Function isVarUsedInTree

lib/checkleakautovar.cpp:187–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

185}
186
187static bool isVarUsedInTree(const Token *tok, nonneg int varid)
188{
189 if (!tok)
190 return false;
191 std::deque<const Token*> nodes{ tok };
192 while (!nodes.empty()) {
193 const Token* node = nodes.front();
194 if (node->varId() == varid)
195 return true;
196 if (node->str() != "(" || !Token::simpleMatch(node->astOperand1(), "sizeof")) {
197 if (node->astOperand1())
198 nodes.emplace_back(node->astOperand1());
199 if (node->astOperand2())
200 nodes.emplace_back(node->astOperand2());
201 }
202 nodes.pop_front();
203 }
204 return false;
205}
206
207static bool isPointerReleased(const Token *startToken, const Token *endToken, nonneg int varid)
208{

Callers 1

checkScopeMethod · 0.85

Calls 6

frontMethod · 0.80
astOperand1Method · 0.80
astOperand2Method · 0.80
simpleMatchFunction · 0.70
emptyMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected