| 2248 | } |
| 2249 | |
| 2250 | static 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 | |
| 2280 | bool isReturnScope(const Token* const endToken, const Library& library, const Token** unknownFunc, bool functionScope) |
| 2281 | { |
no test coverage detected