@@ -72,7 +72,8 @@ void CheckExceptionSafety::destructors()
7272 }
7373}
7474
75- void CheckExceptionSafety::destructorsError (const Token * const tok, const std::string &className) {
75+ void CheckExceptionSafety::destructorsError (const Token * const tok, const std::string &className)
76+ {
7677 reportError (tok, Severity::warning, " exceptThrowInDestructor" ,
7778 " Class " + className + " is not safe, destructor throws exception\n "
7879 " The class " + className + " is not safe because its destructor "
@@ -142,7 +143,8 @@ void CheckExceptionSafety::deallocThrow()
142143 }
143144}
144145
145- void CheckExceptionSafety::deallocThrowError (const Token * const tok, const std::string &varname) {
146+ void CheckExceptionSafety::deallocThrowError (const Token * const tok, const std::string &varname)
147+ {
146148 reportError (tok, Severity::warning, " exceptDeallocThrow" , " Exception thrown in invalid state, '" +
147149 varname + " ' points at deallocated memory." , CWE398 , Certainty::normal);
148150}
@@ -184,7 +186,8 @@ void CheckExceptionSafety::checkRethrowCopy()
184186 }
185187}
186188
187- void CheckExceptionSafety::rethrowCopyError (const Token * const tok, const std::string &varname) {
189+ void CheckExceptionSafety::rethrowCopyError (const Token * const tok, const std::string &varname)
190+ {
188191 reportError (tok, Severity::style, " exceptRethrowCopy" ,
189192 " Throwing a copy of the caught exception instead of rethrowing the original exception.\n "
190193 " Rethrowing an exception with 'throw " + varname + " ;' creates an unnecessary copy of '" + varname + " '. "
@@ -213,7 +216,8 @@ void CheckExceptionSafety::checkCatchExceptionByValue()
213216 }
214217}
215218
216- void CheckExceptionSafety::catchExceptionByValueError (const Token *tok) {
219+ void CheckExceptionSafety::catchExceptionByValueError (const Token *tok)
220+ {
217221 reportError (tok, Severity::style,
218222 " catchExceptionByValue" , " Exception should be caught by reference.\n "
219223 " The exception is caught by value. It could be caught "
@@ -298,7 +302,8 @@ void CheckExceptionSafety::nothrowThrows()
298302 }
299303}
300304
301- void CheckExceptionSafety::noexceptThrowError (const Token * const tok) {
305+ void CheckExceptionSafety::noexceptThrowError (const Token * const tok)
306+ {
302307 reportError (tok, Severity::error, " throwInNoexceptFunction" , " Exception thrown in function declared not to throw exceptions." , CWE398 , Certainty::normal);
303308}
304309
@@ -334,7 +339,8 @@ void CheckExceptionSafety::unhandledExceptionSpecification()
334339 }
335340}
336341
337- void CheckExceptionSafety::unhandledExceptionSpecificationError (const Token * const tok1, const Token * const tok2, const std::string & funcname) {
342+ void CheckExceptionSafety::unhandledExceptionSpecificationError (const Token * const tok1, const Token * const tok2, const std::string & funcname)
343+ {
338344 const std::string str1 (tok1 ? tok1->str () : " foo" );
339345 const std::list<const Token*> locationList = { tok1, tok2 };
340346 reportError (locationList, Severity::style, " unhandledExceptionSpecification" ,
@@ -357,11 +363,11 @@ void CheckExceptionSafety::rethrowNoCurrentException()
357363 // Rethrow can be used in 'exception dispatcher' idiom which is FP in such case
358364 // https://isocpp.org/wiki/faq/exceptions#throw-without-an-object
359365 // We check the beggining of the function with idiom pattern
360- if (Token::simpleMatch (function->functionScope ->bodyStart ->next (), " try { throw ; } catch (" ))
366+ if (Token::simpleMatch (function->functionScope ->bodyStart ->next (), " try { throw ; } catch (" ))
361367 continue ;
362368
363369 for (const Token *tok = function->functionScope ->bodyStart ->next ();
364- tok != function->functionScope ->bodyEnd ; tok = tok->next ()) {
370+ tok != function->functionScope ->bodyEnd ; tok = tok->next ()) {
365371 if (Token::simpleMatch (tok, " catch (" )) {
366372 tok = tok->linkAt (1 ); // skip catch argument
367373 if (Token::simpleMatch (tok, " ) {" ))
@@ -376,7 +382,8 @@ void CheckExceptionSafety::rethrowNoCurrentException()
376382 }
377383}
378384
379- void CheckExceptionSafety::rethrowNoCurrentExceptionError (const Token *tok) {
385+ void CheckExceptionSafety::rethrowNoCurrentExceptionError (const Token *tok)
386+ {
380387 reportError (tok, Severity::error, " rethrowNoCurrentException" ,
381388 " Rethrowing current exception with 'throw;', it seems there is no current exception to rethrow."
382389 " If there is no current exception this calls std::terminate()."
0 commit comments