clang-tools 20.0.0git
|
Bundle the gathered information about an entity like a function regarding it's exception behaviour. More...
#include <ExceptionAnalyzer.h>
Public Types | |
using | Throwables = llvm::SmallSet< const Type *, 2 > |
Public Member Functions | |
ExceptionInfo () | |
By default the exception situation is unknown and must be clarified step-wise. | |
ExceptionInfo (State S) | |
ExceptionInfo (const ExceptionInfo &)=default | |
ExceptionInfo & | operator= (const ExceptionInfo &)=default |
ExceptionInfo (ExceptionInfo &&)=default | |
ExceptionInfo & | operator= (ExceptionInfo &&)=default |
State | getBehaviour () const |
void | registerException (const Type *ExceptionType) |
Register a single exception type as recognized potential exception to be thrown. | |
void | registerExceptions (const Throwables &Exceptions) |
Registers a SmallVector of exception types as recognized potential exceptions to be thrown. | |
ExceptionInfo & | merge (const ExceptionInfo &Other) |
Updates the local state according to the other state. | |
bool | filterByCatch (const Type *HandlerTy, const ASTContext &Context) |
This method is useful in case 'catch' clauses are analyzed as it is possible to catch multiple exception types by one 'catch' if they are a subclass of the 'catch'ed exception type. | |
ExceptionInfo & | filterIgnoredExceptions (const llvm::StringSet<> &IgnoredTypes, bool IgnoreBadAlloc) |
Filter the set of thrown exception type against a set of ignored types that shall not be considered in the exception analysis. | |
void | clear () |
Clear the state to 'NonThrowing' to make the corresponding entity neutral. | |
const Throwables & | getExceptionTypes () const |
References the set of known exception types that can escape from the corresponding entity. | |
bool | containsUnknownElements () const |
Signal if the there is any 'Unknown' element within the scope of the related entity. | |
Static Public Member Functions | |
static ExceptionInfo | createUnknown () |
static ExceptionInfo | createNonThrowing () |
Bundle the gathered information about an entity like a function regarding it's exception behaviour.
The 'NonThrowing'-state can be considered as the neutral element in terms of information propagation. In the case of 'Throwing' state it is possible that 'getExceptionTypes' does not include ALL possible types as there is the possibility that an 'Unknown' function is called that might throw a previously unknown exception at runtime.
Definition at line 38 of file ExceptionAnalyzer.h.
using clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::Throwables = llvm::SmallSet<const Type *, 2> |
Definition at line 40 of file ExceptionAnalyzer.h.
|
inline |
By default the exception situation is unknown and must be clarified step-wise.
Definition at line 46 of file ExceptionAnalyzer.h.
|
inline |
Definition at line 47 of file ExceptionAnalyzer.h.
|
default |
|
default |
void clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::clear | ( | ) |
Clear the state to 'NonThrowing' to make the corresponding entity neutral.
Definition at line 439 of file ExceptionAnalyzer.cpp.
References clang::tidy::utils::ExceptionAnalyzer::NotThrowing.
|
inline |
Signal if the there is any 'Unknown' element within the scope of the related entity.
This might be relevant if the entity is 'Throwing' and to ensure that no other exception then 'getExceptionTypes' can occur. If there is an 'Unknown' element this can not be guaranteed.
Definition at line 98 of file ExceptionAnalyzer.h.
|
inlinestatic |
Definition at line 42 of file ExceptionAnalyzer.h.
References clang::tidy::utils::ExceptionAnalyzer::Throwing.
|
inlinestatic |
Definition at line 41 of file ExceptionAnalyzer.h.
References clang::tidy::utils::ExceptionAnalyzer::Unknown.
bool clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::filterByCatch | ( | const Type * | HandlerTy, |
const ASTContext & | Context | ||
) |
This method is useful in case 'catch' clauses are analyzed as it is possible to catch multiple exception types by one 'catch' if they are a subclass of the 'catch'ed exception type.
Returns 'true' if some exceptions were filtered, otherwise 'false'.
Definition at line 356 of file ExceptionAnalyzer.cpp.
References Type.
ExceptionAnalyzer::ExceptionInfo & clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::filterIgnoredExceptions | ( | const llvm::StringSet<> & | IgnoredTypes, |
bool | IgnoreBadAlloc | ||
) |
Filter the set of thrown exception type against a set of ignored types that shall not be considered in the exception analysis.
This includes explicit std::bad_alloc
ignoring as separate option.
Definition at line 417 of file ExceptionAnalyzer.cpp.
References Type.
|
inline |
Definition at line 55 of file ExceptionAnalyzer.h.
|
inline |
References the set of known exception types that can escape from the corresponding entity.
Definition at line 92 of file ExceptionAnalyzer.h.
ExceptionAnalyzer::ExceptionInfo & clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::merge | ( | const ExceptionInfo & | Other | ) |
Updates the local state according to the other state.
That means if for example a function contains multiple statements the 'ExceptionInfo' for the final function is the merged result of each statement. If one of these statements throws the whole function throws and if one part is unknown and the rest is non-throwing the result will be unknown.
Definition at line 28 of file ExceptionAnalyzer.cpp.
References clang::tidy::utils::ExceptionAnalyzer::NotThrowing, clang::tidy::utils::ExceptionAnalyzer::Throwing, and clang::tidy::utils::ExceptionAnalyzer::Unknown.
|
default |
|
default |
void clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::registerException | ( | const Type * | ExceptionType | ) |
Register a single exception type as recognized potential exception to be thrown.
Definition at line 13 of file ExceptionAnalyzer.cpp.
References clang::tidy::utils::ExceptionAnalyzer::Throwing.
void clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::registerExceptions | ( | const Throwables & | Exceptions | ) |
Registers a SmallVector
of exception types as recognized potential exceptions to be thrown.
Definition at line 20 of file ExceptionAnalyzer.cpp.
References clang::tidy::utils::ExceptionAnalyzer::Throwing.