@@ -38,10 +38,10 @@ void CheckExceptionSafety::destructors()
3838 const std::size_t functions = symbolDatabase->functionScopes .size ();
3939 for (std::size_t i = 0 ; i < functions; ++i) {
4040 const Scope * scope = symbolDatabase->functionScopes [i];
41- const Function * j = scope->function ;
42- if (j ) {
41+ const Function * function = scope->function ;
42+ if (function ) {
4343 // only looking for destructors
44- if (j ->type == Function::eDestructor) {
44+ if (function ->type == Function::eDestructor) {
4545 // Inspect this destructor.
4646 for (const Token *tok = scope->classStart ->next (); tok != scope->classEnd ; tok = tok->next ()) {
4747 // Skip try blocks
@@ -103,7 +103,7 @@ void CheckExceptionSafety::deallocThrow()
103103 const unsigned int varid (tok->varId ());
104104
105105 // Token where throw occurs
106- const Token *ThrowToken = nullptr ;
106+ const Token *throwToken = nullptr ;
107107
108108 // is there a throw after the deallocation?
109109 const Token* const end2 = tok->scope ()->classEnd ;
@@ -114,13 +114,13 @@ void CheckExceptionSafety::deallocThrow()
114114 deallocThrowError (tok2, tok->str ());
115115 break ;
116116 }
117- ThrowToken = tok2;
117+ throwToken = tok2;
118118 }
119119
120120 // Variable is assigned -> Bail out
121121 else if (Token::Match (tok2, " %varid% =" , varid)) {
122- if (ThrowToken ) // For non-inconclusive checking, wait until we find an assignment to it. Otherwise we assume it is safe to leave a dead pointer.
123- deallocThrowError (ThrowToken , tok2->str ());
122+ if (throwToken ) // For non-inconclusive checking, wait until we find an assignment to it. Otherwise we assume it is safe to leave a dead pointer.
123+ deallocThrowError (throwToken , tok2->str ());
124124 break ;
125125 }
126126 // Variable passed to function. Assume it becomes assigned -> Bail out
@@ -236,32 +236,35 @@ void CheckExceptionSafety::nothrowThrows()
236236 const std::size_t functions = symbolDatabase->functionScopes .size ();
237237 for (std::size_t i = 0 ; i < functions; ++i) {
238238 const Scope * scope = symbolDatabase->functionScopes [i];
239+ const Function* function = scope->function ;
240+ if (!function)
241+ continue ;
239242
240243 // check noexcept functions
241- if (scope-> function && scope-> function ->isNoExcept &&
242- (!scope-> function ->noexceptArg || scope-> function ->noexceptArg ->str () == " true" )) {
243- const Token *throws = functionThrows (scope-> function );
244+ if (function->isNoExcept &&
245+ (!function->noexceptArg || function->noexceptArg ->str () == " true" )) {
246+ const Token *throws = functionThrows (function);
244247 if (throws)
245248 noexceptThrowError (throws);
246249 }
247250
248251 // check throw() functions
249- else if (scope-> function && scope-> function -> isThrow && !scope-> function ->throwArg ) {
250- const Token *throws = functionThrows (scope-> function );
252+ else if (function-> isThrow && !function->throwArg ) {
253+ const Token *throws = functionThrows (function);
251254 if (throws)
252255 nothrowThrowError (throws);
253256 }
254257
255258 // check __attribute__((nothrow)) functions
256- else if (scope-> function && scope-> function ->isAttributeNothrow ()) {
257- const Token *throws = functionThrows (scope-> function );
259+ else if (function->isAttributeNothrow ()) {
260+ const Token *throws = functionThrows (function);
258261 if (throws)
259262 nothrowAttributeThrowError (throws);
260263 }
261264
262265 // check __declspec(nothrow) functions
263- else if (scope-> function && scope-> function ->isDeclspecNothrow ()) {
264- const Token *throws = functionThrows (scope-> function );
266+ else if (function->isDeclspecNothrow ()) {
267+ const Token *throws = functionThrows (function);
265268 if (throws)
266269 nothrowDeclspecThrowError (throws);
267270 }
0 commit comments