Formatted the code [ci skip]
This commit is contained in:
parent
397806b419
commit
14ff646c92
|
@ -72,7 +72,8 @@ void CheckExceptionSafety::destructors()
|
|||
}
|
||||
}
|
||||
|
||||
void CheckExceptionSafety::destructorsError(const Token * const tok, const std::string &className) {
|
||||
void CheckExceptionSafety::destructorsError(const Token * const tok, const std::string &className)
|
||||
{
|
||||
reportError(tok, Severity::warning, "exceptThrowInDestructor",
|
||||
"Class " + className + " is not safe, destructor throws exception\n"
|
||||
"The class " + className + " is not safe because its destructor "
|
||||
|
@ -142,7 +143,8 @@ void CheckExceptionSafety::deallocThrow()
|
|||
}
|
||||
}
|
||||
|
||||
void CheckExceptionSafety::deallocThrowError(const Token * const tok, const std::string &varname) {
|
||||
void CheckExceptionSafety::deallocThrowError(const Token * const tok, const std::string &varname)
|
||||
{
|
||||
reportError(tok, Severity::warning, "exceptDeallocThrow", "Exception thrown in invalid state, '" +
|
||||
varname + "' points at deallocated memory.", CWE398, Certainty::normal);
|
||||
}
|
||||
|
@ -184,7 +186,8 @@ void CheckExceptionSafety::checkRethrowCopy()
|
|||
}
|
||||
}
|
||||
|
||||
void CheckExceptionSafety::rethrowCopyError(const Token * const tok, const std::string &varname) {
|
||||
void CheckExceptionSafety::rethrowCopyError(const Token * const tok, const std::string &varname)
|
||||
{
|
||||
reportError(tok, Severity::style, "exceptRethrowCopy",
|
||||
"Throwing a copy of the caught exception instead of rethrowing the original exception.\n"
|
||||
"Rethrowing an exception with 'throw " + varname + ";' creates an unnecessary copy of '" + varname + "'. "
|
||||
|
@ -213,7 +216,8 @@ void CheckExceptionSafety::checkCatchExceptionByValue()
|
|||
}
|
||||
}
|
||||
|
||||
void CheckExceptionSafety::catchExceptionByValueError(const Token *tok) {
|
||||
void CheckExceptionSafety::catchExceptionByValueError(const Token *tok)
|
||||
{
|
||||
reportError(tok, Severity::style,
|
||||
"catchExceptionByValue", "Exception should be caught by reference.\n"
|
||||
"The exception is caught by value. It could be caught "
|
||||
|
@ -298,7 +302,8 @@ void CheckExceptionSafety::nothrowThrows()
|
|||
}
|
||||
}
|
||||
|
||||
void CheckExceptionSafety::noexceptThrowError(const Token * const tok) {
|
||||
void CheckExceptionSafety::noexceptThrowError(const Token * const tok)
|
||||
{
|
||||
reportError(tok, Severity::error, "throwInNoexceptFunction", "Exception thrown in function declared not to throw exceptions.", CWE398, Certainty::normal);
|
||||
}
|
||||
|
||||
|
@ -334,7 +339,8 @@ void CheckExceptionSafety::unhandledExceptionSpecification()
|
|||
}
|
||||
}
|
||||
|
||||
void CheckExceptionSafety::unhandledExceptionSpecificationError(const Token * const tok1, const Token * const tok2, const std::string & funcname) {
|
||||
void CheckExceptionSafety::unhandledExceptionSpecificationError(const Token * const tok1, const Token * const tok2, const std::string & funcname)
|
||||
{
|
||||
const std::string str1(tok1 ? tok1->str() : "foo");
|
||||
const std::list<const Token*> locationList = { tok1, tok2 };
|
||||
reportError(locationList, Severity::style, "unhandledExceptionSpecification",
|
||||
|
@ -376,7 +382,8 @@ void CheckExceptionSafety::rethrowNoCurrentException()
|
|||
}
|
||||
}
|
||||
|
||||
void CheckExceptionSafety::rethrowNoCurrentExceptionError(const Token *tok) {
|
||||
void CheckExceptionSafety::rethrowNoCurrentExceptionError(const Token *tok)
|
||||
{
|
||||
reportError(tok, Severity::error, "rethrowNoCurrentException",
|
||||
"Rethrowing current exception with 'throw;', it seems there is no current exception to rethrow."
|
||||
" If there is no current exception this calls std::terminate()."
|
||||
|
|
Loading…
Reference in New Issue