14#ifndef LLVM_CLANG_AST_GLOBALDECL_H
15#define LLVM_CLANG_AST_GLOBALDECL_H
24#include "llvm/ADT/DenseMapInfo.h"
25#include "llvm/ADT/PointerIntPair.h"
26#include "llvm/Support/Casting.h"
27#include "llvm/Support/type_traits.h"
57 llvm::PointerIntPair<const Decl *, 3>
Value;
58 unsigned MultiVersionIndex = 0;
61 assert(!isa<CXXConstructorDecl>(
D) &&
"Use other ctor with ctor decls!");
62 assert(!isa<CXXDestructorDecl>(
D) &&
"Use other ctor with dtor decls!");
63 assert(!
D->hasAttr<CUDAGlobalAttr>() &&
"Use other ctor with GPU kernels!");
72 : MultiVersionIndex(MVIndex) {
73 if (!
D->hasAttr<CUDAGlobalAttr>()) {
81 assert(
D->hasAttr<CUDAGlobalAttr>() &&
"Decl is not a GPU kernel!");
96 CanonGD.Value.setPointer(
Value.getPointer()->getCanonicalDecl());
97 CanonGD.Value.setInt(
Value.getInt());
98 CanonGD.MultiVersionIndex = MultiVersionIndex;
106 assert(isa<CXXConstructorDecl>(
getDecl()) &&
"Decl is not a ctor!");
111 assert(isa<CXXDestructorDecl>(
getDecl()) &&
"Decl is not a dtor!");
116 assert(isa<VarDecl>(
getDecl()) &&
117 cast<VarDecl>(
getDecl())->hasGlobalStorage() &&
118 "Decl is not a global variable!");
123 assert(isa<FunctionDecl>(
125 !cast<FunctionDecl>(
getDecl())->hasAttr<CUDAGlobalAttr>() &&
126 !isa<CXXConstructorDecl>(
getDecl()) &&
127 !isa<CXXDestructorDecl>(
getDecl()) &&
128 "Decl is not a plain FunctionDecl!");
129 return MultiVersionIndex;
133 assert(((isa<FunctionDecl>(
getDecl()) &&
134 cast<FunctionDecl>(
getDecl())->hasAttr<CUDAGlobalAttr>()) ||
135 (isa<FunctionTemplateDecl>(
getDecl()) &&
136 cast<FunctionTemplateDecl>(
getDecl())
138 ->hasAttr<CUDAGlobalAttr>())) &&
139 "Decl is not a GPU kernel!");
144 return LHS.Value == RHS.Value &&
145 LHS.MultiVersionIndex == RHS.MultiVersionIndex;
149 return !(*
this ==
Other);
158 GD.Value.setFromOpaqueValue(
P);
174 assert(isa<CXXConstructorDecl>(
getDecl()));
181 assert(isa<CXXDestructorDecl>(
getDecl()));
188 assert(isa<FunctionDecl>(
getDecl()) &&
189 !cast<FunctionDecl>(
getDecl())->hasAttr<CUDAGlobalAttr>() &&
190 !isa<CXXConstructorDecl>(
getDecl()) &&
191 !isa<CXXDestructorDecl>(
getDecl()) &&
192 "Decl is not a plain FunctionDecl!");
194 Result.MultiVersionIndex = Index;
199 assert(isa<FunctionDecl>(
getDecl()) &&