-------------------------------------------------------------------------- void func() { functionWithExceptionSpecification(); } --------------------------------------------------------------------------
| 327 | // void func() { functionWithExceptionSpecification(); } |
| 328 | //-------------------------------------------------------------------------- |
| 329 | void CheckExceptionSafetyImpl::unhandledExceptionSpecification() |
| 330 | { |
| 331 | if ((!mSettings.severity.isEnabled(Severity::style) || !mSettings.certainty.isEnabled(Certainty::inconclusive)) && |
| 332 | !mSettings.isPremiumEnabled("unhandledExceptionSpecification")) |
| 333 | return; |
| 334 | |
| 335 | logChecker("CheckExceptionSafety::unhandledExceptionSpecification"); // style,inconclusive |
| 336 | |
| 337 | const SymbolDatabase* const symbolDatabase = mTokenizer->getSymbolDatabase(); |
| 338 | |
| 339 | for (const Scope * scope : symbolDatabase->functionScopes) { |
| 340 | // only check functions without exception specification |
| 341 | if (scope->function && !scope->function->isThrow() && !mSettings.library.isentrypoint(scope->className)) { |
| 342 | for (const Token *tok = scope->function->functionScope->bodyStart->next(); |
| 343 | tok != scope->function->functionScope->bodyEnd; tok = tok->next()) { |
| 344 | if (tok->str() == "try") |
| 345 | break; |
| 346 | if (tok->function()) { |
| 347 | const Function * called = tok->function(); |
| 348 | // check if called function has an exception specification |
| 349 | if (called->isThrow() && called->throwArg) { |
| 350 | unhandledExceptionSpecificationError(tok, called->tokenDef, scope->function->name()); |
| 351 | break; |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | void CheckExceptionSafetyImpl::unhandledExceptionSpecificationError(const Token * const tok1, const Token * const tok2, const std::string & funcname) |
| 360 | { |
no test coverage detected