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

Method nothrowThrows

lib/checkexceptionsafety.cpp:284–314  ·  view source on GitHub ↗

-------------------------------------------------------------------------- void func() noexcept { throw x; } void func() throw() { throw x; } void func() __attribute__((nothrow)); void func() { throw x; } --------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

282// void func() __attribute__((nothrow)); void func() { throw x; }
283//--------------------------------------------------------------------------
284void CheckExceptionSafetyImpl::nothrowThrows()
285{
286 logChecker("CheckExceptionSafety::nothrowThrows");
287
288 const SymbolDatabase* const symbolDatabase = mTokenizer->getSymbolDatabase();
289
290 for (const Scope * scope : symbolDatabase->functionScopes) {
291 const Function* function = scope->function;
292 if (!function)
293 continue;
294
295 bool isNoExcept = false, isEntryPoint = false;
296 if (function->isNoExcept() || // noexcept and noexcept(true) functions
297 (function->isThrow() && !function->throwArg) || // throw() functions
298 function->isAttributeNothrow()) { // __attribute__((nothrow)) or __declspec(nothrow) functions
299 isNoExcept = true;
300 }
301 else if (mSettings.library.isentrypoint(function->name())) {
302 isEntryPoint = true;
303 }
304 if (!isNoExcept && !isEntryPoint)
305 continue;
306
307 if (const Token* throws = functionThrows(function)) {
308 if (isEntryPoint)
309 entryPointThrowError(throws);
310 else
311 noexceptThrowError(throws);
312 }
313 }
314}
315
316void CheckExceptionSafetyImpl::noexceptThrowError(const Token * const tok)
317{

Callers 1

runChecksMethod · 0.80

Calls 3

functionThrowsFunction · 0.85
isentrypointMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected