clang-tools 22.0.0git
|
Bundle the gathered information about an entity like a function regarding it's exception behaviour. More...
#include <ExceptionAnalyzer.h>
Classes | |
struct | ThrowInfo |
Holds information about where an exception is thrown. More... |
Public Types | |
using | Throwables = llvm::SmallDenseMap<const Type *, ThrowInfo, 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, const ThrowInfo &ThrowInfo) |
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. | |
Throwables | 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 & | getExceptions () const |
References the set of known exceptions 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 43 of file ExceptionAnalyzer.h.
using clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::Throwables = llvm::SmallDenseMap<const Type *, ThrowInfo, 2> |
Definition at line 52 of file ExceptionAnalyzer.h.
|
inline |
By default the exception situation is unknown and must be clarified step-wise.
Definition at line 59 of file ExceptionAnalyzer.h.
References clang::tidy::utils::ExceptionAnalyzer::NotThrowing.
Referenced by createNonThrowing(), createUnknown(), ExceptionInfo(), ExceptionInfo(), operator=(), and operator=().
|
inline |
Definition at line 60 of file ExceptionAnalyzer.h.
References clang::tidy::utils::ExceptionAnalyzer::Unknown.
|
default |
References ExceptionInfo().
|
default |
References ExceptionInfo().
void clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::clear | ( | ) |
Clear the state to 'NonThrowing' to make the corresponding entity neutral.
Definition at line 452 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 112 of file ExceptionAnalyzer.h.
|
inlinestatic |
Definition at line 55 of file ExceptionAnalyzer.h.
References ExceptionInfo(), and clang::tidy::utils::ExceptionAnalyzer::Throwing.
|
inlinestatic |
Definition at line 54 of file ExceptionAnalyzer.h.
References ExceptionInfo(), and clang::tidy::utils::ExceptionAnalyzer::Unknown.
ExceptionAnalyzer::ExceptionInfo::Throwables 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 filtered exceptions.
Definition at line 360 of file ExceptionAnalyzer.cpp.
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 429 of file ExceptionAnalyzer.cpp.
|
inline |
Definition at line 68 of file ExceptionAnalyzer.h.
|
inline |
References the set of known exceptions that can escape from the corresponding entity.
Definition at line 106 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 |
References ExceptionInfo().
|
default |
References ExceptionInfo().
void clang::tidy::utils::ExceptionAnalyzer::ExceptionInfo::registerException | ( | const Type * | ExceptionType, |
const ThrowInfo & | ThrowInfo ) |
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.