26#include "llvm/ADT/SmallVector.h"
28using namespace llvm::hlsl;
36static FunctionDecl *lookupBuiltinFunction(Sema &S, StringRef Name) {
38 S.getASTContext().Idents.get(Name, tok::TokenKind::identifier);
39 DeclarationNameInfo NameInfo =
40 DeclarationNameInfo(DeclarationName(&II), SourceLocation());
44 S.LookupName(R, S.getCurScope());
47 assert(R.isSingleResult() &&
48 "Since this is a builtin it should always resolve!");
100 HLSLParamModifierAttr::Spelling Modifier;
102 HLSLParamModifierAttr::Spelling Modifier)
103 : NameII(NameII), Ty(Ty), Modifier(Modifier) {}
110 LocalVar(StringRef Name,
QualType Ty) : Name(Name), Ty(Ty),
Decl(
nullptr) {}
132 enum class PlaceHolder { _0, _1, _2, _3, _4, Handle = 128, LastStmt };
134 Expr *convertPlaceholder(PlaceHolder PH);
135 Expr *convertPlaceholder(LocalVar &Var);
136 Expr *convertPlaceholder(
Expr *E) {
return E; }
142 QualType ReturnTy,
bool IsConst =
false,
144 : DeclBuilder(DB), Name(Name), ReturnTy(ReturnTy), Method(
nullptr),
145 IsConst(IsConst), IsCtor(IsCtor), SC(SC) {}
148 QualType ReturnTy,
bool IsConst =
false,
158 HLSLParamModifierAttr::Spelling Modifier =
159 HLSLParamModifierAttr::Keyword_in);
161 template <
typename... Ts>
163 QualType ReturnType, Ts... ArgSpecs);
164 template <
typename TLHS,
typename TRHS>
167 template <
typename T>
169 template <
typename ResourceT,
typename ValueT>
182 void ensureCompleteDecl() {
195 assert(!
Builder.Record->isCompleteDefinition() &&
196 "record is already complete");
198 unsigned Position =
static_cast<unsigned>(
Params.size());
202 &AST.
Idents.
get(Name, tok::TokenKind::identifier),
206 if (!DefaultValue.
isNull())
207 Decl->setDefaultArgument(AST,
208 Builder.SemaRef.getTrivialTemplateArgumentLoc(
250 "unexpected concept decl parameter count");
259 Builder.Record->getDeclContext(),
269 T->setDeclContext(DC);
271 QualType ConceptTType = Context.getTypeDeclType(ConceptTTPD);
277 QualType CSETType = Context.getTypeDeclType(
T);
285 Context,
Builder.Record->getDeclContext(), Loc, {CSETA});
325 Builder.Template->setImplicit(
true);
326 Builder.Template->setLexicalDeclContext(
Builder.Record->getDeclContext());
337Expr *BuiltinTypeMethodBuilder::convertPlaceholder(PlaceHolder PH) {
338 if (PH == PlaceHolder::Handle)
341 if (PH == PlaceHolder::LastStmt) {
342 assert(!StmtsList.empty() &&
"no statements in the list");
343 Stmt *LastStmt = StmtsList.pop_back_val();
344 assert(
isa<ValueStmt>(LastStmt) &&
"last statement does not have a value");
356Expr *BuiltinTypeMethodBuilder::convertPlaceholder(LocalVar &Var) {
357 VarDecl *VD = Var.Decl;
358 assert(VD &&
"local variable is not declared");
360 VD->getASTContext(), NestedNameSpecifierLoc(), SourceLocation(), VD,
361 false, DeclarationNameInfo(VD->getDeclName(), SourceLocation()),
368 bool IsConst,
bool IsCtor,
370 : DeclBuilder(DB), ReturnTy(ReturnTy), Method(
nullptr), IsConst(IsConst),
371 IsCtor(IsCtor), SC(SC) {
373 assert((!NameStr.empty() || IsCtor) &&
"method needs a name");
374 assert(((IsCtor && !IsConst) || !IsCtor) &&
"constructor cannot be const");
382 AST.
Idents.
get(NameStr, tok::TokenKind::identifier);
389 HLSLParamModifierAttr::Spelling Modifier) {
390 assert(Method ==
nullptr &&
"Cannot add param, method already created");
391 const IdentifierInfo &II = DeclBuilder.SemaRef.getASTContext().Idents.get(
392 Name, tok::TokenKind::identifier);
393 Params.emplace_back(II, Ty, Modifier);
397void BuiltinTypeMethodBuilder::createDecl() {
398 assert(
Method ==
nullptr &&
"Method or constructor is already created");
403 for (Param &MP : Params)
404 ParamTypes.emplace_back(MP.Ty);
417 AST, DeclBuilder.Record,
SourceLocation(), NameInfo, FuncTy, TSInfo,
422 AST, DeclBuilder.Record,
SourceLocation(), NameInfo, FuncTy, TSInfo, SC,
430 for (
int I = 0, E = Params.size(); I != E; I++) {
431 Param &MP = Params[I];
437 if (MP.Modifier != HLSLParamModifierAttr::Keyword_in) {
439 HLSLParamModifierAttr::Create(AST,
SourceRange(), MP.Modifier);
443 ParmDecls.push_back(Parm);
444 FnProtoLoc.setParam(I, Parm);
446 Method->setParams({ParmDecls});
450 ensureCompleteDecl();
452 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
454 AST,
SourceLocation(), Method->getFunctionObjectParameterType(),
true);
455 FieldDecl *HandleField = DeclBuilder.getResourceHandleField();
463 ensureCompleteDecl();
465 assert(Var.Decl ==
nullptr &&
"local variable is already declared");
467 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
470 &AST.
Idents.
get(Var.Name, tok::TokenKind::identifier), Var.Ty,
474 StmtsList.push_back(DS);
479 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
483 StmtsList.push_back(ThisExpr);
487template <
typename... Ts>
490 QualType ReturnType, Ts... ArgSpecs) {
491 ensureCompleteDecl();
493 std::array<
Expr *,
sizeof...(ArgSpecs)> Args{
494 convertPlaceholder(std::forward<Ts>(ArgSpecs))...};
496 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
497 FunctionDecl *FD = lookupBuiltinFunction(DeclBuilder.SemaRef, BuiltinName);
511 StmtsList.push_back(
Call);
515template <
typename TLHS,
typename TRHS>
517 Expr *LHSExpr = convertPlaceholder(LHS);
518 Expr *RHSExpr = convertPlaceholder(RHS);
520 DeclBuilder.SemaRef.getASTContext(), LHSExpr, RHSExpr, BO_Assign,
523 StmtsList.push_back(AssignStmt);
529 Expr *PtrExpr = convertPlaceholder(Ptr);
535 StmtsList.push_back(Deref);
542 ensureCompleteDecl();
544 Expr *ResourceExpr = convertPlaceholder(ResourceRecord);
546 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
547 FieldDecl *HandleField = DeclBuilder.getResourceHandleField();
551 StmtsList.push_back(HandleExpr);
555template <
typename ResourceT,
typename ValueT>
558 ValueT HandleValue) {
559 ensureCompleteDecl();
561 Expr *ResourceExpr = convertPlaceholder(ResourceRecord);
562 Expr *HandleValueExpr = convertPlaceholder(HandleValue);
564 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
565 FieldDecl *HandleField = DeclBuilder.getResourceHandleField();
570 DeclBuilder.SemaRef.getASTContext(), HandleMemberExpr, HandleValueExpr,
573 StmtsList.push_back(AssignStmt);
579 ensureCompleteDecl();
581 Expr *ReturnValueExpr = convertPlaceholder(ReturnValue);
582 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
589 assert(!DeclBuilder.Record->isCompleteDefinition() &&
590 "record is already complete");
592 ensureCompleteDecl();
594 if (!Method->hasBody()) {
595 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
596 assert((ReturnTy == AST.
VoidTy || !StmtsList.empty()) &&
597 "nothing to return from non-void method");
598 if (ReturnTy != AST.
VoidTy) {
599 if (
Expr *LastExpr = dyn_cast<Expr>(StmtsList.back())) {
601 ReturnTy.getNonReferenceType()) &&
602 "Return type of the last statement must match the return type "
605 StmtsList.pop_back();
614 Method->setLexicalDeclContext(DeclBuilder.Record);
616 Method->addAttr(AlwaysInlineAttr::CreateImplicit(
617 AST,
SourceRange(), AlwaysInlineAttr::CXX11_clang_always_inline));
618 DeclBuilder.Record->addDecl(Method);
624 : SemaRef(SemaRef), Record(R) {
625 Record->startDefinition();
626 Template = Record->getDescribedClassTemplate();
632 : SemaRef(SemaRef), HLSLNamespace(Namespace) {
638 if (SemaRef.LookupQualifiedName(
Result, HLSLNamespace)) {
641 if (
auto *TD = dyn_cast<ClassTemplateDecl>(
Found)) {
642 PrevDecl = TD->getTemplatedDecl();
645 PrevDecl = dyn_cast<CXXRecordDecl>(
Found);
646 assert(PrevDecl &&
"Unexpected lookup result type.");
651 Template = PrevTemplate;
658 Record->setImplicit(
true);
659 Record->setLexicalDeclContext(HLSLNamespace);
660 Record->setHasExternalLexicalStorage();
664 FinalAttr::CreateImplicit(AST,
SourceRange(), FinalAttr::Keyword_final));
668 if (HLSLNamespace && !Template && Record->getDeclContext() == HLSLNamespace)
669 HLSLNamespace->addDecl(Record);
676 assert(!Record->isCompleteDefinition() &&
"record is already complete");
677 assert(Record->isBeingDefined() &&
678 "Definition must be started before adding members!");
687 Field->setAccess(Access);
688 Field->setImplicit(
true);
689 for (
Attr *A : Attrs) {
694 Record->addDecl(Field);
695 Fields[Name] = Field;
700 ResourceClass RC,
bool IsROV,
bool RawBuffer,
AccessSpecifier Access) {
701 assert(!Record->isCompleteDefinition() &&
"record is already complete");
710 HLSLResourceClassAttr::CreateImplicit(Ctx, RC),
711 IsROV ? HLSLROVAttr::CreateImplicit(Ctx) :
nullptr,
712 RawBuffer ? HLSLRawBufferAttr::CreateImplicit(Ctx) :
nullptr,
714 ? HLSLContainedTypeAttr::CreateImplicit(Ctx, ElementTypeInfo)
725 if (Record->isCompleteDefinition())
728 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
729 QualType HandleType = getResourceHandleField()->getType();
732 .callBuiltin(
"__builtin_hlsl_resource_uninitializedhandle", HandleType,
734 .assign(PH::Handle, PH::LastStmt)
740 if (Record->isCompleteDefinition())
743 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
745 QualType HandleType = getResourceHandleField()->getType();
750 .addParam(
"range", AST.
IntTy)
753 .callBuiltin(
"__builtin_hlsl_resource_handlefrombinding", HandleType,
754 PH::Handle, PH::_0, PH::_1, PH::_2, PH::_3, PH::_4)
755 .assign(PH::Handle, PH::LastStmt)
761 if (Record->isCompleteDefinition())
764 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
766 QualType HandleType = getResourceHandleField()->getType();
770 .addParam(
"range", AST.
IntTy)
774 .callBuiltin(
"__builtin_hlsl_resource_handlefromimplicitbinding",
775 HandleType, PH::Handle, PH::_3, PH::_0, PH::_1, PH::_2,
777 .assign(PH::Handle, PH::LastStmt)
793 if (Record->isCompleteDefinition())
796 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
798 QualType HandleType = getResourceHandleField()->getType();
800 BuiltinTypeMethodBuilder::LocalVar TmpVar(
"tmp", RecordType);
806 .addParam(
"range", AST.
IntTy)
809 .declareLocalVar(TmpVar)
810 .accessHandleFieldOnResource(TmpVar)
811 .callBuiltin(
"__builtin_hlsl_resource_handlefrombinding", HandleType,
812 PH::LastStmt, PH::_0, PH::_1, PH::_2, PH::_3, PH::_4)
813 .setHandleFieldOnResource(TmpVar, PH::LastStmt)
831 if (Record->isCompleteDefinition())
834 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
836 QualType HandleType = getResourceHandleField()->getType();
838 BuiltinTypeMethodBuilder::LocalVar TmpVar(
"tmp", RecordType);
844 .addParam(
"range", AST.
IntTy)
847 .declareLocalVar(TmpVar)
848 .accessHandleFieldOnResource(TmpVar)
849 .callBuiltin(
"__builtin_hlsl_resource_handlefromimplicitbinding",
850 HandleType, PH::LastStmt, PH::_0, PH::_1, PH::_2, PH::_3,
852 .setHandleFieldOnResource(TmpVar, PH::LastStmt)
858 if (Record->isCompleteDefinition())
866 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
870 .addParam(
"other", ConstRecordRefType)
871 .accessHandleFieldOnResource(PH::_0)
872 .assign(PH::Handle, PH::LastStmt)
877 if (Record->isCompleteDefinition())
886 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
889 .addParam(
"other", ConstRecordRefType)
890 .accessHandleFieldOnResource(PH::_0)
891 .assign(PH::Handle, PH::LastStmt)
902 if (getResourceAttrs().ResourceClass == llvm::dxil::ResourceClass::UAV)
909 if (Record->isCompleteDefinition())
921FieldDecl *BuiltinTypeDeclBuilder::getResourceHandleField()
const {
922 auto I = Fields.find(
"__handle");
923 assert(I != Fields.end() &&
924 I->second->getType()->isHLSLAttributedResourceType() &&
925 "record does not have resource handle field");
929QualType BuiltinTypeDeclBuilder::getFirstTemplateTypeParam() {
930 assert(
Template &&
"record it not a template");
931 if (
const auto *TTD = dyn_cast<TemplateTypeParmDecl>(
932 Template->getTemplateParameters()->getParam(0))) {
933 return QualType(TTD->getTypeForDecl(), 0);
938QualType BuiltinTypeDeclBuilder::getHandleElementType() {
940 return getFirstTemplateTypeParam();
942 return SemaRef.getASTContext().Char8Ty;
945HLSLAttributedResourceType::Attributes
946BuiltinTypeDeclBuilder::getResourceAttrs()
const {
947 QualType HandleType = getResourceHandleField()->getType();
958 assert(!Record->isCompleteDefinition() &&
"record is already complete");
959 assert(Record->isBeingDefined() &&
960 "Definition must be started before completing it.");
962 Record->completeDefinition();
966Expr *BuiltinTypeDeclBuilder::getConstantIntExpr(
int value) {
976 if (Record->isCompleteDefinition()) {
977 assert(Template &&
"existing record it not a template");
978 assert(Template->getTemplateParameters()->size() == Names.size() &&
979 "template param count mismatch");
984 for (StringRef Name : Names)
985 Builder.addTypeParameter(Name);
986 return Builder.finalizeTemplateArgs(CD);
990 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
992 SemaRef.getASTContext().UnsignedIntTy)
993 .callBuiltin(
"__builtin_hlsl_buffer_update_counter",
QualType(),
994 PH::Handle, getConstantIntExpr(1))
999 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1001 SemaRef.getASTContext().UnsignedIntTy)
1002 .callBuiltin(
"__builtin_hlsl_buffer_update_counter",
QualType(),
1003 PH::Handle, getConstantIntExpr(-1))
1009 bool IsConst,
bool IsRef) {
1010 assert(!Record->isCompleteDefinition() &&
"record is already complete");
1012 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1014 QualType ElemTy = getHandleElementType();
1021 ReturnTy = AddrSpaceElemTy;
1033 .callBuiltin(
"__builtin_hlsl_resource_getpointer", ElemPtrTy, PH::Handle,
1035 .dereference(PH::LastStmt)
1040 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1042 QualType ElemTy = getHandleElementType();
1046 .addParam(
"value", ElemTy)
1047 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", AST.
UnsignedIntTy,
1048 PH::Handle, getConstantIntExpr(1))
1049 .callBuiltin(
"__builtin_hlsl_resource_getpointer",
1052 .dereference(PH::LastStmt)
1053 .assign(PH::LastStmt, PH::_0)
1058 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1060 QualType ElemTy = getHandleElementType();
1064 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", AST.
UnsignedIntTy,
1065 PH::Handle, getConstantIntExpr(-1))
1066 .callBuiltin(
"__builtin_hlsl_resource_getpointer",
1069 .dereference(PH::LastStmt)
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
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.
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 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.
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 & addHandleConstructorFromImplicitBinding()
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 & addCreateFromBinding()
BuiltinTypeDeclBuilder & addConsumeMethod()
~BuiltinTypeDeclBuilder()
BuiltinTypeDeclBuilder & addHandleConstructorFromBinding()
BuiltinTypeDeclBuilder & addHandleAccessFunction(DeclarationName &Name, bool IsConst, bool IsRef)
friend struct TemplateParameterListBuilder
BuiltinTypeDeclBuilder & addArraySubscriptOperators()
BuiltinTypeDeclBuilder & completeDefinition()
BuiltinTypeDeclBuilder & addAppendMethod()
BuiltinTypeDeclBuilder & addIncrementCounterMethod()
BuiltinTypeDeclBuilder & addCopyAssignmentOperator()
BuiltinTypeDeclBuilder & addHandleMember(ResourceClass RC, bool IsROV, bool RawBuffer, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addCopyConstructor()
BuiltinTypeDeclBuilder & addCreateFromImplicitBinding()
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_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()
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 & 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