#include "clang/Sema/SemaCUDA.h"
FD
if it is a CUDA/HIP implicit host device function used on device side in device compilation.
Matches
with highest calling priority from Caller
context and erases all functions with lower calling priority.
Definition at line 45 of file SemaCUDA.h.
◆ CUDAFunctionPreference Enumerator CFP_Never CFP_WrongSide CFP_HostDevice CFP_SameSide CFP_NativeDefinition at line 160 of file SemaCUDA.h.
◆ CUDATargetContextKindDefines kinds of CUDA global host/device context where a function may be called.
Enumerator CTCK_Unknown CTCK_InitGlobalVarUnknown context.
Definition at line 129 of file SemaCUDA.h.
◆ CUDAVariableTarget Enumerator CVT_Device CVT_HostEmitted on device side with a shadow variable on host side.
CVT_BothEmitted on host side only.
CVT_UnifiedEmitted on both sides with different addresses.
Definition at line 118 of file SemaCUDA.h.
◆ SemaCUDA() ◆ ActOnExecConfigExpr() ◆ checkAllowedInitializer() void SemaCUDA::checkAllowedInitializer ( VarDecl * VD )Definition at line 656 of file SemaCUDA.cpp.
References clang::SemaBase::Diag(), clang::Decl::getDeclContext(), clang::VarDecl::getInit(), clang::Decl::getLocation(), clang::Decl::hasAttr(), clang::VarDecl::hasGlobalStorage(), clang::VarDecl::hasInit(), clang::Host, clang::HostDevice, IdentifyTarget(), clang::Init, clang::DeclContext::isDependentContext(), clang::Decl::isInvalidDecl(), and clang::Decl::setInvalidDecl().
Referenced by clang::Sema::FinalizeDeclaration(), and clang::Sema::InstantiateVariableInitializer().
◆ CheckCall()Check whether we're allowed to call Callee from the current context.
If the call is allowed in semantically-correct programs, but only if it's never codegen'ed (CFP_WrongSide), creates a deferred diagnostic to be emitted if and when the caller is codegen'ed, and returns true.
Will only create deferred diagnostics for a given SourceLocation once, so you can safely call this multiple times without generating duplicate deferred errors.
Definition at line 880 of file SemaCUDA.cpp.
References CFP_Never, CFP_WrongSide, clang::CUDA, clang::ASTContext::CUDAExternalDeviceDeclODRUsedByHost, clang::Sema::currentEvaluationContext(), clang::Sema::Emitted, clang::SemaBase::getASTContext(), clang::Sema::getCurFunctionDecl(), clang::FunctionDecl::getDescribedFunctionTemplate(), clang::Sema::getEmissionStatus(), clang::ASTContext::GetGVALinkageForFunction(), clang::SemaBase::getLangOpts(), clang::GVA_StrongExternal, IdentifyPreference(), Loc, LocsWithCUDACallDiags, and clang::SemaBase::SemaRef.
Referenced by clang::Sema::MarkFunctionReferenced().
◆ CheckLambdaCapture() ◆ checkTargetOverload()Check whether NewFD is a valid overload for CUDA.
Emits diagnostics and invalidates NewFD if not.
Definition at line 1003 of file SemaCUDA.cpp.
References clang::CUDA, clang::Device, clang::SemaBase::Diag(), clang::Decl::getAsFunction(), clang::NamedDecl::getDeclName(), clang::SemaBase::getLangOpts(), clang::Decl::getLocation(), clang::Global, clang::Host, clang::HostDevice, IdentifyTarget(), isImplicitHostDeviceFunction(), clang::Sema::IsOverload(), Previous, clang::SemaBase::SemaRef, and clang::Decl::setInvalidDecl().
Referenced by clang::Sema::CheckFunctionDeclaration().
◆ CurrentTarget() ◆ DiagIfDeviceCode()Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as device code".
EmitOnBothSides
is true.Example usage:
// Variable-length arrays are not allowed in CUDA device code. if (DiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentTarget()) return ExprError(); // Otherwise, continue parsing as normal.
Definition at line 817 of file SemaCUDA.cpp.
References clang::CUDA, CurrentTarget(), clang::Device, clang::Sema::Emitted, clang::Sema::getCurFunctionDecl(), clang::SemaBase::getDiagnostics(), clang::Sema::getEmissionStatus(), clang::SemaBase::getLangOpts(), clang::Global, clang::HostDevice, clang::Sema::IsLastErrorImmediate, Loc, and clang::SemaBase::SemaRef.
Referenced by clang::Sema::ActOnCXXTryBlock(), clang::Sema::BuildCXXThrow(), and clang::SemaBase::Diag().
◆ DiagIfHostCode()Creates a SemaDiagnosticBuilder that emits the diagnostic if the current context is "used as host code".
Same as DiagIfDeviceCode, with "host" and "device" switched.
Definition at line 849 of file SemaCUDA.cpp.
References clang::CUDA, CurrentTarget(), clang::Sema::Emitted, clang::Sema::getCurFunctionDecl(), clang::SemaBase::getDiagnostics(), clang::Sema::getEmissionStatus(), clang::SemaBase::getLangOpts(), clang::Host, clang::HostDevice, clang::Sema::IsLastErrorImmediate, Loc, and clang::SemaBase::SemaRef.
Referenced by clang::SemaBase::Diag(), and handleSharedAttr().
◆ EraseUnwantedMatches() ◆ getConfigureFuncName() std::string SemaCUDA::getConfigureFuncName ( ) const ◆ IdentifyPreference()Identifies relative preference of a given Caller/Callee combination, based on their host/device attributes.
Callee
. nullptr in case of global context. Callee target function
Definition at line 225 of file SemaCUDA.cpp.
References CFP_HostDevice, CFP_Native, CFP_Never, CFP_SameSide, CFP_WrongSide, CTCK_InitGlobalVar, CurCUDATargetCtx, clang::Device, clang::SemaBase::getLangOpts(), clang::Global, clang::Host, clang::HostDevice, IdentifyTarget(), clang::InvalidTarget, clang::SemaCUDA::CUDATargetContext::Kind, and clang::SemaCUDA::CUDATargetContext::Target.
Referenced by clang::OverloadCandidateSet::BestViableFunction(), CheckCall(), EraseUnwantedMatches(), IsAllowedCall(), clang::isBetterOverloadCandidate(), and clang::Sema::isUsualDeallocationFunction().
◆ IdentifyTarget() [1/3]Determines whether the given function is a CUDA device/host/kernel/etc.
IdentifyTarget - Determine the CUDA compilation target for this function.
function.
Use this rather than examining the function's attributes yourself – you will get it wrong. Returns CUDAFunctionTarget::Host if D is null.
Definition at line 134 of file SemaCUDA.cpp.
References CurCUDATargetCtx, D, clang::Device, clang::Global, clang::Decl::hasAttr(), clang::Host, clang::HostDevice, clang::InvalidTarget, clang::Decl::isImplicit(), and clang::SemaCUDA::CUDATargetContext::Target.
Referenced by clang::Sema::ActOnExplicitInstantiation(), clang::Sema::BuildVAArgExpr(), checkAllowedInitializer(), clang::Sema::CheckCallingConvAttr(), clang::Sema::CheckFunctionTemplateSpecialization(), checkTargetOverload(), CurrentTarget(), DiagnoseBadTarget(), getCCForDeclaratorChunk(), GetDeclSpecTypeForDeclarator(), clang::Sema::getEmissionStatus(), GetFullTypeForDeclarator(), handleCallConvAttr(), IdentifyPreference(), IdentifyTarget(), inferTargetForImplicitSpecialMember(), IsOverloadOrOverrideImpl(), MarkVarDeclODRUsed(), RecordImplicitHostDeviceFuncUsedByDevice(), and clang::Sema::shouldIgnoreInHostDeviceCheck().
◆ IdentifyTarget() [2/3] ◆ IdentifyTarget() [3/3]Determines whether the given variable is emitted on host or device side.
IdentifyTarget - Determine the CUDA compilation target for this variable.
Definition at line 163 of file SemaCUDA.cpp.
References CVT_Both, CVT_Device, CVT_Host, CVT_Unified, clang::Device, clang::Decl::getDeclContext(), clang::ValueDecl::getType(), clang::Global, clang::Decl::hasAttr(), clang::HostDevice, IdentifyTarget(), clang::VarDecl::isConstexpr(), clang::QualType::isConstQualified(), clang::Type::isCUDADeviceBuiltinSurfaceType(), and clang::Type::isCUDADeviceBuiltinTextureType().
◆ inferTargetForImplicitSpecialMember()Given a implicit special member, infer its CUDA target from the calls it needs to make to underlying base/field special members.
Definition at line 370 of file SemaCUDA.cpp.
References clang::Decl::addAttr(), clang::CXXRecordDecl::bases(), clang::Device, clang::SemaBase::Diag(), clang::RecordDecl::fields(), clang::Type::getAs(), clang::SemaBase::getASTContext(), clang::Decl::getAttr(), clang::ASTContext::getBaseElementType(), clang::RecordType::getDecl(), clang::DeclContext::getLexicalParent(), clang::Decl::getLocation(), clang::Sema::SpecialMemberOverloadResult::getMethod(), clang::CXXMethodDecl::getParent(), clang::Decl::hasAttr(), clang::Host, IdentifyTarget(), clang::CXXRecordDecl::isAbstract(), clang::Sema::LookupSpecialMember(), resolveCalleeCUDATargetConflict(), clang::SemaBase::SemaRef, and clang::CXXRecordDecl::vbases().
Referenced by clang::Sema::DeclareImplicitCopyAssignment(), clang::Sema::DeclareImplicitCopyConstructor(), clang::Sema::DeclareImplicitDefaultConstructor(), clang::Sema::DeclareImplicitDestructor(), clang::Sema::DeclareImplicitMoveAssignment(), clang::Sema::DeclareImplicitMoveConstructor(), DiagnoseBadTarget(), and clang::Sema::ShouldDeleteSpecialMember().
◆ inheritTargetAttrs() ◆ IsAllowedCall()Determines whether Caller may invoke Callee, based on their CUDA host/device attributes.
Returns false if the call is not allowed.
Note: Will return true for CFP_WrongSide calls. These may appear in semantically correct CUDA programs, but only if they're never codegen'ed.
Definition at line 186 of file SemaCUDA.h.
References CFP_Never, and IdentifyPreference().
◆ isEmptyConstructor()CD
can be considered empty according to CUDA (E.2.3.1 in CUDA 7.5 Programming guide).
Definition at line 510 of file SemaCUDA.cpp.
References clang::Redeclarable< decl_type >::getFirstDecl(), clang::FunctionDecl::getNumParams(), clang::CXXMethodDecl::getParent(), clang::FunctionDecl::hasTrivialBody(), clang::CXXConstructorDecl::inits(), clang::Sema::InstantiateFunctionDefinition(), clang::FunctionDecl::isDefined(), clang::CXXRecordDecl::isDynamicClass(), clang::FunctionDecl::isTemplateInstantiation(), clang::FunctionDecl::isTrivial(), clang::TagDecl::isUnion(), Loc, and clang::SemaBase::SemaRef.
◆ isEmptyDestructor()Definition at line 548 of file SemaCUDA.cpp.
References clang::CXXRecordDecl::bases(), clang::RecordDecl::fields(), clang::Redeclarable< decl_type >::getFirstDecl(), clang::CXXMethodDecl::getParent(), clang::FunctionDecl::hasTrivialBody(), clang::Sema::InstantiateFunctionDefinition(), clang::FunctionDecl::isDefined(), clang::CXXRecordDecl::isDynamicClass(), clang::FunctionDecl::isTemplateInstantiation(), clang::FunctionDecl::isTrivial(), clang::TagDecl::isUnion(), Loc, and clang::SemaBase::SemaRef.
◆ isImplicitHostDeviceFunction() ◆ MaybeAddConstantAttr() void SemaCUDA::MaybeAddConstantAttr ( VarDecl * VD ) ◆ maybeAddHostDeviceAttrs()May add implicit CUDAHostAttr and CUDADeviceAttr attributes to FD, depending on FD and the current compilation settings.
Definition at line 738 of file SemaCUDA.cpp.
References clang::Decl::addAttr(), clang::CUDA, D, clang::SemaBase::Diag(), clang::Decl::getAsFunction(), clang::SemaBase::getASTContext(), clang::FunctionDecl::getDescribedFunctionTemplate(), clang::SemaBase::getLangOpts(), clang::Decl::getLocation(), clang::Sema::getSourceManager(), clang::Decl::hasAttr(), clang::FunctionDecl::isConstexpr(), clang::FunctionDecl::isFunctionTemplateSpecialization(), clang::SourceManager::isInSystemHeader(), clang::Sema::IsOverload(), clang::FunctionDecl::isVariadic(), Previous, and clang::SemaBase::SemaRef.
Referenced by clang::Sema::ActOnFunctionDeclarator().
◆ PopForceHostDevice() bool SemaCUDA::PopForceHostDevice ( )Decrements our count of the number of times we've seen a pragma forcing functions to be host device.
Returns false if the count is 0 before incrementing, so you can emit an error.
Definition at line 44 of file SemaCUDA.cpp.
References clang::CUDA, and clang::SemaBase::getLangOpts().
◆ PushForceHostDevice() void SemaCUDA::PushForceHostDevice ( )Increments our count of the number of times we've seen a pragma forcing functions to be host device.
So long as this count is greater than zero, all functions encountered will be host device.
Definition at line 39 of file SemaCUDA.cpp.
References clang::CUDA, and clang::SemaBase::getLangOpts().
◆ RecordImplicitHostDeviceFuncUsedByDevice() void SemaCUDA::RecordImplicitHostDeviceFuncUsedByDevice ( const FunctionDecl * FD ) ◆ SetLambdaAttrs() ◆ ASTReader ◆ ASTWriter ◆ CurCUDATargetCtx ◆ DeviceKnownEmittedFnsAn inverse call graph, mapping known-emitted functions to one of their known-emitted callers (plus the location of the call).
Functions that we can tell a priori must be emitted aren't added to this map.
Definition at line 82 of file SemaCUDA.h.
Referenced by emitCallStackNotes().
◆ LocsWithCUDACallDiagsFunctionDecls and SourceLocations for which CheckCall has emitted a (maybe deferred) "bad call" diagnostic.
We use this to avoid emitting the same deferred diag twice.
Definition at line 73 of file SemaCUDA.h.
Referenced by CheckCall().
The documentation for this class was generated from the following files:
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4