//-------------------------------------------------------------------------- // void func() noexcept { throw x; } // void func() throw() { throw x; } // void func() __attribute__((nothrow)); void func() { throw x; } //-------------------------------------------------------------------------- void CheckExceptionSafety::nothrowThrows() { const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase(); const std::size_t functions = symbolDatabase->functionScopes.size(); for (std::size_t i = 0; i < functions; ++i) { const Scope * scope = symbolDatabase->functionScopes[i]; const Function* function = scope->function; if (!function) continue; // check noexcept and noexcept(true) functions if (function->isNoExcept() && (!function->noexceptArg || function->noexceptArg->str() == "true")) { const Token *throws = functionThrows(function); if (throws) noexceptThrowError(throws); } // check throw() functions else if (function->isThrow() && !function->throwArg) { const Token *throws = functionThrows(function); if (throws) noexceptThrowError(throws); } // check __attribute__((nothrow)) or __declspec(nothrow) functions else if (function->isAttributeNothrow()) { const Token *throws = functionThrows(function); if (throws) noexceptThrowError(throws); } } }
//-------------------------------------------------------------------------- // void func() noexcept { throw x; } // void func() throw() { throw x; } // void func() __attribute__((nothrow)); void func() { throw x; } //-------------------------------------------------------------------------- void CheckExceptionSafety::nothrowThrows() { const SymbolDatabase* const symbolDatabase = _tokenizer->getSymbolDatabase(); const std::size_t functions = symbolDatabase->functionScopes.size(); for (std::size_t i = 0; i < functions; ++i) { const Scope * scope = symbolDatabase->functionScopes[i]; // check noexcept functions if (scope->function && scope->function->isNoExcept && (!scope->function->noexceptArg || scope->function->noexceptArg->str() == "true")) { const Token *throws = functionThrows(scope->function); if (throws) noexceptThrowError(throws); } // check throw() functions else if (scope->function && scope->function->isThrow && !scope->function->throwArg) { const Token *throws = functionThrows(scope->function); if (throws) nothrowThrowError(throws); } // check __attribute__((nothrow)) functions else if (scope->function && scope->function->isAttributeNothrow()) { const Token *throws = functionThrows(scope->function); if (throws) nothrowAttributeThrowError(throws); } // check __declspec(nothrow) functions else if (scope->function && scope->function->isDeclspecNothrow()) { const Token *throws = functionThrows(scope->function); if (throws) nothrowDeclspecThrowError(throws); } } }