25#include "llvm/ADT/SmallVector.h"
34 if (
auto *A = D->
getAttr<AttrT>())
35 return !A->isImplicit();
40 assert(
getLangOpts().
CUDA &&
"Should only be called during CUDA compilation");
41 ForceHostDeviceDepth++;
45 assert(
getLangOpts().
CUDA &&
"Should only be called during CUDA compilation");
46 if (ForceHostDeviceDepth == 0)
48 ForceHostDeviceDepth--;
55 bool IsDeviceKernelCall =
false;
59 IsDeviceKernelCall =
true;
63 IsDeviceKernelCall =
true;
65 SemaRef.getCurFunctionDecl(
true);
71 IsDeviceKernelCall =
false;
75 IsDeviceKernelCall =
false;
85 Diag(LLLLoc, diag::err_cuda_device_kernel_launch_not_supported));
95 if (IsDeviceKernelCall) {
106 SemaRef.MarkFunctionReferenced(LLLLoc, ConfigDecl);
108 if (IsDeviceKernelCall) {
115 SemaRef.Context.IntTy, LLLLoc));
119 SemaRef.Context.IntTy, LLLLoc));
121 llvm::append_range(Args, ExecConfig);
123 if (Args.size() < 4) {
124 llvm::APInt One(
SemaRef.Context.getTypeSize(
SemaRef.Context.IntTy), 1);
126 SemaRef.Context.IntTy, LLLLoc));
131 SemaRef.Context.IntTy, LLLLoc));
135 SemaRef.Context.NullPtrTy, LLLLoc));
136 return SemaRef.BuildCallExpr(S, ConfigDR, LLLLoc, Args, GGGLoc,
nullptr,
139 return SemaRef.BuildCallExpr(S, ConfigDR, LLLLoc, ExecConfig, GGGLoc,
nullptr,
144 bool HasHostAttr =
false;
145 bool HasDeviceAttr =
false;
146 bool HasGlobalAttr =
false;
147 bool HasInvalidTargetAttr =
false;
149 switch (AL.getKind()) {
150 case ParsedAttr::AT_CUDAGlobal:
151 HasGlobalAttr =
true;
153 case ParsedAttr::AT_CUDAHost:
156 case ParsedAttr::AT_CUDADevice:
157 HasDeviceAttr =
true;
159 case ParsedAttr::AT_CUDAInvalidTarget:
160 HasInvalidTargetAttr =
true;
167 if (HasInvalidTargetAttr)
173 if (HasHostAttr && HasDeviceAttr)
185 return isa<A>(Attribute) &&
186 !(IgnoreImplicitAttr && Attribute->isImplicit());
195 auto *VD = dyn_cast_or_null<VarDecl>(D);
196 if (VD && VD->hasGlobalStorage() && !VD->isStaticLocal()) {
203 S.CurCUDATargetCtx = {
Target, K, VD};
209 bool IgnoreImplicitHDAttr) {
220 if (D->
hasAttr<CUDAInvalidTargetAttr>())
223 if (D->
hasAttr<CUDAGlobalAttr>())
236 !IgnoreImplicitHDAttr) {
247 if (Var->
hasAttr<HIPManagedAttr>())
253 Var->
hasAttr<CUDAConstantAttr>() &&
256 if (Var->
hasAttr<CUDADeviceAttr>() || Var->
hasAttr<CUDAConstantAttr>() ||
257 Var->
hasAttr<CUDASharedAttr>() ||
310 assert(Callee &&
"Callee must be valid.");
341 if (CalleeTarget == CallerTarget ||
385 llvm_unreachable(
"All cases should've been handled by now.");
391 if (
auto *A = D->
getAttr<AttrT>())
392 return A->isImplicit();
399 return IsImplicitDevAttr && IsImplicitHostAttr;
409 if (Matches.size() <= 1)
412 using Pair = std::pair<DeclAccessPair, FunctionDecl *>;
415 auto GetCFP = [&](
const Pair &
Match) {
421 GetCFP(*llvm::max_element(Matches, [&](
const Pair &M1,
const Pair &M2) {
422 return GetCFP(M1) < GetCFP(M2);
426 llvm::erase_if(Matches,
427 [&](
const Pair &
Match) {
return GetCFP(
Match) < BestCFP; });
447 *ResolvedTarget = Target2;
449 *ResolvedTarget = Target1;
450 }
else if (Target1 != Target2) {
453 *ResolvedTarget = Target1;
468 bool HasH = MemberDecl->
hasAttr<CUDAHostAttr>();
469 bool HasD = MemberDecl->
hasAttr<CUDADeviceAttr>();
470 bool HasExplicitAttr =
471 (HasD && !MemberDecl->
getAttr<CUDADeviceAttr>()->isImplicit()) ||
472 (HasH && !MemberDecl->
getAttr<CUDAHostAttr>()->isImplicit());
473 if (!InClass || HasExplicitAttr)
476 std::optional<CUDAFunctionTarget> InferredTarget;
488 for (
const auto &B : ClassDecl->
bases()) {
489 if (!B.isVirtual()) {
495 llvm::append_range(Bases, llvm::make_pointer_range(ClassDecl->
vbases()));
497 for (
const auto *B : Bases) {
498 auto *BaseClassDecl = B->getType()->getAsCXXRecordDecl();
503 SemaRef.LookupSpecialMember(BaseClassDecl, CSM,
515 if (!InferredTarget) {
516 InferredTarget = BaseMethodTarget;
519 *InferredTarget, BaseMethodTarget, &*InferredTarget);
520 if (ResolutionError) {
523 diag::note_implicit_member_target_infer_collision)
524 << (
unsigned)CSM << *InferredTarget << BaseMethodTarget;
534 for (
const auto *F : ClassDecl->
fields()) {
535 if (F->isInvalidDecl()) {
545 SemaRef.LookupSpecialMember(FieldRecDecl, CSM,
546 ConstRHS && !F->isMutable(),
557 if (!InferredTarget) {
558 InferredTarget = FieldMethodTarget;
561 *InferredTarget, FieldMethodTarget, &*InferredTarget);
562 if (ResolutionError) {
565 diag::note_implicit_member_target_infer_collision)
566 << (
unsigned)CSM << *InferredTarget << FieldMethodTarget;
577 bool NeedsH =
true, NeedsD =
true;
578 if (InferredTarget) {
623 if (const CXXConstructExpr *CE =
624 dyn_cast<CXXConstructExpr>(CI->getInit()))
625 return isEmptyConstructor(Loc, CE->getConstructor());
667 if (CXXRecordDecl *RD = BS.getType()->getAsCXXRecordDecl())
668 return isEmptyDestructor(Loc, RD->getDestructor());
675 if (CXXRecordDecl *RD = Field->getType()
676 ->getBaseElementTypeUnsafe()
677 ->getAsCXXRecordDecl())
678 return isEmptyDestructor(Loc, RD->getDestructor());
687enum CUDAInitializerCheckKind {
688 CICK_DeviceOrConstant,
692bool IsDependentVar(
VarDecl *VD) {
696 return Init->isValueDependent();
709bool HasAllowedCUDADeviceStaticInitializer(
SemaCUDA &S, VarDecl *VD,
710 CUDAInitializerCheckKind CheckKind) {
712 assert(!IsDependentVar(VD) &&
"do not check dependent var");
714 auto IsEmptyInit = [&](
const Expr *
Init) {
717 if (
const auto *CE = dyn_cast<CXXConstructExpr>(
Init)) {
722 auto IsConstantInit = [&](
const Expr *
Init) {
724 ASTContext::CUDAConstantEvalContextRAII EvalCtx(S.
getASTContext(),
729 auto HasEmptyDtor = [&](VarDecl *VD) {
734 if (CheckKind == CICK_Shared)
735 return IsEmptyInit(
Init) && HasEmptyDtor(VD);
737 ((IsEmptyInit(
Init) || IsConstantInit(
Init)) && HasEmptyDtor(VD));
749 bool IsSharedVar = VD->
hasAttr<CUDASharedAttr>();
750 bool IsDeviceOrConstantVar =
752 (VD->
hasAttr<CUDADeviceAttr>() || VD->
hasAttr<CUDAConstantAttr>());
753 if ((IsSharedVar || IsDeviceOrConstantVar) &&
765 if (IsDeviceOrConstantVar || IsSharedVar) {
766 if (HasAllowedCUDADeviceStaticInitializer(
767 *
this, VD, IsSharedVar ? CICK_Shared : CICK_DeviceOrConstant))
770 IsSharedVar ? diag::err_shared_var_init : diag::err_dynamic_var_init)
771 <<
Init->getSourceRange();
778 InitFn = CE->getConstructor();
779 }
else if (
const CallExpr *CE = dyn_cast<CallExpr>(
Init)) {
780 InitFn = CE->getDirectCallee();
787 << InitFnTarget << InitFn;
788 Diag(InitFn->getLocation(), diag::note_previous_decl) << InitFn;
811 !
getASTContext().CUDAImplicitHostDeviceFunUsedByDevice.count(Caller))))
831 assert(
getLangOpts().
CUDA &&
"Should only be called during CUDA compilation");
833 if (ForceHostDeviceDepth > 0) {
834 if (!NewD->
hasAttr<CUDAHostAttr>())
836 if (!NewD->
hasAttr<CUDADeviceAttr>())
843 if (
getLangOpts().OffloadImplicitHostDeviceTemplates &&
844 !NewD->
hasAttr<CUDAHostAttr>() && !NewD->
hasAttr<CUDADeviceAttr>() &&
845 !NewD->
hasAttr<CUDAGlobalAttr>() &&
855 NewD->
hasAttr<CUDADeviceAttr>() || NewD->
hasAttr<CUDAGlobalAttr>())
860 auto IsMatchingDeviceFn = [&](
NamedDecl *D) {
862 D = Using->getTargetDecl();
864 return OldD && OldD->
hasAttr<CUDADeviceAttr>() &&
865 !OldD->
hasAttr<CUDAHostAttr>() &&
866 !
SemaRef.IsOverload(NewD, OldD,
870 auto It = llvm::find_if(
Previous, IsMatchingDeviceFn);
877 if (!
SemaRef.getSourceManager().isInSystemHeader(
Match->getLocation())) {
879 diag::err_cuda_unattributed_constexpr_cannot_overload_device)
882 diag::note_cuda_conflicting_device_function_declared_here);
898 !VD->
hasAttr<CUDASharedAttr>() &&
900 !IsDependentVar(VD) &&
902 HasAllowedCUDADeviceStaticInitializer(*
this, VD,
903 CICK_DeviceOrConstant))) {
910 assert(
getLangOpts().
CUDA &&
"Should only be called during CUDA compilation");
912 SemaRef.getCurFunctionDecl(
true);
913 SemaDiagnosticBuilder::Kind DiagKind = [&] {
915 return SemaDiagnosticBuilder::K_Nop;
919 return SemaDiagnosticBuilder::K_Immediate;
925 return SemaDiagnosticBuilder::K_Nop;
926 if (
SemaRef.IsLastErrorImmediate &&
928 return SemaDiagnosticBuilder::K_Immediate;
930 return SemaDiagnosticBuilder::K_Deferred;
931 return (
SemaRef.getEmissionStatus(CurFunContext) ==
933 ? SemaDiagnosticBuilder::K_ImmediateWithCallStack
934 : SemaDiagnosticBuilder::K_Deferred;
936 return SemaDiagnosticBuilder::K_Nop;
944 assert(
getLangOpts().
CUDA &&
"Should only be called during CUDA compilation");
946 SemaRef.getCurFunctionDecl(
true);
947 SemaDiagnosticBuilder::Kind DiagKind = [&] {
949 return SemaDiagnosticBuilder::K_Nop;
952 return SemaDiagnosticBuilder::K_Immediate;
958 return SemaDiagnosticBuilder::K_Nop;
959 if (
SemaRef.IsLastErrorImmediate &&
961 return SemaDiagnosticBuilder::K_Immediate;
962 return (
SemaRef.getEmissionStatus(CurFunContext) ==
964 ? SemaDiagnosticBuilder::K_ImmediateWithCallStack
965 : SemaDiagnosticBuilder::K_Deferred;
967 return SemaDiagnosticBuilder::K_Nop;
974 assert(
getLangOpts().
CUDA &&
"Should only be called during CUDA compilation");
975 assert(Callee &&
"Callee may not be null.");
977 const auto &ExprEvalCtx =
SemaRef.currentEvaluationContext();
978 if (ExprEvalCtx.isUnevaluated() || ExprEvalCtx.isConstantEvaluated() ||
979 ExprEvalCtx.isDiscardedStatementContext())
996 bool CallerKnownEmitted =
SemaRef.getEmissionStatus(Caller) ==
998 bool CallerIsImplicitHDExplicitInst =
1000 SemaDiagnosticBuilder::Kind DiagKind = [
this, Caller, Callee,
1002 CallerIsImplicitHDExplicitInst] {
1006 assert(Caller &&
"Never/wrongSide calls require a non-null caller");
1010 return (CallerKnownEmitted && !CallerIsImplicitHDExplicitInst)
1011 ? SemaDiagnosticBuilder::K_ImmediateWithCallStack
1012 : SemaDiagnosticBuilder::K_Deferred;
1014 return SemaDiagnosticBuilder::K_Nop;
1019 bool CallerHD = Caller && Caller->
hasAttr<CUDAHostAttr>() &&
1020 Caller->
hasAttr<CUDADeviceAttr>();
1021 bool CallerDiscard =
SemaRef.getEmissionStatus(Caller) ==
1023 bool RDC =
getLangOpts().GPURelocatableDeviceCode;
1024 if (IsDeviceKernelCall && !(CallerHD && CallerDiscard) && !RDC) {
1025 Diag(Loc, diag::err_cuda_device_kernel_launch_require_rdc);
1029 if (DiagKind == SemaDiagnosticBuilder::K_Nop) {
1032 Callee->hasAttr<CUDAGlobalAttr>() && !Callee->isDefined() &&
1051 if (!Callee->getBuiltinID())
1053 diag::note_previous_decl, Caller,
SemaRef)
1055 return DiagKind != SemaDiagnosticBuilder::K_Immediate &&
1056 DiagKind != SemaDiagnosticBuilder::K_ImmediateWithCallStack;
1087 bool CalleeIsDevice = Callee->hasAttr<CUDADeviceAttr>();
1089 !Caller->
hasAttr<CUDAGlobalAttr>() && !Caller->
hasAttr<CUDADeviceAttr>();
1090 bool ShouldCheck = CalleeIsDevice && CallerIsHost;
1093 auto DiagKind = SemaDiagnosticBuilder::K_Deferred;
1096 diag::err_capture_bad_target, Callee,
SemaRef)
1104 diag::warn_maybe_capture_bad_target_this_ptr, Callee,
1110 assert(
getLangOpts().
CUDA &&
"Should only be called during CUDA compilation");
1111 if (
Method->hasAttr<CUDAHostAttr>() ||
Method->hasAttr<CUDADeviceAttr>())
1119 assert(
getLangOpts().
CUDA &&
"Should only be called during CUDA compilation");
1132 if (NewTarget != OldTarget &&
1133 !
SemaRef.IsOverload(NewFD, OldFD,
false,
1136 !(
getLangOpts().OffloadImplicitHostDeviceTemplates &&
1140 !(
getLangOpts().OffloadImplicitHostDeviceTemplates &&
1146 << NewTarget << NewFD->
getDeclName() << OldTarget << OldFD;
1147 Diag(OldFD->getLocation(), diag::note_previous_declaration);
1156 << NewTarget << OldTarget;
1163template <
typename AttrTy>
1166 if (AttrTy *Attribute = TemplateFD.
getAttr<AttrTy>()) {
1167 AttrTy *Clone = Attribute->clone(S.
Context);
1168 Clone->setInherited(
true);
1183 return "__llvmPushCallConfiguration";
1186 return getLangOpts().HIPUseNewLaunchAPI ?
"__hipPushCallConfiguration"
1187 :
"hipConfigureCall";
1192 return "__cudaPushCallConfiguration";
1195 return "cudaConfigureCall";
1199 return "cudaGetParameterBuffer";
1203 return "cudaLaunchDevice";
1214 for (
unsigned I = 0; I < Arguments.size(); ++I) {
1215 auto *DeclRef = dyn_cast<DeclRefExpr>(Arguments[I]);
1218 auto *Variable = dyn_cast<VarDecl>(DeclRef->getDecl());
1219 if (!Variable || !Variable->isLocalVarDecl() || !Variable->isConstexpr())
1222 bool HostByValue =
false, HostByRef =
false;
1223 bool DeviceByValue =
false, DeviceByRef =
false;
1227 if (!Callee || I >= Callee->getNumParams())
1240 bool IsRef = Callee->getParamDecl(I)->getType()->isReferenceType();
1241 HostByValue |= CoversHost && !IsRef;
1242 HostByRef |= CoversHost && IsRef;
1243 DeviceByValue |= CoversDevice && !IsRef;
1244 DeviceByRef |= CoversDevice && IsRef;
1247 if ((HostByValue && DeviceByRef) || (HostByRef && DeviceByValue))
Defines the clang::ASTContext interface.
static bool hasImplicitAttr(const ValueDecl *decl)
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines the clang::Preprocessor interface.
static bool resolveCalleeCUDATargetConflict(CUDAFunctionTarget Target1, CUDAFunctionTarget Target2, CUDAFunctionTarget *ResolvedTarget)
When an implicitly-declared special member has to invoke more than one base/field special member,...
static bool hasAttr(const Decl *D, bool IgnoreImplicitAttr)
static void copyAttrIfPresent(Sema &S, FunctionDecl *FD, const FunctionDecl &TemplateFD)
static bool hasExplicitAttr(const VarDecl *D)
This file declares semantic analysis for CUDA constructs.
FunctionDecl * getcudaGetParameterBufferDecl()
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
llvm::SetVector< const ValueDecl * > CUDAExternalDeviceDeclODRUsedByHost
Keep track of CUDA/HIP external kernels or device variables ODR-used by host code.
llvm::DenseSet< const FunctionDecl * > CUDAImplicitHostDeviceFunUsedByDevice
Keep track of CUDA/HIP implicit host device functions used on device side in device compilation.
FunctionDecl * getcudaConfigureCallDecl()
FunctionDecl * getcudaLaunchDeviceDecl()
Attr - This represents one attribute.
Represents a base class of a C++ class.
Represents a call to a C++ constructor.
Represents a C++ constructor within a class.
Represents a C++ base or member initializer.
Represents a C++ destructor within a class.
Represents a static or instance method of a struct/union/class.
const CXXRecordDecl * getParent() const
Return the parent of this method declaration, which is the class in which this method is defined.
The null pointer literal (C++11 [lex.nullptr])
Represents a C++ struct/union/class.
base_class_range vbases()
bool isAbstract() const
Determine whether this class has a pure virtual function.
bool isDynamicClass() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
A reference to a declared variable, function, enum, etc.
Decl - This represents one declaration (or definition), e.g.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
bool isInvalidDecl() const
SourceLocation getLocation() const
DeclContext * getDeclContext()
This represents one expression.
Represents a member of a struct/union/class.
Represents a function declaration or definition.
bool hasTrivialBody() const
Returns whether the function has a trivial body that does not require any specific codegen.
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
bool isVariadic() const
Whether this function is variadic.
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration.
bool isImplicitHDExplicitInstantiation() const
True if both host and device are implicit attributes and this is (or is a member of) an explicit temp...
unsigned getNumParams() const
Return the number of parameters this function must have based on its FunctionType.
bool isDefined(const FunctionDecl *&Definition, bool CheckForPendingFriendDefinition=false) const
Returns true if the function has a definition that does not need to be instantiated.
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Represents the results of name lookup.
This represents a decl that may have a name.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13....
ParsedAttr - Represents a syntactic attribute.
A (possibly-)qualified type.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isConstQualified() const
Determine whether this type is const-qualified.
LangAS getAddressSpace() const
field_range fields() const
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
Scope - A scope is a transient data structure that is used while parsing the program.
A generic diagnostic builder for errors which may or may not be deferred.
ASTContext & getASTContext() const
const LangOptions & getLangOpts() const
DiagnosticsEngine & getDiagnostics() const
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
std::string getLaunchDeviceFuncName() const
Return the name of the device kernel launch function.
void PushForceHostDevice()
Increments our count of the number of times we've seen a pragma forcing functions to be host device.
void checkAllowedInitializer(VarDecl *VD)
void RecordImplicitHostDeviceFuncUsedByDevice(const FunctionDecl *FD)
Record FD if it is a CUDA/HIP implicit host device function used on device side in device compilation...
std::string getConfigureFuncName() const
Returns the name of the launch configuration function.
bool PopForceHostDevice()
Decrements our count of the number of times we've seen a pragma forcing functions to be host device.
CUDAFunctionTarget IdentifyTarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
static bool isImplicitHDExplicitInstantiation(const FunctionDecl *FD)
Null-tolerant wrapper for FunctionDecl::isImplicitHDExplicitInstantiation.
void maybeAddHostDeviceAttrs(FunctionDecl *FD, const LookupResult &Previous)
May add implicit CUDAHostAttr and CUDADeviceAttr attributes to FD, depending on FD and the current co...
ExprResult ActOnExecConfigExpr(Scope *S, SourceLocation LLLLoc, MultiExprArg ExecConfig, SourceLocation GGGLoc)
bool isEmptyConstructor(SourceLocation Loc, CXXConstructorDecl *CD)
std::string getGetParameterBufferFuncName() const
Return the name of the parameter buffer allocation function for the device kernel launch.
bool isEmptyDestructor(SourceLocation Loc, CXXDestructorDecl *CD)
void checkTargetOverload(FunctionDecl *NewFD, const LookupResult &Previous)
Check whether NewFD is a valid overload for CUDA.
CUDAFunctionTarget CurrentTarget()
Gets the CUDA target for the current context.
SemaDiagnosticBuilder DiagIfHostCode(SourceLocation Loc, unsigned DiagID)
Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as host cod...
bool inferTargetForImplicitSpecialMember(CXXRecordDecl *ClassDecl, CXXSpecialMemberKind CSM, CXXMethodDecl *MemberDecl, bool ConstRHS, bool Diagnose)
Given a implicit special member, infer its CUDA target from the calls it needs to make to underlying ...
struct clang::SemaCUDA::CUDATargetContext CurCUDATargetCtx
CUDATargetContextKind
Defines kinds of CUDA global host/device context where a function may be called.
@ CTCK_InitGlobalVar
Unknown context.
SemaDiagnosticBuilder DiagIfDeviceCode(SourceLocation Loc, unsigned DiagID)
Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as device c...
llvm::DenseSet< FunctionDeclAndLoc > LocsWithCUDACallDiags
FunctionDecls and SourceLocations for which CheckCall has emitted a (maybe deferred) "bad call" diagn...
bool CheckCall(SourceLocation Loc, FunctionDecl *Callee)
Check whether we're allowed to call Callee from the current context.
void inheritTargetAttrs(FunctionDecl *FD, const FunctionTemplateDecl &TD)
Copies target attributes from the template TD to the function FD.
static bool isImplicitHostDeviceFunction(const FunctionDecl *D)
void CheckLambdaCapture(CXXMethodDecl *D, const sema::Capture &Capture)
void MaybeAddConstantAttr(VarDecl *VD)
May add implicit CUDAConstantAttr attribute to VD, depending on VD and current compilation settings.
void EraseUnwantedMatches(const FunctionDecl *Caller, llvm::SmallVectorImpl< std::pair< DeclAccessPair, FunctionDecl * > > &Matches)
Finds a function in Matches with highest calling priority from Caller context and erases all function...
void SetLambdaAttrs(CXXMethodDecl *Method)
Set device or host device attributes on the given lambda operator() method.
CUDAFunctionPreference IdentifyPreference(const FunctionDecl *Caller, const FunctionDecl *Callee)
Identifies relative preference of a given Caller/Callee combination, based on their host/device attri...
void recordPotentialODRUsedVariable(MultiExprArg Args, OverloadCandidateSet &CandidateSet)
Record variables that are potentially ODR-used in CUDA/HIP.
@ CVT_Host
Emitted on device side with a shadow variable on host side.
@ CVT_Both
Emitted on host side only.
@ CVT_Unified
Emitted on both sides with different addresses.
SpecialMemberOverloadResult - The overloading result for a special member function.
CXXMethodDecl * getMethod() const
Sema - This implements semantic analysis and AST building for C.
Encodes a location in the source.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isReferenceType() const
bool isCUDADeviceBuiltinSurfaceType() const
Check if the type is the CUDA device builtin surface type.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isCUDADeviceBuiltinTextureType() const
Check if the type is the CUDA device builtin texture type.
Represents a shadow declaration implicitly introduced into a scope by a (resolved) using-declaration ...
Represents a variable declaration or definition.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
bool isStaticDataMember() const
Determines whether this is a static data member.
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
bool isFileVarDecl() const
Returns true for file scoped variable declaration.
const Expr * getInit() const
ValueDecl * getVariable() const
bool isVariableCapture() const
SourceLocation getLocation() const
Retrieve the location at which this variable was captured.
bool isThisCapture() const
bool isReferenceCapture() const
llvm::SmallPtrSet< VarDecl *, 4 > CUDAPotentialODRUsedVars
Variables that are potentially ODR-used in CUDA/HIP.
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
@ Match
This is not an overload because the signature exactly matches an existing declaration.
bool isa(CodeGen::Address addr)
MutableArrayRef< Expr * > MultiExprArg
bool CudaFeatureEnabled(llvm::VersionTuple, CudaFeature)
CXXSpecialMemberKind
Kinds of C++ special members.
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
ActionResult< Expr * > ExprResult
OverloadCandidate - A single candidate in an overload set (C++ 13.3).