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) : SemaRef(SemaRef) {}
662 HandleFunctionOrMethodRef(FD, DRE);
669 HandleFunctionOrMethodRef(FD, ME);
674void DiagnoseHLSLAvailability::HandleFunctionOrMethodRef(
FunctionDecl *FD,
676 assert((isa<DeclRefExpr>(RefExpr) || isa<MemberExpr>(RefExpr)) &&
677 "expected DeclRefExpr or MemberExpr");
682 if (!WasAlreadyScannedInCurrentStage(FDWithBody))
683 DeclsToScan.push_back(FDWithBody);
688 const AvailabilityAttr *AA = FindAvailabilityAttr(FD);
690 CheckDeclAvailability(
694void DiagnoseHLSLAvailability::RunOnTranslationUnit(
703 DeclContextsToScan.push_back(TU);
705 while (!DeclContextsToScan.empty()) {
706 const DeclContext *DC = DeclContextsToScan.pop_back_val();
707 for (
auto &
D : DC->
decls()) {
714 if (llvm::dyn_cast<NamespaceDecl>(
D) || llvm::dyn_cast<ExportDecl>(
D)) {
715 DeclContextsToScan.push_back(llvm::dyn_cast<DeclContext>(
D));
725 if (HLSLShaderAttr *ShaderAttr = FD->
getAttr<HLSLShaderAttr>()) {
726 SetShaderStageContext(ShaderAttr->getType());
735 for (
const auto *Redecl : FD->
redecls()) {
736 if (Redecl->isInExportDeclContext()) {
743 SetUnknownShaderStageContext();
751void DiagnoseHLSLAvailability::RunOnFunction(
const FunctionDecl *FD) {
752 assert(DeclsToScan.empty() &&
"DeclsToScan should be empty");
753 DeclsToScan.push_back(FD);
755 while (!DeclsToScan.empty()) {
763 const unsigned ScannedStages = GetScannedStages(FD);
764 if (WasAlreadyScannedInCurrentStage(ScannedStages))
767 ReportOnlyShaderStageIssues = !NeverBeenScanned(ScannedStages);
769 AddToScannedFunctions(FD);
774bool DiagnoseHLSLAvailability::HasMatchingEnvironmentOrNone(
775 const AvailabilityAttr *AA) {
780 llvm::Triple::EnvironmentType CurrentEnv = GetCurrentShaderEnvironment();
781 if (CurrentEnv == llvm::Triple::UnknownEnvironment)
784 llvm::Triple::EnvironmentType AttrEnv =
785 AvailabilityAttr::getEnvironmentType(IIEnvironment->
getName());
787 return CurrentEnv == AttrEnv;
790const AvailabilityAttr *
791DiagnoseHLSLAvailability::FindAvailabilityAttr(
const Decl *
D) {
792 AvailabilityAttr
const *PartialMatch =
nullptr;
796 for (
const auto *A :
D->
attrs()) {
797 if (
const auto *Avail = dyn_cast<AvailabilityAttr>(A)) {
798 StringRef AttrPlatform = Avail->getPlatform()->getName();
799 StringRef TargetPlatform =
803 if (AttrPlatform == TargetPlatform) {
805 if (HasMatchingEnvironmentOrNone(Avail))
807 PartialMatch = Avail;
816void DiagnoseHLSLAvailability::CheckDeclAvailability(
NamedDecl *
D,
817 const AvailabilityAttr *AA,
836 if (ReportOnlyShaderStageIssues)
842 if (InUnknownShaderStageContext())
847 bool EnvironmentMatches = HasMatchingEnvironmentOrNone(AA);
848 VersionTuple Introduced = AA->getIntroduced();
857 llvm::StringRef PlatformName(
860 llvm::StringRef CurrentEnvStr =
861 llvm::Triple::getEnvironmentTypeName(GetCurrentShaderEnvironment());
863 llvm::StringRef AttrEnvStr =
864 AA->getEnvironment() ? AA->getEnvironment()->getName() :
"";
865 bool UseEnvironment = !AttrEnvStr.empty();
867 if (EnvironmentMatches) {
869 <<
Range <<
D << PlatformName << Introduced.getAsString()
870 << UseEnvironment << CurrentEnvStr;
876 SemaRef.
Diag(
D->
getLocation(), diag::note_partial_availability_specified_here)
877 <<
D << PlatformName << Introduced.getAsString()
879 << UseEnvironment << AttrEnvStr << CurrentEnvStr;
891 TI.
getTriple().getEnvironment() != llvm::Triple::EnvironmentType::Library)
894 DiagnoseHLSLAvailability(
SemaRef).RunOnTranslationUnit(TU);
907 for (
unsigned i = 1; i < TheCall->
getNumArgs(); ++i) {
911 if (VecTyA ==
nullptr && VecTyB ==
nullptr)
914 if (VecTyA && VecTyB) {
915 bool retValue =
false;
916 if (VecTyA->getElementType() != VecTyB->getElementType()) {
920 diag::err_vec_builtin_incompatible_vector)
925 if (VecTyA->getNumElements() != VecTyB->getNumElements()) {
929 S->
Diag(BuiltinLoc, diag::err_vec_builtin_incompatible_vector)
941 S->
Diag(BuiltinLoc, diag::err_vec_builtin_non_vector)
951 for (
unsigned i = 0; i < TheCall->
getNumArgs(); ++i) {
953 if (Check(PassedType)) {
956 ExpectedType, VecTyA->getNumElements(), VecTyA->getVectorKind());
958 diag::err_typecheck_convert_incompatible)
968 return !PassedType->hasFloatingRepresentation();
988 if (
const auto *VecTy = PassedType->getAs<
VectorType>())
989 return VecTy->getElementType()->isDoubleType();
998 return !PassedType->hasUnsignedIntegerRepresentation();
1001 checkAllUnsignedTypes);
1016 switch (BuiltinID) {
1017 case Builtin::BI__builtin_hlsl_elementwise_all:
1018 case Builtin::BI__builtin_hlsl_elementwise_any: {
1023 case Builtin::BI__builtin_hlsl_elementwise_clamp: {
1034 case Builtin::BI__builtin_hlsl_dot: {
1045 case Builtin::BI__builtin_hlsl_elementwise_rcp: {
1052 case Builtin::BI__builtin_hlsl_elementwise_rsqrt:
1053 case Builtin::BI__builtin_hlsl_elementwise_frac: {
1060 case Builtin::BI__builtin_hlsl_elementwise_isinf: {
1068 case Builtin::BI__builtin_hlsl_lerp: {
1079 case Builtin::BI__builtin_hlsl_mad: {
1092 case Builtin::BI__builtin_elementwise_bitreverse: {
1097 case Builtin::BI__builtin_elementwise_acos:
1098 case Builtin::BI__builtin_elementwise_asin:
1099 case Builtin::BI__builtin_elementwise_atan:
1100 case Builtin::BI__builtin_elementwise_ceil:
1101 case Builtin::BI__builtin_elementwise_cos:
1102 case Builtin::BI__builtin_elementwise_cosh:
1103 case Builtin::BI__builtin_elementwise_exp:
1104 case Builtin::BI__builtin_elementwise_exp2:
1105 case Builtin::BI__builtin_elementwise_floor:
1106 case Builtin::BI__builtin_elementwise_log:
1107 case Builtin::BI__builtin_elementwise_log2:
1108 case Builtin::BI__builtin_elementwise_log10:
1109 case Builtin::BI__builtin_elementwise_pow:
1110 case Builtin::BI__builtin_elementwise_roundeven:
1111 case Builtin::BI__builtin_elementwise_sin:
1112 case Builtin::BI__builtin_elementwise_sinh:
1113 case Builtin::BI__builtin_elementwise_sqrt:
1114 case Builtin::BI__builtin_elementwise_tan:
1115 case Builtin::BI__builtin_elementwise_tanh:
1116 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
Wraps an identifier and optional source location for the identifier.