[AMDGPU][AsmParser][NFC] Translate parsed MIMG instructions to MCInsts automatically.
[llvm-project.git] / clang-tools-extra / clang-tidy / utils / ExceptionSpecAnalyzer.h
blob9c9782f7a38c6eb9d133153a1b7ce87ac03055f4
1 //===--- ExceptionSpecAnalyzer.h - clang-tidy -------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_EXCEPTION_SPEC_ANALYZER_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_EXCEPTION_SPEC_ANALYZER_H
12 #include "clang/AST/DeclCXX.h"
13 #include "llvm/ADT/DenseMap.h"
15 namespace clang::tidy::utils {
17 /// This class analysis if a `FunctionDecl` has been declared implicitly through
18 /// defaulting or explicitly as throwing or not and evaluates noexcept
19 /// expressions if needed. Unlike the `ExceptionAnalyzer` however it can't tell
20 /// you if the function will actually throw an exception or not.
21 class ExceptionSpecAnalyzer {
22 public:
23 enum class State {
24 Throwing, ///< This function has been declared as possibly throwing.
25 NotThrowing, ///< This function has been declared as not throwing.
26 Unknown, ///< We're unable to tell if this function is declared as throwing
27 ///< or not.
30 ExceptionSpecAnalyzer() = default;
32 State analyze(const FunctionDecl *FuncDecl);
34 private:
35 enum class DefaultableMemberKind {
36 DefaultConstructor,
37 CopyConstructor,
38 MoveConstructor,
39 CopyAssignment,
40 MoveAssignment,
41 Destructor,
43 CompareEqual,
44 CompareNotEqual,
45 CompareThreeWay,
46 CompareRelational,
48 None,
51 State analyzeImpl(const FunctionDecl *FuncDecl);
53 State analyzeUnresolvedOrDefaulted(const CXXMethodDecl *MethodDecl,
54 const FunctionProtoType *FuncProto);
56 State analyzeFieldDecl(const FieldDecl *FDecl, DefaultableMemberKind Kind);
58 State analyzeBase(const CXXBaseSpecifier &Base, DefaultableMemberKind Kind);
60 enum class SkipMethods : bool {
61 Yes = true,
62 No = false,
65 State analyzeRecord(const CXXRecordDecl *RecDecl, DefaultableMemberKind Kind,
66 SkipMethods SkipMethods = SkipMethods::No);
68 static State analyzeFunctionEST(const FunctionDecl *FuncDecl,
69 const FunctionProtoType *FuncProto);
71 static bool hasTrivialMemberKind(const CXXRecordDecl *RecDecl,
72 DefaultableMemberKind Kind);
74 static bool isConstructor(DefaultableMemberKind Kind);
76 static bool isSpecialMember(DefaultableMemberKind Kind);
78 static bool isComparison(DefaultableMemberKind Kind);
80 static DefaultableMemberKind
81 getDefaultableMemberKind(const FunctionDecl *FuncDecl);
83 llvm::DenseMap<const FunctionDecl *, State> FunctionCache{32u};
86 } // namespace clang::tidy::utils
88 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_UTILS_EXCEPTION_SPEC_ANALYZER_H