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

Method byDerefCopy

lib/valueflow.cpp:2265–2301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2263
2264 template<class Predicate>
2265 bool byDerefCopy(Token* tok,
2266 const TokenList& tokenlist,
2267 ErrorLogger& errorLogger,
2268 const Settings& settings,
2269 Predicate pred,
2270 SourceLocation loc = SourceLocation::current()) const
2271 {
2272 bool update = false;
2273 if (!settings.certainty.isEnabled(Certainty::inconclusive) && inconclusive)
2274 return update;
2275 if (!argtok)
2276 return update;
2277 if (!tok)
2278 return update;
2279 for (const ValueFlow::Value &v : argtok->values()) {
2280 if (!v.isLifetimeValue())
2281 continue;
2282 const Token *tok2 = v.tokvalue;
2283 ErrorPath er = v.errorPath;
2284 const Variable *var = ValueFlow::getLifetimeVariable(tok2, er, settings);
2285 // TODO: the inserted data is never used
2286 er.insert(er.end(), errorPath.cbegin(), errorPath.cend());
2287 if (!var)
2288 continue;
2289 const Token * const varDeclEndToken = var->declEndToken();
2290 if (!varDeclEndToken)
2291 continue;
2292 for (const Token *tok3 = tok; tok3 && tok3 != varDeclEndToken; tok3 = tok3->previous()) {
2293 if (tok3->varId() == var->declarationId()) {
2294 update |= LifetimeStore{tok3, message, type, inconclusive}
2295 .byVal(tok, tokenlist, errorLogger, settings, pred, loc);
2296 break;
2297 }
2298 }
2299 }
2300 return update;
2301 }
2302
2303 bool byDerefCopy(Token* tok,
2304 const TokenList& tokenlist,

Callers 2

Calls 4

declEndTokenMethod · 0.80
byValMethod · 0.80
isEnabledMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected