9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_EXCEPTION_ANALYZER_H 10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_EXCEPTION_ANALYZER_H 12 #include "clang/AST/ASTContext.h" 13 #include "clang/ASTMatchers/ASTMatchFinder.h" 14 #include "llvm/ADT/SmallSet.h" 15 #include "llvm/ADT/StringSet.h" 26 enum class State : std::int8_t {
65 void registerException(
const Type *ExceptionType);
69 void registerExceptions(
const Throwables &Exceptions);
83 bool filterByCatch(
const Type *BaseClass);
89 filterIgnoredExceptions(
const llvm::StringSet<> &IgnoredTypes,
108 void reevaluateBehaviour();
117 bool ContainsUnknown;
128 IgnoredExceptions = std::move(ExceptionNames);
136 throwsException(
const FunctionDecl *Func,
137 llvm::SmallSet<const FunctionDecl *, 32> &CallStack);
140 llvm::SmallSet<const FunctionDecl *, 32> &CallStack);
145 template <
typename T>
ExceptionInfo analyzeDispatch(
const T *Node);
147 bool IgnoreBadAlloc =
true;
148 llvm::StringSet<> IgnoredExceptions;
149 std::map<const FunctionDecl *, ExceptionInfo> FunctionCache;
156 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_EXCEPTION_ANALYZER_H llvm::SmallSet< const Type *, 2 > Throwables
Bundle the gathered information about an entity like a function regarding it's exception behaviour...
ExceptionInfo()
By default the exception situation is unknown and must be clarified step-wise.
static ExceptionInfo createNonThrowing()
State getBehaviour() const
This function can not throw, given an AST.
This can happen for extern functions without available definition.
const Throwables & getExceptionTypes() const
References the set of known exception types that can escape from the corresponding entity...
This class analysis if a FunctionDecl can in principle throw an exception, either directly or indirec...
The function can definitely throw given an AST.
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
ExceptionInfo analyze(const FunctionDecl *Func)
bool containsUnknownElements() const
Signal if the there is any 'Unknown' element within the scope of the related entity.
void ignoreBadAlloc(bool ShallIgnore)
static ExceptionInfo createUnknown()
ExceptionAnalyzer()=default
void ignoreExceptions(llvm::StringSet<> ExceptionNames)