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

Function isLocalContainerBuffer

lib/checkautovariables.cpp:142–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

140}
141
142static bool isLocalContainerBuffer(const Token* tok, const Settings& settings)
143{
144 if (!tok)
145 return false;
146
147 // x+y
148 if (tok->str() == "+")
149 return isLocalContainerBuffer(tok->astOperand1(), settings) || isLocalContainerBuffer(tok->astOperand2(), settings);
150
151 if (tok->str() != "(" || !Token::simpleMatch(tok->astOperand1(), "."))
152 return false;
153
154 tok = tok->astOperand1()->astOperand1();
155
156 const Variable* var = tok->variable();
157 if (!var || !var->isLocal() || var->isStatic())
158 return false;
159
160 const Library::Container::Yield yield = astContainerYield(tok, settings.library);
161
162 return yield == Library::Container::Yield::BUFFER || yield == Library::Container::Yield::BUFFER_NT;
163}
164
165static bool isAddressOfLocalVariable(const Token *expr)
166{

Callers 1

isAutoVariableRHSFunction · 0.85

Calls 6

astContainerYieldFunction · 0.85
astOperand1Method · 0.80
astOperand2Method · 0.80
variableMethod · 0.80
simpleMatchFunction · 0.70
strMethod · 0.45

Tested by

no test coverage detected