20#include "llvm/ADT/STLExtras.h"
21#include "llvm/ADT/StringExtras.h"
22#include "llvm/ADT/StringRef.h"
23#include "llvm/Support/Casting.h"
24#include "llvm/Support/ErrorHandling.h"
25#include "llvm/TargetParser/Triple.h"
39 getASTContext(), LexicalParent, CBuffer, KwLoc, Ident, IdentLoc, LBrace);
52 constexpr unsigned CBufferAlign = 128;
58 unsigned FieldAlign = 32;
60 FieldAlign = CBufferAlign;
61 Size = llvm::alignTo(Size, FieldAlign);
65 if (
unsigned ElementCount = AT->getSize().getZExtValue()) {
66 unsigned ElementSize =
68 unsigned AlignedElementSize = llvm::alignTo(ElementSize, CBufferAlign);
69 Size = AlignedElementSize * (ElementCount - 1) + ElementSize;
72 unsigned ElementCount = VT->getNumElements();
73 unsigned ElementSize =
75 Size = ElementSize * ElementCount;
83 auto *BufDecl = cast<HLSLBufferDecl>(Dcl);
84 BufDecl->setRBraceLoc(RBrace);
88 bool HasPackOffset =
false;
89 bool HasNonPackOffset =
false;
90 for (
auto *Field : BufDecl->decls()) {
91 VarDecl *Var = dyn_cast<VarDecl>(Field);
94 if (Field->hasAttr<HLSLPackOffsetAttr>()) {
95 PackOffsetVec.emplace_back(Var, Field->getAttr<HLSLPackOffsetAttr>());
98 HasNonPackOffset =
true;
102 if (HasPackOffset && HasNonPackOffset)
103 Diag(BufDecl->getLocation(), diag::warn_hlsl_packoffset_mix);
109 std::sort(PackOffsetVec.begin(), PackOffsetVec.end(),
110 [](
const std::pair<VarDecl *, HLSLPackOffsetAttr *> &LHS,
111 const std::pair<VarDecl *, HLSLPackOffsetAttr *> &RHS) {
112 return LHS.second->getOffset() < RHS.second->getOffset();
115 for (
unsigned i = 0; i < PackOffsetVec.size() - 1; i++) {
116 VarDecl *Var = PackOffsetVec[i].first;
117 HLSLPackOffsetAttr *
Attr = PackOffsetVec[i].second;
120 unsigned End =
Begin + Size;
121 unsigned NextBegin = PackOffsetVec[i + 1].second->getOffset() * 32;
122 if (End > NextBegin) {
123 VarDecl *NextVar = PackOffsetVec[i + 1].first;
135 int X,
int Y,
int Z) {
136 if (HLSLNumThreadsAttr *NT =
D->
getAttr<HLSLNumThreadsAttr>()) {
137 if (NT->getX() !=
X || NT->getY() != Y || NT->getZ() != Z) {
138 Diag(NT->getLocation(), diag::err_hlsl_attribute_param_mismatch) << AL;
139 Diag(AL.
getLoc(), diag::note_conflicting_attribute);
149 llvm::Triple::EnvironmentType ShaderType) {
150 if (HLSLShaderAttr *NT =
D->
getAttr<HLSLShaderAttr>()) {
151 if (NT->getType() != ShaderType) {
152 Diag(NT->getLocation(), diag::err_hlsl_attribute_param_mismatch) << AL;
153 Diag(AL.
getLoc(), diag::note_conflicting_attribute);
157 return HLSLShaderAttr::Create(
getASTContext(), ShaderType, AL);
160HLSLParamModifierAttr *
162 HLSLParamModifierAttr::Spelling Spelling) {
165 if (HLSLParamModifierAttr *PA =
D->
getAttr<HLSLParamModifierAttr>()) {
166 if ((PA->isIn() && Spelling == HLSLParamModifierAttr::Keyword_out) ||
167 (PA->isOut() && Spelling == HLSLParamModifierAttr::Keyword_in)) {
170 return HLSLParamModifierAttr::Create(
172 HLSLParamModifierAttr::Keyword_inout);
174 Diag(AL.
getLoc(), diag::err_hlsl_duplicate_parameter_modifier) << AL;
175 Diag(PA->getLocation(), diag::note_conflicting_attribute);
188 if (HLSLShaderAttr::isValidShaderType(
Env) &&
Env != llvm::Triple::Library) {
189 if (
const auto *Shader = FD->
getAttr<HLSLShaderAttr>()) {
192 if (Shader->getType() !=
Env) {
193 Diag(Shader->getLocation(), diag::err_hlsl_entry_shader_attr_mismatch)
205 case llvm::Triple::UnknownEnvironment:
206 case llvm::Triple::Library:
209 llvm_unreachable(
"Unhandled environment in triple");
215 const auto *ShaderAttr = FD->
getAttr<HLSLShaderAttr>();
216 assert(ShaderAttr &&
"Entry point has no shader attribute");
217 llvm::Triple::EnvironmentType ST = ShaderAttr->getType();
220 case llvm::Triple::Pixel:
221 case llvm::Triple::Vertex:
222 case llvm::Triple::Geometry:
223 case llvm::Triple::Hull:
224 case llvm::Triple::Domain:
225 case llvm::Triple::RayGeneration:
226 case llvm::Triple::Intersection:
227 case llvm::Triple::AnyHit:
228 case llvm::Triple::ClosestHit:
229 case llvm::Triple::Miss:
230 case llvm::Triple::Callable:
231 if (
const auto *NT = FD->
getAttr<HLSLNumThreadsAttr>()) {
233 {llvm::Triple::Compute,
234 llvm::Triple::Amplification,
235 llvm::Triple::Mesh});
240 case llvm::Triple::Compute:
241 case llvm::Triple::Amplification:
242 case llvm::Triple::Mesh:
243 if (!FD->
hasAttr<HLSLNumThreadsAttr>()) {
245 << llvm::Triple::getEnvironmentTypeName(ST);
250 llvm_unreachable(
"Unhandled environment in triple");
260 Diag(Param->getLocation(), diag::note_previous_decl) << Param;
270 auto *ShaderAttr = EntryPoint->
getAttr<HLSLShaderAttr>();
271 assert(ShaderAttr &&
"Entry point has no shader attribute");
272 llvm::Triple::EnvironmentType ST = ShaderAttr->getType();
274 switch (AnnotationAttr->
getKind()) {
275 case attr::HLSLSV_DispatchThreadID:
276 case attr::HLSLSV_GroupIndex:
277 if (ST == llvm::Triple::Compute)
282 llvm_unreachable(
"Unknown HLSLAnnotationAttr");
287 const Attr *A, llvm::Triple::EnvironmentType Stage,
288 std::initializer_list<llvm::Triple::EnvironmentType> AllowedStages) {
290 llvm::transform(AllowedStages, std::back_inserter(StageStrings),
291 [](llvm::Triple::EnvironmentType ST) {
293 HLSLShaderAttr::ConvertEnvironmentTypeToStr(ST));
295 Diag(A->
getLoc(), diag::err_hlsl_attr_unsupported_in_stage)
296 << A << llvm::Triple::getEnvironmentTypeName(Stage)
297 << (AllowedStages.size() != 1) << join(StageStrings,
", ");
301 llvm::VersionTuple SMVersion =
303 uint32_t ZMax = 1024;
304 uint32_t ThreadMax = 1024;
305 if (SMVersion.getMajor() <= 4) {
308 }
else if (SMVersion.getMajor() == 5) {
318 diag::err_hlsl_numthreads_argument_oor)
327 diag::err_hlsl_numthreads_argument_oor)
336 diag::err_hlsl_numthreads_argument_oor)
341 if (
X * Y * Z > ThreadMax) {
342 Diag(AL.
getLoc(), diag::err_hlsl_numthreads_invalid) << ThreadMax;
355 return VT->getNumElements() <= 3;
360 auto *VD = cast<ValueDecl>(
D);
362 Diag(AL.
getLoc(), diag::err_hlsl_attr_invalid_type)
363 << AL <<
"uint/uint2/uint3";
373 Diag(AL.
getLoc(), diag::err_hlsl_attr_invalid_ast_node)
374 << AL <<
"shader constant in a constant buffer";
378 uint32_t SubComponent;
385 QualType T = cast<VarDecl>(
D)->getType().getCanonicalType();
393 if (IsAggregateTy || Size > 128) {
394 Diag(AL.
getLoc(), diag::err_hlsl_packoffset_cross_reg_boundary);
398 if ((Component * 32 + Size) > 128) {
399 Diag(AL.
getLoc(), diag::err_hlsl_packoffset_cross_reg_boundary);
404 EltTy = VT->getElementType();
406 if (Align > 32 && Component == 1) {
409 Diag(AL.
getLoc(), diag::err_hlsl_packoffset_alignment_mismatch)
426 llvm::Triple::EnvironmentType ShaderType;
427 if (!HLSLShaderAttr::ConvertStrToEnvironmentType(Str, ShaderType)) {
428 Diag(AL.
getLoc(), diag::warn_attribute_type_not_supported)
429 << AL << Str << ArgLoc;
442 Diag(AL.
getLoc(), diag::err_attribute_argument_type)
452 llvm::dxil::ResourceClass RC;
453 if (!HLSLResourceClassAttr::ConvertStrToResourceClass(
Identifier, RC)) {
454 Diag(ArgLoc, diag::warn_attribute_type_not_supported)
463 StringRef Space =
"space0";
467 Diag(AL.
getLoc(), diag::err_attribute_argument_type)
473 StringRef Str =
Loc->Ident->getName();
480 Diag(AL.
getLoc(), diag::err_attribute_argument_type)
486 Space =
Loc->Ident->getName();
487 SpaceArgLoc =
Loc->Loc;
501 Diag(ArgLoc, diag::err_hlsl_unsupported_register_type)
502 << Slot.substr(0, 1);
506 StringRef SlotNum = Slot.substr(1);
508 if (SlotNum.getAsInteger(10, Num)) {
509 Diag(ArgLoc, diag::err_hlsl_unsupported_register_number);
514 if (!Space.starts_with(
"space")) {
515 Diag(SpaceArgLoc, diag::err_hlsl_expected_space) << Space;
518 StringRef SpaceNum = Space.substr(5);
520 if (SpaceNum.getAsInteger(10, Num)) {
521 Diag(SpaceArgLoc, diag::err_hlsl_expected_space) << Space;
527 HLSLResourceBindingAttr *NewAttr =
528 HLSLResourceBindingAttr::Create(
getASTContext(), Slot, Space, AL);
555class DiagnoseHLSLAvailability
585 llvm::DenseMap<const FunctionDecl *, unsigned> ScannedDecls;
589 llvm::Triple::EnvironmentType CurrentShaderEnvironment;
590 unsigned CurrentShaderStageBit;
595 bool ReportOnlyShaderStageIssues;
598 void SetShaderStageContext(llvm::Triple::EnvironmentType ShaderType) {
599 static_assert(
sizeof(
unsigned) >= 4);
600 assert(HLSLShaderAttr::isValidShaderType(ShaderType));
601 assert((
unsigned)(ShaderType - llvm::Triple::Pixel) < 31 &&
602 "ShaderType is too big for this bitmap");
605 unsigned bitmapIndex = ShaderType - llvm::Triple::Pixel;
606 CurrentShaderEnvironment = ShaderType;
607 CurrentShaderStageBit = (1 << bitmapIndex);
610 void SetUnknownShaderStageContext() {
611 CurrentShaderEnvironment = llvm::Triple::UnknownEnvironment;
612 CurrentShaderStageBit = (1 << 31);
615 llvm::Triple::EnvironmentType GetCurrentShaderEnvironment()
const {
616 return CurrentShaderEnvironment;
619 bool InUnknownShaderStageContext()
const {
620 return CurrentShaderEnvironment == llvm::Triple::UnknownEnvironment;
625 unsigned &ScannedStages = ScannedDecls.getOrInsertDefault(FD);
626 ScannedStages |= CurrentShaderStageBit;
630 return ScannedDecls.getOrInsertDefault(FD);
633 bool WasAlreadyScannedInCurrentStage(
const FunctionDecl *FD) {
634 return WasAlreadyScannedInCurrentStage(GetScannedStages(FD));
637 bool WasAlreadyScannedInCurrentStage(
unsigned ScannerStages) {
638 return ScannerStages & CurrentShaderStageBit;
641 static bool NeverBeenScanned(
unsigned ScannedStages) {
642 return ScannedStages == 0;
647 void CheckDeclAvailability(
NamedDecl *
D,
const AvailabilityAttr *AA,
649 const AvailabilityAttr *FindAvailabilityAttr(
const Decl *
D);
650 bool HasMatchingEnvironmentOrNone(
const AvailabilityAttr *AA);
653 DiagnoseHLSLAvailability(
Sema &SemaRef)
655 CurrentShaderEnvironment(
llvm::Triple::UnknownEnvironment),
656 CurrentShaderStageBit(0), ReportOnlyShaderStageIssues(
false) {}
665 HandleFunctionOrMethodRef(FD, DRE);
672 HandleFunctionOrMethodRef(FD, ME);
677void DiagnoseHLSLAvailability::HandleFunctionOrMethodRef(
FunctionDecl *FD,
679 assert((isa<DeclRefExpr>(RefExpr) || isa<MemberExpr>(RefExpr)) &&
680 "expected DeclRefExpr or MemberExpr");
685 if (!WasAlreadyScannedInCurrentStage(FDWithBody))
686 DeclsToScan.push_back(FDWithBody);
691 const AvailabilityAttr *AA = FindAvailabilityAttr(FD);
693 CheckDeclAvailability(
697void DiagnoseHLSLAvailability::RunOnTranslationUnit(
706 DeclContextsToScan.push_back(TU);
708 while (!DeclContextsToScan.empty()) {
709 const DeclContext *DC = DeclContextsToScan.pop_back_val();
710 for (
auto &
D : DC->
decls()) {
717 if (llvm::dyn_cast<NamespaceDecl>(
D) || llvm::dyn_cast<ExportDecl>(
D)) {
718 DeclContextsToScan.push_back(llvm::dyn_cast<DeclContext>(
D));
728 if (HLSLShaderAttr *ShaderAttr = FD->
getAttr<HLSLShaderAttr>()) {
729 SetShaderStageContext(ShaderAttr->getType());
738 for (
const auto *Redecl : FD->
redecls()) {
739 if (Redecl->isInExportDeclContext()) {
746 SetUnknownShaderStageContext();
754void DiagnoseHLSLAvailability::RunOnFunction(
const FunctionDecl *FD) {
755 assert(DeclsToScan.empty() &&
"DeclsToScan should be empty");
756 DeclsToScan.push_back(FD);
758 while (!DeclsToScan.empty()) {
766 const unsigned ScannedStages = GetScannedStages(FD);
767 if (WasAlreadyScannedInCurrentStage(ScannedStages))
770 ReportOnlyShaderStageIssues = !NeverBeenScanned(ScannedStages);
772 AddToScannedFunctions(FD);
777bool DiagnoseHLSLAvailability::HasMatchingEnvironmentOrNone(
778 const AvailabilityAttr *AA) {
783 llvm::Triple::EnvironmentType CurrentEnv = GetCurrentShaderEnvironment();
784 if (CurrentEnv == llvm::Triple::UnknownEnvironment)
787 llvm::Triple::EnvironmentType AttrEnv =
788 AvailabilityAttr::getEnvironmentType(IIEnvironment->
getName());
790 return CurrentEnv == AttrEnv;
793const AvailabilityAttr *
794DiagnoseHLSLAvailability::FindAvailabilityAttr(
const Decl *
D) {
795 AvailabilityAttr
const *PartialMatch =
nullptr;
799 for (
const auto *A :
D->
attrs()) {
800 if (
const auto *Avail = dyn_cast<AvailabilityAttr>(A)) {
801 StringRef AttrPlatform = Avail->getPlatform()->getName();
802 StringRef TargetPlatform =
806 if (AttrPlatform == TargetPlatform) {
808 if (HasMatchingEnvironmentOrNone(Avail))
810 PartialMatch = Avail;
819void DiagnoseHLSLAvailability::CheckDeclAvailability(
NamedDecl *
D,
820 const AvailabilityAttr *AA,
839 if (ReportOnlyShaderStageIssues)
845 if (InUnknownShaderStageContext())
850 bool EnvironmentMatches = HasMatchingEnvironmentOrNone(AA);
851 VersionTuple Introduced = AA->getIntroduced();
860 llvm::StringRef PlatformName(
863 llvm::StringRef CurrentEnvStr =
864 llvm::Triple::getEnvironmentTypeName(GetCurrentShaderEnvironment());
866 llvm::StringRef AttrEnvStr =
867 AA->getEnvironment() ? AA->getEnvironment()->getName() :
"";
868 bool UseEnvironment = !AttrEnvStr.empty();
870 if (EnvironmentMatches) {
872 <<
Range <<
D << PlatformName << Introduced.getAsString()
873 << UseEnvironment << CurrentEnvStr;
879 SemaRef.
Diag(
D->
getLocation(), diag::note_partial_availability_specified_here)
880 <<
D << PlatformName << Introduced.getAsString()
882 << UseEnvironment << AttrEnvStr << CurrentEnvStr;
894 TI.
getTriple().getEnvironment() != llvm::Triple::EnvironmentType::Library)
897 DiagnoseHLSLAvailability(
SemaRef).RunOnTranslationUnit(TU);
910 for (
unsigned i = 1; i < TheCall->
getNumArgs(); ++i) {
914 if (VecTyA ==
nullptr && VecTyB ==
nullptr)
917 if (VecTyA && VecTyB) {
918 bool retValue =
false;
919 if (VecTyA->getElementType() != VecTyB->getElementType()) {
923 diag::err_vec_builtin_incompatible_vector)
928 if (VecTyA->getNumElements() != VecTyB->getNumElements()) {
932 S->
Diag(BuiltinLoc, diag::err_vec_builtin_incompatible_vector)
944 S->
Diag(BuiltinLoc, diag::err_vec_builtin_non_vector)
954 for (
unsigned i = 0; i < TheCall->
getNumArgs(); ++i) {
956 if (Check(PassedType)) {
959 ExpectedType, VecTyA->getNumElements(), VecTyA->getVectorKind());
961 diag::err_typecheck_convert_incompatible)
971 return !PassedType->hasFloatingRepresentation();
991 if (
const auto *VecTy = PassedType->getAs<
VectorType>())
992 return VecTy->getElementType()->isDoubleType();
1001 return !PassedType->hasUnsignedIntegerRepresentation();
1004 checkAllUnsignedTypes);
1019 switch (BuiltinID) {
1020 case Builtin::BI__builtin_hlsl_all:
1021 case Builtin::BI__builtin_hlsl_any: {
1026 case Builtin::BI__builtin_hlsl_elementwise_clamp: {
1037 case Builtin::BI__builtin_hlsl_dot: {
1048 case Builtin::BI__builtin_hlsl_elementwise_saturate:
1049 case Builtin::BI__builtin_hlsl_elementwise_rcp: {
1056 case Builtin::BI__builtin_hlsl_elementwise_rsqrt:
1057 case Builtin::BI__builtin_hlsl_elementwise_frac: {
1064 case Builtin::BI__builtin_hlsl_elementwise_isinf: {
1072 case Builtin::BI__builtin_hlsl_lerp: {
1083 case Builtin::BI__builtin_hlsl_length: {
1094 RetTy = VTy->getElementType();
1101 case Builtin::BI__builtin_hlsl_mad: {
1112 case Builtin::BI__builtin_hlsl_normalize: {
1126 case Builtin::BI__builtin_elementwise_bitreverse: {
1131 case Builtin::BI__builtin_elementwise_acos:
1132 case Builtin::BI__builtin_elementwise_asin:
1133 case Builtin::BI__builtin_elementwise_atan:
1134 case Builtin::BI__builtin_elementwise_ceil:
1135 case Builtin::BI__builtin_elementwise_cos:
1136 case Builtin::BI__builtin_elementwise_cosh:
1137 case Builtin::BI__builtin_elementwise_exp:
1138 case Builtin::BI__builtin_elementwise_exp2:
1139 case Builtin::BI__builtin_elementwise_floor:
1140 case Builtin::BI__builtin_elementwise_log:
1141 case Builtin::BI__builtin_elementwise_log2:
1142 case Builtin::BI__builtin_elementwise_log10:
1143 case Builtin::BI__builtin_elementwise_pow:
1144 case Builtin::BI__builtin_elementwise_roundeven:
1145 case Builtin::BI__builtin_elementwise_sin:
1146 case Builtin::BI__builtin_elementwise_sinh:
1147 case Builtin::BI__builtin_elementwise_sqrt:
1148 case Builtin::BI__builtin_elementwise_tan:
1149 case Builtin::BI__builtin_elementwise_tanh:
1150 case Builtin::BI__builtin_elementwise_trunc: {
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
bool CheckNoDoubleVectors(Sema *S, CallExpr *TheCall)
bool CheckUnsignedIntRepresentation(Sema *S, CallExpr *TheCall)
bool CheckVectorElementCallArgs(Sema *S, CallExpr *TheCall)
static bool isLegalTypeForHLSLSV_DispatchThreadID(QualType T)
bool CheckFloatOrHalfRepresentations(Sema *S, CallExpr *TheCall)
bool CheckAllArgsHaveFloatRepresentation(Sema *S, CallExpr *TheCall)
static unsigned calculateLegacyCbufferSize(const ASTContext &Context, QualType T)
void SetElementTypeAsReturnType(Sema *S, CallExpr *TheCall, QualType ReturnType)
bool CheckArgsTypesAreCorrect(Sema *S, CallExpr *TheCall, QualType ExpectedType, llvm::function_ref< bool(clang::QualType PassedType)> Check)
This file declares semantic analysis for HLSL constructs.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const ConstantArrayType * getAsConstantArrayType(QualType T) const
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedIntTy
const TargetInfo & getTargetInfo() const
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
Attr - This represents one attribute.
attr::Kind getKind() const
SourceRange getRange() const
SourceLocation getLoc() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
SourceLocation getBeginLoc() const LLVM_READONLY
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return null.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
Represents the canonical version of C arrays with a specified constant size.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
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.
bool isInExportDeclContext() const
Whether this declaration was exported in a lexical context.
SourceLocation getLocation() const
DeclContext * getDeclContext()
SourceLocation getBeginLoc() const LLVM_READONLY
This represents one expression.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
Represents a member of a struct/union/class.
Represents a function declaration or definition.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
bool isThisDeclarationADefinition() const
Returns whether this specific declaration of the function is also a definition that does not contain ...
ArrayRef< ParmVarDecl * > parameters() const
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body.
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
static HLSLBufferDecl * Create(ASTContext &C, DeclContext *LexicalParent, bool CBuffer, SourceLocation KwLoc, IdentifierInfo *ID, SourceLocation IDLoc, SourceLocation LBrace)
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
This represents a decl that may have a name.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
Represents a parameter to a function.
ParsedAttr - Represents a syntactic attribute.
unsigned getSemanticSpelling() const
If the parsed attribute has a semantic equivalent, and it would have a semantic Spelling enumeration ...
IdentifierLoc * getArgAsIdent(unsigned Arg) const
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this attribute.
bool isArgIdent(unsigned Arg) const
Expr * getArgAsExpr(unsigned Arg) const
A (possibly-)qualified type.
Represents a struct/union/class.
field_range fields() const
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
A class that does preorder or postorder depth-first traversal on the entire Clang AST and visits each...
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
Scope - A scope is a transient data structure that is used while parsing the program.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
ASTContext & getASTContext() const
void handleResourceClassAttr(Decl *D, const ParsedAttr &AL)
void DiagnoseAttrStageMismatch(const Attr *A, llvm::Triple::EnvironmentType Stage, std::initializer_list< llvm::Triple::EnvironmentType > AllowedStages)
void handleShaderAttr(Decl *D, const ParsedAttr &AL)
void handleSV_DispatchThreadIDAttr(Decl *D, const ParsedAttr &AL)
void CheckEntryPoint(FunctionDecl *FD)
HLSLNumThreadsAttr * mergeNumThreadsAttr(Decl *D, const AttributeCommonInfo &AL, int X, int Y, int Z)
void handlePackOffsetAttr(Decl *D, const ParsedAttr &AL)
void CheckSemanticAnnotation(FunctionDecl *EntryPoint, const Decl *Param, const HLSLAnnotationAttr *AnnotationAttr)
void handleParamModifierAttr(Decl *D, const ParsedAttr &AL)
void handleResourceBindingAttr(Decl *D, const ParsedAttr &AL)
void handleNumThreadsAttr(Decl *D, const ParsedAttr &AL)
void DiagnoseAvailabilityViolations(TranslationUnitDecl *TU)
void ActOnTopLevelFunction(FunctionDecl *FD)
HLSLShaderAttr * mergeShaderAttr(Decl *D, const AttributeCommonInfo &AL, llvm::Triple::EnvironmentType ShaderType)
void ActOnFinishBuffer(Decl *Dcl, SourceLocation RBrace)
HLSLParamModifierAttr * mergeParamModifierAttr(Decl *D, const AttributeCommonInfo &AL, HLSLParamModifierAttr::Spelling Spelling)
Decl * ActOnStartBuffer(Scope *BufferScope, bool CBuffer, SourceLocation KwLoc, IdentifierInfo *Ident, SourceLocation IdentLoc, SourceLocation LBrace)
bool CheckBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall)
Sema - This implements semantic analysis and AST building for C.
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
ASTContext & getASTContext() const
bool BuiltinVectorToScalarMath(CallExpr *TheCall)
const LangOptions & getLangOpts() const
bool PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall)
DeclContext * getCurLexicalContext() const
bool checkUInt32Argument(const AttrInfo &AI, const Expr *Expr, uint32_t &Val, unsigned Idx=UINT_MAX, bool StrictlyUnsigned=false)
If Expr is a valid integer constant, get the value of the integer expression and return success or fa...
bool BuiltinElementwiseTernaryMath(CallExpr *TheCall, bool CheckForFloatArgs=true)
bool checkArgCount(CallExpr *Call, unsigned DesiredArgCount)
Checks that a call expression's argument count is the desired number.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
bool checkStringLiteralArgumentAttr(const AttributeCommonInfo &CI, const Expr *E, StringRef &Str, SourceLocation *ArgLocation=nullptr)
Check if the argument E is a ASCII string literal.
Encodes a location in the source.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
SourceLocation getEndLoc() const LLVM_READONLY
SourceLocation getBeginLoc() const LLVM_READONLY
Exposes information about the current target.
TargetOptions & getTargetOpts() const
Retrieve the target options.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
StringRef getPlatformName() const
Retrieve the name of the platform as it is used in the availability attribute.
VersionTuple getPlatformMinVersion() const
Retrieve the minimum desired version of the platform, to which the program should be compiled.
std::string HLSLEntry
The entry point name for HLSL shader being compiled as specified by -E.
The top declaration context.
bool isStructureType() const
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e....
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type.
bool isFloat32Type() const
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g....
bool isVectorType() const
const T * getAs() const
Member-template getAs<specific type>'.
Represents a variable declaration or definition.
Represents a GCC generic vector type.
Defines the clang::TargetInfo interface.
The JSON file list parser is used to communicate input to InstallAPI.
@ AANT_ArgumentIdentifier
@ Result
The result type of a method or function.
const FunctionProtoType * T
@ Generic
not a target-specific vector type
Diagnostic wrappers for TextAPI types for error reporting.
Wraps an identifier and optional source location for the identifier.