20 #ifndef checkexceptionsafetyH
21 #define checkexceptionsafetyH
55 :
Check(myName(), tokenizer, settings, errorLogger) {}
78 void checkRethrowCopy();
81 void checkCatchExceptionByValue();
87 void unhandledExceptionSpecification();
90 void rethrowNoCurrentException();
93 void destructorsError(
const Token *
const tok,
const std::string &className);
94 void deallocThrowError(
const Token *
const tok,
const std::string &varname);
95 void rethrowCopyError(
const Token *
const tok,
const std::string &varname);
96 void catchExceptionByValueError(
const Token *tok);
97 void noexceptThrowError(
const Token *
const tok);
99 void unhandledExceptionSpecificationError(
const Token *
const tok1,
const Token *
const tok2,
const std::string & funcname);
101 void rethrowNoCurrentExceptionError(
const Token *tok);
117 return "Exception Safety";
122 return "Checking exception safety\n"
123 "- Throwing exceptions in destructors\n"
124 "- Throwing exception during invalid state\n"
125 "- Throwing a copy of a caught exception instead of rethrowing the original exception\n"
126 "- Exception caught by value instead of by reference\n"
127 "- Throwing exception in noexcept, nothrow(), __attribute__((nothrow)) or __declspec(nothrow) function\n"
128 "- Unhandled exception specification when calling function foo()\n"
129 "- Rethrow without currently handled exception\n";
Check exception safety (exceptions shouldn't cause leaks nor corrupt data)
void unhandledExceptionSpecification()
Check for unhandled exception specification
void destructors()
Don't throw exceptions in destructors.
static std::string myName()
Short description of class (for –doc)
void nothrowThrows()
Check for functions that throw that shouldn't
void deallocThrowError(const Token *const tok, const std::string &varname)
void rethrowCopyError(const Token *const tok, const std::string &varname)
void noexceptThrowError(const Token *const tok)
void getErrorMessages(ErrorLogger *errorLogger, const Settings *settings) const override
Generate all possible errors (for –errorlist)
void rethrowNoCurrentException()
Check for rethrow not from catch scope
void checkCatchExceptionByValue()
Check for exceptions that are caught by value instead of by reference
CheckExceptionSafety()
This constructor is used when registering the CheckClass.
void runChecks(const Tokenizer &tokenizer, ErrorLogger *errorLogger) override
run checks, the token list is not simplified
void catchExceptionByValueError(const Token *tok)
void deallocThrow()
deallocating memory and then throw (dead pointer)
std::string classInfo() const override
wiki formatted description of the class (for –doc)
void rethrowNoCurrentExceptionError(const Token *tok)
Rethrow without currently handled exception.
void checkRethrowCopy()
Don't rethrow a copy of the caught exception; use a bare throw instead.
void unhandledExceptionSpecificationError(const Token *const tok1, const Token *const tok2, const std::string &funcname)
Missing exception specification.
void destructorsError(const Token *const tok, const std::string &className)
Don't throw exceptions in destructors.
CheckExceptionSafety(const Tokenizer *tokenizer, const Settings *settings, ErrorLogger *errorLogger)
This constructor is used when running checks.
Interface class that cppcheck uses to communicate with the checks.
This is an interface, which the class responsible of error logging should implement.
This is just a container for general settings so that we don't need to pass individual values to func...
The token list that the TokenList generates is a linked-list of this class.
The main purpose is to tokenize the source code.
const Settings & getSettings() const
bool isC() const
Is the code C.