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

Function hasNoreturnFunction

lib/astutils.cpp:2250–2278  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2248}
2249
2250static bool hasNoreturnFunction(const Token* tok, const Library& library, const Token** unknownFunc)
2251{
2252 if (!tok)
2253 return false;
2254 const Token* ftok = (tok->str() == "(" && !tok->isCast()) ? tok->previous() : nullptr;
2255 while (Token::simpleMatch(ftok, "("))
2256 ftok = ftok->astOperand1();
2257 if (ftok) {
2258 const Function * function = ftok->function();
2259 if (function) {
2260 if (function->isEscapeFunction())
2261 return true;
2262 if (function->isAttributeNoreturn())
2263 return true;
2264 } else if (library.isnoreturn(ftok)) {
2265 return true;
2266 } else if (Token::Match(ftok, "exit|abort")) {
2267 return true;
2268 }
2269 if (unknownFunc && !function && library.functions().count(library.getFunctionName(ftok)) == 0)
2270 *unknownFunc = ftok;
2271 return false;
2272 }
2273 if (tok->isConstOp()) {
2274 return hasNoreturnFunction(tok->astOperand1(), library, unknownFunc) || hasNoreturnFunction(tok->astOperand2(), library, unknownFunc);
2275 }
2276
2277 return false;
2278}
2279
2280bool isReturnScope(const Token* const endToken, const Library& library, const Token** unknownFunc, bool functionScope)
2281{

Callers 1

isReturnScopeFunction · 0.85

Calls 9

isCastMethod · 0.80
astOperand1Method · 0.80
isnoreturnMethod · 0.80
getFunctionNameMethod · 0.80
isConstOpMethod · 0.80
astOperand2Method · 0.80
simpleMatchFunction · 0.70
strMethod · 0.45
functionMethod · 0.45

Tested by

no test coverage detected