27#include "llvm/ADT/SmallVector.h"
29using namespace llvm::hlsl;
37static FunctionDecl *lookupBuiltinFunction(Sema &S, StringRef Name) {
39 S.getASTContext().Idents.get(Name, tok::TokenKind::identifier);
40 DeclarationNameInfo NameInfo =
41 DeclarationNameInfo(DeclarationName(&II), SourceLocation());
45 S.LookupName(R, S.getCurScope());
48 assert(R.isSingleResult() &&
49 "Since this is a builtin it should always resolve!");
53CXXConstructorDecl *lookupCopyConstructor(QualType ResTy) {
54 assert(ResTy->isRecordType() &&
"not a CXXRecord type");
55 for (
auto *CD : ResTy->getAsCXXRecordDecl()->ctors())
56 if (CD->isCopyConstructor())
109 HLSLParamModifierAttr::Spelling Modifier;
111 HLSLParamModifierAttr::Spelling Modifier)
112 : NameII(NameII), Ty(Ty), Modifier(Modifier) {}
119 LocalVar(StringRef Name,
QualType Ty) : Name(Name), Ty(Ty),
Decl(
nullptr) {}
141 enum class PlaceHolder {
153 Expr *convertPlaceholder(PlaceHolder PH);
154 Expr *convertPlaceholder(LocalVar &Var);
155 Expr *convertPlaceholder(
Expr *E) {
return E; }
161 QualType ReturnTy,
bool IsConst =
false,
163 : DeclBuilder(DB), Name(Name), ReturnTy(ReturnTy), Method(
nullptr),
164 IsConst(IsConst), IsCtor(IsCtor), SC(SC) {}
167 QualType ReturnTy,
bool IsConst =
false,
177 HLSLParamModifierAttr::Spelling Modifier =
178 HLSLParamModifierAttr::Keyword_in);
180 template <
typename... Ts>
182 QualType ReturnType, Ts... ArgSpecs);
183 template <
typename TLHS,
typename TRHS>
186 template <
typename T>
188 template <
typename ResourceT,
typename ValueT>
191 template <
typename T>
194 template <
typename ResourceT,
typename ValueT>
208 void ensureCompleteDecl() {
213 template <
typename ResourceT,
typename ValueT>
226 assert(!
Builder.Record->isCompleteDefinition() &&
227 "record is already complete");
229 unsigned Position =
static_cast<unsigned>(
Params.size());
233 &AST.
Idents.
get(Name, tok::TokenKind::identifier),
237 if (!DefaultValue.
isNull())
238 Decl->setDefaultArgument(AST,
239 Builder.SemaRef.getTrivialTemplateArgumentLoc(
281 "unexpected concept decl parameter count");
290 Builder.Record->getDeclContext(),
300 T->setDeclContext(DC);
302 QualType ConceptTType = Context.getTypeDeclType(ConceptTTPD);
308 QualType CSETType = Context.getTypeDeclType(
T);
316 Context,
Builder.Record->getDeclContext(), Loc, {CSETA});
356 Builder.Template->setImplicit(
true);
357 Builder.Template->setLexicalDeclContext(
Builder.Record->getDeclContext());
368Expr *BuiltinTypeMethodBuilder::convertPlaceholder(PlaceHolder PH) {
369 if (PH == PlaceHolder::Handle)
371 if (PH == PlaceHolder::CounterHandle)
374 if (PH == PlaceHolder::LastStmt) {
375 assert(!StmtsList.empty() &&
"no statements in the list");
376 Stmt *LastStmt = StmtsList.pop_back_val();
377 assert(
isa<ValueStmt>(LastStmt) &&
"last statement does not have a value");
389Expr *BuiltinTypeMethodBuilder::convertPlaceholder(LocalVar &Var) {
390 VarDecl *VD = Var.Decl;
391 assert(VD &&
"local variable is not declared");
393 VD->getASTContext(), NestedNameSpecifierLoc(), SourceLocation(), VD,
394 false, DeclarationNameInfo(VD->getDeclName(), SourceLocation()),
401 bool IsConst,
bool IsCtor,
403 : DeclBuilder(DB), ReturnTy(ReturnTy), Method(
nullptr), IsConst(IsConst),
404 IsCtor(IsCtor), SC(SC) {
406 assert((!NameStr.empty() || IsCtor) &&
"method needs a name");
407 assert(((IsCtor && !IsConst) || !IsCtor) &&
"constructor cannot be const");
415 AST.
Idents.
get(NameStr, tok::TokenKind::identifier);
422 HLSLParamModifierAttr::Spelling Modifier) {
423 assert(Method ==
nullptr &&
"Cannot add param, method already created");
424 const IdentifierInfo &II = DeclBuilder.SemaRef.getASTContext().Idents.get(
425 Name, tok::TokenKind::identifier);
426 Params.emplace_back(II, Ty, Modifier);
430void BuiltinTypeMethodBuilder::createDecl() {
431 assert(
Method ==
nullptr &&
"Method or constructor is already created");
436 for (Param &MP : Params)
437 ParamTypes.emplace_back(MP.Ty);
450 AST, DeclBuilder.Record,
SourceLocation(), NameInfo, FuncTy, TSInfo,
455 AST, DeclBuilder.Record,
SourceLocation(), NameInfo, FuncTy, TSInfo, SC,
463 for (
int I = 0, E = Params.size(); I != E; I++) {
464 Param &MP = Params[I];
470 if (MP.Modifier != HLSLParamModifierAttr::Keyword_in) {
472 HLSLParamModifierAttr::Create(AST,
SourceRange(), MP.Modifier);
476 ParmDecls.push_back(Parm);
477 FnProtoLoc.setParam(I, Parm);
479 Method->setParams({ParmDecls});
483 ensureCompleteDecl();
485 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
487 AST,
SourceLocation(), Method->getFunctionObjectParameterType(),
true);
488 FieldDecl *HandleField = DeclBuilder.getResourceHandleField();
495 ensureCompleteDecl();
497 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
499 AST,
SourceLocation(), Method->getFunctionObjectParameterType(),
true);
500 FieldDecl *HandleField = DeclBuilder.getResourceCounterHandleField();
508 ensureCompleteDecl();
510 assert(Var.Decl ==
nullptr &&
"local variable is already declared");
512 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
515 &AST.
Idents.
get(Var.Name, tok::TokenKind::identifier), Var.Ty,
519 StmtsList.push_back(DS);
524 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
528 StmtsList.push_back(ThisExpr);
532template <
typename... Ts>
535 QualType ReturnType, Ts... ArgSpecs) {
536 ensureCompleteDecl();
538 std::array<
Expr *,
sizeof...(ArgSpecs)> Args{
539 convertPlaceholder(std::forward<Ts>(ArgSpecs))...};
541 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
542 FunctionDecl *FD = lookupBuiltinFunction(DeclBuilder.SemaRef, BuiltinName);
556 StmtsList.push_back(
Call);
560template <
typename TLHS,
typename TRHS>
562 Expr *LHSExpr = convertPlaceholder(LHS);
563 Expr *RHSExpr = convertPlaceholder(RHS);
565 DeclBuilder.SemaRef.getASTContext(), LHSExpr, RHSExpr, BO_Assign,
568 StmtsList.push_back(AssignStmt);
574 Expr *PtrExpr = convertPlaceholder(Ptr);
580 StmtsList.push_back(Deref);
587 ensureCompleteDecl();
589 Expr *ResourceExpr = convertPlaceholder(ResourceRecord);
591 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
592 FieldDecl *HandleField = DeclBuilder.getResourceHandleField();
596 StmtsList.push_back(HandleExpr);
600template <
typename ResourceT,
typename ValueT>
603 ValueT HandleValue) {
604 return setFieldOnResource(ResourceRecord, HandleValue,
605 DeclBuilder.getResourceHandleField());
608template <
typename ResourceT,
typename ValueT>
611 ResourceT ResourceRecord, ValueT HandleValue) {
612 return setFieldOnResource(ResourceRecord, HandleValue,
613 DeclBuilder.getResourceCounterHandleField());
616template <
typename ResourceT,
typename ValueT>
618 ResourceT ResourceRecord, ValueT HandleValue,
FieldDecl *HandleField) {
619 ensureCompleteDecl();
621 Expr *ResourceExpr = convertPlaceholder(ResourceRecord);
622 Expr *HandleValueExpr = convertPlaceholder(HandleValue);
629 DeclBuilder.SemaRef.
getASTContext(), HandleMemberExpr, HandleValueExpr,
632 StmtsList.push_back(AssignStmt);
637BuiltinTypeMethodBuilder &
639 ensureCompleteDecl();
641 Expr *ResourceExpr = convertPlaceholder(ResourceRecord);
643 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
644 FieldDecl *HandleField = DeclBuilder.getResourceCounterHandleField();
648 StmtsList.push_back(HandleExpr);
654 ensureCompleteDecl();
656 Expr *ReturnValueExpr = convertPlaceholder(ReturnValue);
657 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
667 assert(CD &&
"no copy constructor found");
681 assert(!DeclBuilder.Record->isCompleteDefinition() &&
682 "record is already complete");
684 ensureCompleteDecl();
686 if (!Method->hasBody()) {
687 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
688 assert((ReturnTy == AST.
VoidTy || !StmtsList.empty()) &&
689 "nothing to return from non-void method");
690 if (ReturnTy != AST.
VoidTy) {
691 if (
Expr *LastExpr = dyn_cast<Expr>(StmtsList.back())) {
693 ReturnTy.getNonReferenceType()) &&
694 "Return type of the last statement must match the return type "
697 StmtsList.pop_back();
706 Method->setLexicalDeclContext(DeclBuilder.Record);
708 Method->addAttr(AlwaysInlineAttr::CreateImplicit(
709 AST,
SourceRange(), AlwaysInlineAttr::CXX11_clang_always_inline));
710 DeclBuilder.Record->addDecl(Method);
716 : SemaRef(SemaRef), Record(R) {
717 Record->startDefinition();
718 Template = Record->getDescribedClassTemplate();
724 : SemaRef(SemaRef), HLSLNamespace(Namespace) {
730 if (SemaRef.LookupQualifiedName(
Result, HLSLNamespace)) {
733 if (
auto *TD = dyn_cast<ClassTemplateDecl>(
Found)) {
734 PrevDecl = TD->getTemplatedDecl();
737 PrevDecl = dyn_cast<CXXRecordDecl>(
Found);
738 assert(PrevDecl &&
"Unexpected lookup result type.");
743 Template = PrevTemplate;
750 Record->setImplicit(
true);
751 Record->setLexicalDeclContext(HLSLNamespace);
752 Record->setHasExternalLexicalStorage();
756 FinalAttr::CreateImplicit(AST,
SourceRange(), FinalAttr::Keyword_final));
760 if (HLSLNamespace && !Template && Record->getDeclContext() == HLSLNamespace)
761 HLSLNamespace->addDecl(Record);
768 assert(!Record->isCompleteDefinition() &&
"record is already complete");
769 assert(Record->isBeingDefined() &&
770 "Definition must be started before adding members!");
779 Field->setAccess(Access);
780 Field->setImplicit(
true);
781 for (
Attr *A : Attrs) {
786 Record->addDecl(Field);
787 Fields[Name] = Field;
793 bool RawBuffer,
bool HasCounter,
795 addHandleMember(RC, IsROV, RawBuffer, Access);
797 addCounterHandleMember(RC, IsROV, RawBuffer, Access);
802 ResourceClass RC,
bool IsROV,
bool RawBuffer,
AccessSpecifier Access) {
803 return addResourceMember(
"__handle", RC, IsROV, RawBuffer,
808 ResourceClass RC,
bool IsROV,
bool RawBuffer,
AccessSpecifier Access) {
809 return addResourceMember(
"__counter_handle", RC, IsROV, RawBuffer,
814 StringRef MemberName,
ResourceClass RC,
bool IsROV,
bool RawBuffer,
815 bool IsCounter, AccessSpecifier Access) {
816 assert(!
Record->isCompleteDefinition() &&
"record is already complete");
819 TypeSourceInfo *ElementTypeInfo =
823 QualType AttributedResTy = QualType();
825 HLSLResourceClassAttr::CreateImplicit(Ctx, RC),
826 IsROV ? HLSLROVAttr::CreateImplicit(Ctx) :
nullptr,
827 RawBuffer ? HLSLRawBufferAttr::CreateImplicit(Ctx) :
nullptr,
829 ? HLSLContainedTypeAttr::CreateImplicit(Ctx, ElementTypeInfo)
832 Attrs.push_back(HLSLIsCounterAttr::CreateImplicit(Ctx));
843 assert(!Record->isCompleteDefinition() &&
"record is already complete");
845 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
846 QualType HandleType = getResourceHandleField()->getType();
849 .callBuiltin(
"__builtin_hlsl_resource_uninitializedhandle", HandleType,
851 .assign(PH::Handle, PH::LastStmt)
858 addCreateFromBindingWithImplicitCounter();
859 addCreateFromImplicitBindingWithImplicitCounter();
861 addCreateFromBinding();
862 addCreateFromImplicitBinding();
879 assert(!
Record->isCompleteDefinition() &&
"record is already complete");
881 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
885 BuiltinTypeMethodBuilder::LocalVar TmpVar(
"tmp", RecordType);
891 .addParam(
"range", AST.
IntTy)
894 .declareLocalVar(TmpVar)
895 .accessHandleFieldOnResource(TmpVar)
896 .callBuiltin(
"__builtin_hlsl_resource_handlefrombinding", HandleType,
897 PH::LastStmt, PH::_0, PH::_1, PH::_2, PH::_3, PH::_4)
898 .setHandleFieldOnResource(TmpVar, PH::LastStmt)
916 assert(!
Record->isCompleteDefinition() &&
"record is already complete");
918 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
922 BuiltinTypeMethodBuilder::LocalVar TmpVar(
"tmp", RecordType);
928 .addParam(
"range", AST.
IntTy)
931 .declareLocalVar(TmpVar)
932 .accessHandleFieldOnResource(TmpVar)
933 .callBuiltin(
"__builtin_hlsl_resource_handlefromimplicitbinding",
934 HandleType, PH::LastStmt, PH::_0, PH::_1, PH::_2, PH::_3,
936 .setHandleFieldOnResource(TmpVar, PH::LastStmt)
957BuiltinTypeDeclBuilder::addCreateFromBindingWithImplicitCounter() {
958 assert(!
Record->isCompleteDefinition() &&
"record is already complete");
960 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
962 QualType HandleType = getResourceHandleField()->
getType();
964 BuiltinTypeMethodBuilder::LocalVar TmpVar(
"tmp", RecordType);
967 "__createFromBindingWithImplicitCounter",
971 .addParam(
"range", AST.
IntTy)
975 .declareLocalVar(TmpVar)
976 .accessHandleFieldOnResource(TmpVar)
977 .callBuiltin(
"__builtin_hlsl_resource_handlefrombinding", HandleType,
978 PH::LastStmt, PH::_0, PH::_1, PH::_2, PH::_3, PH::_4)
979 .setHandleFieldOnResource(TmpVar, PH::LastStmt)
980 .accessHandleFieldOnResource(TmpVar)
981 .callBuiltin(
"__builtin_hlsl_resource_counterhandlefromimplicitbinding",
982 HandleType, PH::LastStmt, PH::_5, PH::_1)
983 .setCounterHandleFieldOnResource(TmpVar, PH::LastStmt)
1005BuiltinTypeDeclBuilder::addCreateFromImplicitBindingWithImplicitCounter() {
1006 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1008 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1009 ASTContext &AST = SemaRef.getASTContext();
1010 QualType HandleType = getResourceHandleField()->getType();
1012 BuiltinTypeMethodBuilder::LocalVar TmpVar(
"tmp", RecordType);
1015 *
this,
"__createFromImplicitBindingWithImplicitCounter",
1019 .addParam(
"range", AST.
IntTy)
1023 .declareLocalVar(TmpVar)
1024 .accessHandleFieldOnResource(TmpVar)
1025 .callBuiltin(
"__builtin_hlsl_resource_handlefromimplicitbinding",
1026 HandleType, PH::LastStmt, PH::_0, PH::_1, PH::_2, PH::_3,
1028 .setHandleFieldOnResource(TmpVar, PH::LastStmt)
1029 .accessHandleFieldOnResource(TmpVar)
1030 .callBuiltin(
"__builtin_hlsl_resource_counterhandlefromimplicitbinding",
1031 HandleType, PH::LastStmt, PH::_5, PH::_1)
1032 .setCounterHandleFieldOnResource(TmpVar, PH::LastStmt)
1033 .returnValue(TmpVar)
1038 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1045 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1049 MMB.
addParam(
"other", ConstRecordRefType)
1051 .
assign(PH::Handle, PH::LastStmt);
1053 if (getResourceCounterHandleField())
1061 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1069 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1072 MMB.
addParam(
"other", ConstRecordRefType)
1074 .
assign(PH::Handle, PH::LastStmt);
1076 if (getResourceCounterHandleField())
1089 if (getResourceAttrs().ResourceClass == llvm::dxil::ResourceClass::UAV)
1096 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1107FieldDecl *BuiltinTypeDeclBuilder::getResourceHandleField()
const {
1108 auto I = Fields.find(
"__handle");
1109 assert(I != Fields.end() &&
1110 I->second->getType()->isHLSLAttributedResourceType() &&
1111 "record does not have resource handle field");
1115FieldDecl *BuiltinTypeDeclBuilder::getResourceCounterHandleField()
const {
1116 auto I = Fields.find(
"__counter_handle");
1117 if (I == Fields.end() ||
1118 !I->second->getType()->isHLSLAttributedResourceType())
1123QualType BuiltinTypeDeclBuilder::getFirstTemplateTypeParam() {
1124 assert(
Template &&
"record it not a template");
1125 if (
const auto *TTD = dyn_cast<TemplateTypeParmDecl>(
1126 Template->getTemplateParameters()->getParam(0))) {
1127 return QualType(TTD->getTypeForDecl(), 0);
1132QualType BuiltinTypeDeclBuilder::getHandleElementType() {
1134 return getFirstTemplateTypeParam();
1136 return SemaRef.getASTContext().Char8Ty;
1139HLSLAttributedResourceType::Attributes
1140BuiltinTypeDeclBuilder::getResourceAttrs()
const {
1141 QualType HandleType = getResourceHandleField()->getType();
1146 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1147 assert(Record->isBeingDefined() &&
1148 "Definition must be started before completing it.");
1150 Record->completeDefinition();
1154Expr *BuiltinTypeDeclBuilder::getConstantIntExpr(
int value) {
1164 if (Record->isCompleteDefinition()) {
1165 assert(Template &&
"existing record it not a template");
1166 assert(Template->getTemplateParameters()->size() == Names.size() &&
1167 "template param count mismatch");
1172 for (StringRef Name : Names)
1173 Builder.addTypeParameter(Name);
1174 return Builder.finalizeTemplateArgs(CD);
1178 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1180 SemaRef.getASTContext().UnsignedIntTy)
1181 .callBuiltin(
"__builtin_hlsl_buffer_update_counter",
QualType(),
1182 PH::CounterHandle, getConstantIntExpr(1))
1187 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1189 SemaRef.getASTContext().UnsignedIntTy)
1190 .callBuiltin(
"__builtin_hlsl_buffer_update_counter",
QualType(),
1191 PH::CounterHandle, getConstantIntExpr(-1))
1197 bool IsConst,
bool IsRef) {
1198 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1200 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1202 QualType ElemTy = getHandleElementType();
1209 ReturnTy = AddrSpaceElemTy;
1221 .callBuiltin(
"__builtin_hlsl_resource_getpointer", ElemPtrTy, PH::Handle,
1223 .dereference(PH::LastStmt)
1228 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1230 QualType ElemTy = getHandleElementType();
1234 .addParam(
"value", ElemTy)
1235 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", AST.
UnsignedIntTy,
1236 PH::CounterHandle, getConstantIntExpr(1))
1237 .callBuiltin(
"__builtin_hlsl_resource_getpointer",
1240 .dereference(PH::LastStmt)
1241 .assign(PH::LastStmt, PH::_0)
1246 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1248 QualType ElemTy = getHandleElementType();
1252 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", AST.
UnsignedIntTy,
1253 PH::CounterHandle, getConstantIntExpr(-1))
1254 .callBuiltin(
"__builtin_hlsl_resource_getpointer",
1257 .dereference(PH::LastStmt)
Defines the clang::ASTContext interface.
llvm::dxil::ResourceClass ResourceClass
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
llvm::MachO::Record Record
This file declares semantic analysis for HLSL constructs.
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
QualType getTypeDeclType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypeDecl *Decl) const
CanQualType UnsignedIntTy
a trap message and trap category.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
DeclarationNameTable DeclarationNames
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
QualType getTypeDeclType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier Qualifier, const TypeDecl *Decl) const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
CanQualType UnsignedIntTy
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
CanQualType getCanonicalTagType(const TagDecl *TD) const
Attr - This represents one attribute.
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
static CXXConstructExpr * Create(const ASTContext &Ctx, QualType Ty, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr * > Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, CXXConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
Create a C++ construction expression.
Represents a C++ constructor within a class.
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, ExplicitSpecifier ES, bool UsesFPIntrin, bool isInline, bool isImplicitlyDeclared, ConstexprSpecKind ConstexprKind, InheritedConstructor Inherited=InheritedConstructor(), const AssociatedConstraint &TrailingRequiresClause={})
Represents a static or instance method of a struct/union/class.
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin, bool isInline, ConstexprSpecKind ConstexprKind, SourceLocation EndLocation, const AssociatedConstraint &TrailingRequiresClause={})
Represents a C++ struct/union/class.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr)
Represents the this expression in C++.
static CXXThisExpr * Create(const ASTContext &Ctx, SourceLocation L, QualType Ty, bool IsImplicit)
static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)
Create a call expression.
QualType withConst() const
Retrieves a version of this type with const applied.
static ClassTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a class template node.
static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt * > Stmts, FPOptionsOverride FPFeatures, SourceLocation LB, SourceLocation RB)
Declaration of a C++20 concept.
A reference to a concept and its template args, as it appears in the code.
static ConceptReference * Create(const ASTContext &C, NestedNameSpecifierLoc NNS, SourceLocation TemplateKWLoc, DeclarationNameInfo ConceptNameInfo, NamedDecl *FoundDecl, TemplateDecl *NamedConcept, const ASTTemplateArgumentListInfo *ArgsAsWritten)
Represents the specialization of a concept - evaluates to a prvalue of type bool.
static ConceptSpecializationExpr * Create(const ASTContext &C, ConceptReference *ConceptRef, ImplicitConceptSpecializationDecl *SpecDecl, const ConstraintSatisfaction *Satisfaction)
The result of a constraint satisfaction check, containing the necessary information to diagnose an un...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
A reference to a declared variable, function, enum, etc.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)
DeclStmt - Adaptor class for mixing declarations with statements and expressions.
Decl - This represents one declaration (or definition), e.g.
The name of a declaration.
Store information needed for an explicit specifier.
This represents one expression.
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
Represents a function declaration or definition.
QualType getReturnType() const
DeclarationNameInfo getNameInfo() const
One of these records is kept for each identifier that is lexed.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
static ImplicitConceptSpecializationDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation SL, ArrayRef< TemplateArgument > ConvertedArgs)
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.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
static MemberExpr * CreateImplicit(const ASTContext &C, Expr *Base, bool IsArrow, ValueDecl *MemberDecl, QualType T, ExprValueKind VK, ExprObjectKind OK)
Create an implicit MemberExpr, with no location, qualifier, template arguments, and so on.
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.
Represent a C++ namespace.
A C++ nested-name-specifier augmented with source location information.
Represents a parameter to a function.
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
A (possibly-)qualified type.
QualType withConst() const
void addConst()
Add the const type qualifier to this QualType.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
static ReturnStmt * Create(const ASTContext &Ctx, SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate)
Create a return statement.
unsigned getDepth() const
Returns the depth of this scope. The translation-unit has scope depth 0.
Sema - This implements semantic analysis and AST building for C.
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc, NamedDecl *TemplateParam=nullptr)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
Scope * getCurScope() const
Retrieve the parser's current scope.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
@ LookupTagName
Tag name lookup, which finds the names of enums, classes, structs, and unions.
ASTContext & getASTContext() const
Encodes a location in the source.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
A convenient class for passing around template argument information.
void addArgument(const TemplateArgumentLoc &Loc)
Location wrapper for a TemplateArgument.
Represents a template argument.
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
NamedDecl * getParam(unsigned Idx)
static TemplateParameterList * Create(const ASTContext &C, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ArrayRef< NamedDecl * > Params, SourceLocation RAngleLoc, Expr *RequiresClause)
Declaration of a template type parameter.
static TemplateTypeParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation KeyLoc, SourceLocation NameLoc, unsigned D, unsigned P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, UnsignedOrNone NumExpanded=std::nullopt)
A container of type source information.
The base class of the type hierarchy.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isRecordType() const
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
Represents a variable declaration or definition.
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
friend struct BuiltinTypeMethodBuilder
BuiltinTypeDeclBuilder(Sema &SemaRef, CXXRecordDecl *R)
BuiltinTypeDeclBuilder & addSimpleTemplateParams(ArrayRef< StringRef > Names, ConceptDecl *CD)
BuiltinTypeDeclBuilder & addMemberVariable(StringRef Name, QualType Type, llvm::ArrayRef< Attr * > Attrs, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addConsumeMethod()
~BuiltinTypeDeclBuilder()
BuiltinTypeDeclBuilder & addHandleAccessFunction(DeclarationName &Name, bool IsConst, bool IsRef)
friend struct TemplateParameterListBuilder
BuiltinTypeDeclBuilder & addArraySubscriptOperators()
BuiltinTypeDeclBuilder & completeDefinition()
BuiltinTypeDeclBuilder & addBufferHandles(ResourceClass RC, bool IsROV, bool RawBuffer, bool HasCounter, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addAppendMethod()
BuiltinTypeDeclBuilder & addIncrementCounterMethod()
BuiltinTypeDeclBuilder & addCopyAssignmentOperator()
BuiltinTypeDeclBuilder & addCopyConstructor()
BuiltinTypeDeclBuilder & addStaticInitializationFunctions(bool HasCounter)
BuiltinTypeDeclBuilder & addDefaultHandleConstructor()
BuiltinTypeDeclBuilder & addDecrementCounterMethod()
BuiltinTypeDeclBuilder & addLoadMethods()
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
@ ICIS_NoInit
No in-class initializer.
@ OK_Ordinary
An ordinary object is located at an address in memory.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
nullptr
This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...
StorageClass
Storage classes.
@ Result
The result type of a method or function.
const FunctionProtoType * T
@ Template
We are parsing a template declaration.
bool CreateHLSLAttributedResourceType(Sema &S, QualType Wrapped, ArrayRef< const Attr * > AttrList, QualType &ResType, HLSLAttributedResourceLocInfo *LocInfo=nullptr)
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
U cast(CodeGen::Address addr)
@ Other
Other implicit parameter.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
static const ASTTemplateArgumentListInfo * Create(const ASTContext &C, const TemplateArgumentListInfo &List)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
Extra information about a function prototype.
BuiltinTypeMethodBuilder & addParam(StringRef Name, QualType Ty, HLSLParamModifierAttr::Spelling Modifier=HLSLParamModifierAttr::Keyword_in)
Expr * getResourceHandleExpr()
BuiltinTypeMethodBuilder & accessHandleFieldOnResource(T ResourceRecord)
BuiltinTypeDeclBuilder & finalize()
Expr * getResourceCounterHandleExpr()
BuiltinTypeMethodBuilder & operator=(const BuiltinTypeMethodBuilder &Other)=delete
BuiltinTypeMethodBuilder & returnThis()
BuiltinTypeMethodBuilder & callBuiltin(StringRef BuiltinName, QualType ReturnType, Ts... ArgSpecs)
BuiltinTypeMethodBuilder & dereference(T Ptr)
~BuiltinTypeMethodBuilder()
BuiltinTypeMethodBuilder & declareLocalVar(LocalVar &Var)
BuiltinTypeMethodBuilder & assign(TLHS LHS, TRHS RHS)
BuiltinTypeMethodBuilder(const BuiltinTypeMethodBuilder &Other)=delete
BuiltinTypeMethodBuilder & accessCounterHandleFieldOnResource(T ResourceRecord)
BuiltinTypeMethodBuilder & setCounterHandleFieldOnResource(ResourceT ResourceRecord, ValueT HandleValue)
BuiltinTypeMethodBuilder & setHandleFieldOnResource(ResourceT ResourceRecord, ValueT HandleValue)
friend BuiltinTypeDeclBuilder
BuiltinTypeMethodBuilder & returnValue(T ReturnValue)
BuiltinTypeMethodBuilder(BuiltinTypeDeclBuilder &DB, DeclarationName &Name, QualType ReturnTy, bool IsConst=false, bool IsCtor=false, StorageClass SC=SC_None)
TemplateParameterListBuilder & addTypeParameter(StringRef Name, QualType DefaultValue=QualType())
BuiltinTypeDeclBuilder & finalizeTemplateArgs(ConceptDecl *CD=nullptr)
llvm::SmallVector< NamedDecl * > Params
~TemplateParameterListBuilder()
TemplateParameterListBuilder(BuiltinTypeDeclBuilder &RB)
ConceptSpecializationExpr * constructConceptSpecializationExpr(Sema &S, ConceptDecl *CD)
BuiltinTypeDeclBuilder & Builder