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

Method findReturns

lib/symboldatabase.cpp:3405–3431  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3403}
3404
3405std::vector<const Token*> Function::findReturns(const Function* f)
3406{
3407 std::vector<const Token*> result;
3408 if (!f)
3409 return result;
3410 const Scope* scope = f->functionScope;
3411 if (!scope)
3412 return result;
3413 if (!scope->bodyStart)
3414 return result;
3415 for (const Token* tok = scope->bodyStart->next(); tok && tok != scope->bodyEnd; tok = tok->next()) {
3416 if (tok->str() == "{" && tok->scope() &&
3417 (tok->scope()->type == ScopeType::eLambda || tok->scope()->type == ScopeType::eClass)) {
3418 tok = tok->link();
3419 continue;
3420 }
3421 if (Token::simpleMatch(tok->astParent(), "return")) {
3422 result.push_back(tok);
3423 }
3424 // Skip lambda functions since the scope may not be set correctly
3425 const Token* lambdaEndToken = findLambdaEndToken(tok);
3426 if (lambdaEndToken) {
3427 tok = lambdaEndToken;
3428 }
3429 }
3430 return result;
3431}
3432
3433const Token * Function::constructorMemberInitialization() const
3434{

Callers

nothing calls this directly

Calls 7

findLambdaEndTokenFunction · 0.85
nextMethod · 0.80
scopeMethod · 0.80
astParentMethod · 0.80
simpleMatchFunction · 0.70
strMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected