| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | #ifndef LLVM_CLANG_AST_GLOBALDECL_H |
| 15 | #define LLVM_CLANG_AST_GLOBALDECL_H |
| 16 | |
| 17 | #include "clang/AST/DeclCXX.h" |
| 18 | #include "clang/AST/DeclObjC.h" |
| 19 | #include "clang/AST/DeclOpenMP.h" |
| 20 | #include "clang/Basic/ABI.h" |
| 21 | #include "clang/Basic/LLVM.h" |
| 22 | #include "llvm/ADT/DenseMapInfo.h" |
| 23 | #include "llvm/ADT/PointerIntPair.h" |
| 24 | #include "llvm/Support/Casting.h" |
| 25 | #include "llvm/Support/type_traits.h" |
| 26 | #include <cassert> |
| 27 | |
| 28 | namespace clang { |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | class GlobalDecl { |
| 35 | llvm::PointerIntPair<const Decl *, 2> Value; |
| 36 | unsigned MultiVersionIndex = 0; |
| 37 | |
| 38 | void Init(const Decl *D) { |
| 39 | (0) . __assert_fail ("!isa(D) && \"Use other ctor with ctor decls!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/GlobalDecl.h", 39, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!isa<CXXConstructorDecl>(D) && "Use other ctor with ctor decls!"); |
| 40 | (0) . __assert_fail ("!isa(D) && \"Use other ctor with dtor decls!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/GlobalDecl.h", 40, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(!isa<CXXDestructorDecl>(D) && "Use other ctor with dtor decls!"); |
| 41 | |
| 42 | Value.setPointer(D); |
| 43 | } |
| 44 | |
| 45 | public: |
| 46 | GlobalDecl() = default; |
| 47 | GlobalDecl(const VarDecl *D) { Init(D);} |
| 48 | GlobalDecl(const FunctionDecl *D, unsigned MVIndex = 0) |
| 49 | : MultiVersionIndex(MVIndex) { |
| 50 | Init(D); |
| 51 | } |
| 52 | GlobalDecl(const BlockDecl *D) { Init(D); } |
| 53 | GlobalDecl(const CapturedDecl *D) { Init(D); } |
| 54 | GlobalDecl(const ObjCMethodDecl *D) { Init(D); } |
| 55 | GlobalDecl(const OMPDeclareReductionDecl *D) { Init(D); } |
| 56 | GlobalDecl(const CXXConstructorDecl *D, CXXCtorType Type) : Value(D, Type) {} |
| 57 | GlobalDecl(const CXXDestructorDecl *D, CXXDtorType Type) : Value(D, Type) {} |
| 58 | |
| 59 | GlobalDecl getCanonicalDecl() const { |
| 60 | GlobalDecl CanonGD; |
| 61 | CanonGD.Value.setPointer(Value.getPointer()->getCanonicalDecl()); |
| 62 | CanonGD.Value.setInt(Value.getInt()); |
| 63 | CanonGD.MultiVersionIndex = MultiVersionIndex; |
| 64 | |
| 65 | return CanonGD; |
| 66 | } |
| 67 | |
| 68 | const Decl *getDecl() const { return Value.getPointer(); } |
| 69 | |
| 70 | CXXCtorType getCtorType() const { |
| 71 | (0) . __assert_fail ("isa(getDecl()) && \"Decl is not a ctor!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/GlobalDecl.h", 71, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isa<CXXConstructorDecl>(getDecl()) && "Decl is not a ctor!"); |
| 72 | return static_cast<CXXCtorType>(Value.getInt()); |
| 73 | } |
| 74 | |
| 75 | CXXDtorType getDtorType() const { |
| 76 | (0) . __assert_fail ("isa(getDecl()) && \"Decl is not a dtor!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/GlobalDecl.h", 76, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isa<CXXDestructorDecl>(getDecl()) && "Decl is not a dtor!"); |
| 77 | return static_cast<CXXDtorType>(Value.getInt()); |
| 78 | } |
| 79 | |
| 80 | unsigned getMultiVersionIndex() const { |
| 81 | (0) . __assert_fail ("isa(getDecl()) && !isa(getDecl()) && !isa(getDecl()) && \"Decl is not a plain FunctionDecl!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/GlobalDecl.h", 84, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isa<FunctionDecl>(getDecl()) && |
| 82 | (0) . __assert_fail ("isa(getDecl()) && !isa(getDecl()) && !isa(getDecl()) && \"Decl is not a plain FunctionDecl!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/GlobalDecl.h", 84, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> !isa<CXXConstructorDecl>(getDecl()) && |
| 83 | (0) . __assert_fail ("isa(getDecl()) && !isa(getDecl()) && !isa(getDecl()) && \"Decl is not a plain FunctionDecl!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/GlobalDecl.h", 84, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> !isa<CXXDestructorDecl>(getDecl()) && |
| 84 | (0) . __assert_fail ("isa(getDecl()) && !isa(getDecl()) && !isa(getDecl()) && \"Decl is not a plain FunctionDecl!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/GlobalDecl.h", 84, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "Decl is not a plain FunctionDecl!"); |
| 85 | return MultiVersionIndex; |
| 86 | } |
| 87 | |
| 88 | friend bool operator==(const GlobalDecl &LHS, const GlobalDecl &RHS) { |
| 89 | return LHS.Value == RHS.Value && |
| 90 | LHS.MultiVersionIndex == RHS.MultiVersionIndex; |
| 91 | } |
| 92 | |
| 93 | void *getAsOpaquePtr() const { return Value.getOpaqueValue(); } |
| 94 | |
| 95 | static GlobalDecl getFromOpaquePtr(void *P) { |
| 96 | GlobalDecl GD; |
| 97 | GD.Value.setFromOpaqueValue(P); |
| 98 | return GD; |
| 99 | } |
| 100 | |
| 101 | GlobalDecl getWithDecl(const Decl *D) { |
| 102 | GlobalDecl Result(*this); |
| 103 | Result.Value.setPointer(D); |
| 104 | return Result; |
| 105 | } |
| 106 | |
| 107 | GlobalDecl getWithCtorType(CXXCtorType Type) { |
| 108 | (getDecl())", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/GlobalDecl.h", 108, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isa<CXXConstructorDecl>(getDecl())); |
| 109 | GlobalDecl Result(*this); |
| 110 | Result.Value.setInt(Type); |
| 111 | return Result; |
| 112 | } |
| 113 | |
| 114 | GlobalDecl getWithDtorType(CXXDtorType Type) { |
| 115 | (getDecl())", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/GlobalDecl.h", 115, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isa<CXXDestructorDecl>(getDecl())); |
| 116 | GlobalDecl Result(*this); |
| 117 | Result.Value.setInt(Type); |
| 118 | return Result; |
| 119 | } |
| 120 | |
| 121 | GlobalDecl getWithMultiVersionIndex(unsigned Index) { |
| 122 | (0) . __assert_fail ("isa(getDecl()) && !isa(getDecl()) && !isa(getDecl()) && \"Decl is not a plain FunctionDecl!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/GlobalDecl.h", 125, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true">assert(isa<FunctionDecl>(getDecl()) && |
| 123 | (0) . __assert_fail ("isa(getDecl()) && !isa(getDecl()) && !isa(getDecl()) && \"Decl is not a plain FunctionDecl!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/GlobalDecl.h", 125, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> !isa<CXXConstructorDecl>(getDecl()) && |
| 124 | (0) . __assert_fail ("isa(getDecl()) && !isa(getDecl()) && !isa(getDecl()) && \"Decl is not a plain FunctionDecl!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/GlobalDecl.h", 125, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> !isa<CXXDestructorDecl>(getDecl()) && |
| 125 | (0) . __assert_fail ("isa(getDecl()) && !isa(getDecl()) && !isa(getDecl()) && \"Decl is not a plain FunctionDecl!\"", "/home/seafit/code_projects/clang_source/clang/include/clang/AST/GlobalDecl.h", 125, __PRETTY_FUNCTION__))" file_link="../../../../include/assert.h.html#88" macro="true"> "Decl is not a plain FunctionDecl!"); |
| 126 | GlobalDecl Result(*this); |
| 127 | Result.MultiVersionIndex = Index; |
| 128 | return Result; |
| 129 | } |
| 130 | }; |
| 131 | |
| 132 | } |
| 133 | |
| 134 | namespace llvm { |
| 135 | |
| 136 | template<> struct DenseMapInfo<clang::GlobalDecl> { |
| 137 | static inline clang::GlobalDecl getEmptyKey() { |
| 138 | return clang::GlobalDecl(); |
| 139 | } |
| 140 | |
| 141 | static inline clang::GlobalDecl getTombstoneKey() { |
| 142 | return clang::GlobalDecl:: |
| 143 | getFromOpaquePtr(reinterpret_cast<void*>(-1)); |
| 144 | } |
| 145 | |
| 146 | static unsigned getHashValue(clang::GlobalDecl GD) { |
| 147 | return DenseMapInfo<void*>::getHashValue(GD.getAsOpaquePtr()); |
| 148 | } |
| 149 | |
| 150 | static bool isEqual(clang::GlobalDecl LHS, |
| 151 | clang::GlobalDecl RHS) { |
| 152 | return LHS == RHS; |
| 153 | } |
| 154 | }; |
| 155 | |
| 156 | } |
| 157 | |
| 158 | #endif |
| 159 | |