File indexing completed on 2026-05-10 08:36:22
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_EXCEPTION_SPEC_ANALYZER_H
0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_EXCEPTION_SPEC_ANALYZER_H
0011
0012 #include "clang/AST/DeclCXX.h"
0013 #include "llvm/ADT/DenseMap.h"
0014
0015 namespace clang::tidy::utils {
0016
0017
0018
0019
0020
0021 class ExceptionSpecAnalyzer {
0022 public:
0023 enum class State {
0024 Throwing,
0025 NotThrowing,
0026 Unknown,
0027
0028 };
0029
0030 ExceptionSpecAnalyzer() = default;
0031
0032 State analyze(const FunctionDecl *FuncDecl);
0033
0034 private:
0035 enum class DefaultableMemberKind {
0036 DefaultConstructor,
0037 CopyConstructor,
0038 MoveConstructor,
0039 CopyAssignment,
0040 MoveAssignment,
0041 Destructor,
0042
0043 CompareEqual,
0044 CompareNotEqual,
0045 CompareThreeWay,
0046 CompareRelational,
0047
0048 None,
0049 };
0050
0051 State analyzeImpl(const FunctionDecl *FuncDecl);
0052
0053 State analyzeUnresolvedOrDefaulted(const CXXMethodDecl *MethodDecl,
0054 const FunctionProtoType *FuncProto);
0055
0056 State analyzeFieldDecl(const FieldDecl *FDecl, DefaultableMemberKind Kind);
0057
0058 State analyzeBase(const CXXBaseSpecifier &Base, DefaultableMemberKind Kind);
0059
0060 enum class SkipMethods : bool {
0061 Yes = true,
0062 No = false,
0063 };
0064
0065 State analyzeRecord(const CXXRecordDecl *RecordDecl,
0066 DefaultableMemberKind Kind,
0067 SkipMethods SkipMethods = SkipMethods::No);
0068
0069 static State analyzeFunctionEST(const FunctionDecl *FuncDecl,
0070 const FunctionProtoType *FuncProto);
0071
0072 static bool hasTrivialMemberKind(const CXXRecordDecl *RecDecl,
0073 DefaultableMemberKind Kind);
0074
0075 static bool isConstructor(DefaultableMemberKind Kind);
0076
0077 static bool isSpecialMember(DefaultableMemberKind Kind);
0078
0079 static bool isComparison(DefaultableMemberKind Kind);
0080
0081 static DefaultableMemberKind
0082 getDefaultableMemberKind(const FunctionDecl *FuncDecl);
0083
0084 llvm::DenseMap<const FunctionDecl *, State> FunctionCache{32U};
0085 };
0086
0087 }
0088
0089 #endif