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 { _0, _1, _2, _3, _4, Handle = 128, LastStmt };
143 Expr *convertPlaceholder(PlaceHolder PH);
144 Expr *convertPlaceholder(LocalVar &Var);
145 Expr *convertPlaceholder(
Expr *E) {
return E; }
151 QualType ReturnTy,
bool IsConst =
false,
153 : DeclBuilder(DB), Name(Name), ReturnTy(ReturnTy), Method(
nullptr),
154 IsConst(IsConst), IsCtor(IsCtor), SC(SC) {}
157 QualType ReturnTy,
bool IsConst =
false,
167 HLSLParamModifierAttr::Spelling Modifier =
168 HLSLParamModifierAttr::Keyword_in);
170 template <
typename... Ts>
172 QualType ReturnType, Ts... ArgSpecs);
173 template <
typename TLHS,
typename TRHS>
176 template <
typename T>
178 template <
typename ResourceT,
typename ValueT>
191 void ensureCompleteDecl() {
204 assert(!
Builder.Record->isCompleteDefinition() &&
205 "record is already complete");
207 unsigned Position =
static_cast<unsigned>(
Params.size());
211 &AST.
Idents.
get(Name, tok::TokenKind::identifier),
215 if (!DefaultValue.
isNull())
216 Decl->setDefaultArgument(AST,
217 Builder.SemaRef.getTrivialTemplateArgumentLoc(
259 "unexpected concept decl parameter count");
268 Builder.Record->getDeclContext(),
278 T->setDeclContext(DC);
280 QualType ConceptTType = Context.getTypeDeclType(ConceptTTPD);
286 QualType CSETType = Context.getTypeDeclType(
T);
294 Context,
Builder.Record->getDeclContext(), Loc, {CSETA});
334 Builder.Template->setImplicit(
true);
335 Builder.Template->setLexicalDeclContext(
Builder.Record->getDeclContext());
346Expr *BuiltinTypeMethodBuilder::convertPlaceholder(PlaceHolder PH) {
347 if (PH == PlaceHolder::Handle)
350 if (PH == PlaceHolder::LastStmt) {
351 assert(!StmtsList.empty() &&
"no statements in the list");
352 Stmt *LastStmt = StmtsList.pop_back_val();
353 assert(
isa<ValueStmt>(LastStmt) &&
"last statement does not have a value");
365Expr *BuiltinTypeMethodBuilder::convertPlaceholder(LocalVar &Var) {
366 VarDecl *VD = Var.Decl;
367 assert(VD &&
"local variable is not declared");
369 VD->getASTContext(), NestedNameSpecifierLoc(), SourceLocation(), VD,
370 false, DeclarationNameInfo(VD->getDeclName(), SourceLocation()),
377 bool IsConst,
bool IsCtor,
379 : DeclBuilder(DB), ReturnTy(ReturnTy), Method(
nullptr), IsConst(IsConst),
380 IsCtor(IsCtor), SC(SC) {
382 assert((!NameStr.empty() || IsCtor) &&
"method needs a name");
383 assert(((IsCtor && !IsConst) || !IsCtor) &&
"constructor cannot be const");
391 AST.
Idents.
get(NameStr, tok::TokenKind::identifier);
398 HLSLParamModifierAttr::Spelling Modifier) {
399 assert(Method ==
nullptr &&
"Cannot add param, method already created");
400 const IdentifierInfo &II = DeclBuilder.SemaRef.getASTContext().Idents.get(
401 Name, tok::TokenKind::identifier);
402 Params.emplace_back(II, Ty, Modifier);
406void BuiltinTypeMethodBuilder::createDecl() {
407 assert(
Method ==
nullptr &&
"Method or constructor is already created");
412 for (Param &MP : Params)
413 ParamTypes.emplace_back(MP.Ty);
426 AST, DeclBuilder.Record,
SourceLocation(), NameInfo, FuncTy, TSInfo,
431 AST, DeclBuilder.Record,
SourceLocation(), NameInfo, FuncTy, TSInfo, SC,
439 for (
int I = 0, E = Params.size(); I != E; I++) {
440 Param &MP = Params[I];
446 if (MP.Modifier != HLSLParamModifierAttr::Keyword_in) {
448 HLSLParamModifierAttr::Create(AST,
SourceRange(), MP.Modifier);
452 ParmDecls.push_back(Parm);
453 FnProtoLoc.setParam(I, Parm);
455 Method->setParams({ParmDecls});
459 ensureCompleteDecl();
461 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
463 AST,
SourceLocation(), Method->getFunctionObjectParameterType(),
true);
464 FieldDecl *HandleField = DeclBuilder.getResourceHandleField();
472 ensureCompleteDecl();
474 assert(Var.Decl ==
nullptr &&
"local variable is already declared");
476 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
479 &AST.
Idents.
get(Var.Name, tok::TokenKind::identifier), Var.Ty,
483 StmtsList.push_back(DS);
488 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
492 StmtsList.push_back(ThisExpr);
496template <
typename... Ts>
499 QualType ReturnType, Ts... ArgSpecs) {
500 ensureCompleteDecl();
502 std::array<
Expr *,
sizeof...(ArgSpecs)> Args{
503 convertPlaceholder(std::forward<Ts>(ArgSpecs))...};
505 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
506 FunctionDecl *FD = lookupBuiltinFunction(DeclBuilder.SemaRef, BuiltinName);
520 StmtsList.push_back(
Call);
524template <
typename TLHS,
typename TRHS>
526 Expr *LHSExpr = convertPlaceholder(LHS);
527 Expr *RHSExpr = convertPlaceholder(RHS);
529 DeclBuilder.SemaRef.getASTContext(), LHSExpr, RHSExpr, BO_Assign,
532 StmtsList.push_back(AssignStmt);
538 Expr *PtrExpr = convertPlaceholder(Ptr);
544 StmtsList.push_back(Deref);
551 ensureCompleteDecl();
553 Expr *ResourceExpr = convertPlaceholder(ResourceRecord);
555 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
556 FieldDecl *HandleField = DeclBuilder.getResourceHandleField();
560 StmtsList.push_back(HandleExpr);
564template <
typename ResourceT,
typename ValueT>
567 ValueT HandleValue) {
568 ensureCompleteDecl();
570 Expr *ResourceExpr = convertPlaceholder(ResourceRecord);
571 Expr *HandleValueExpr = convertPlaceholder(HandleValue);
573 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
574 FieldDecl *HandleField = DeclBuilder.getResourceHandleField();
579 DeclBuilder.SemaRef.getASTContext(), HandleMemberExpr, HandleValueExpr,
582 StmtsList.push_back(AssignStmt);
588 ensureCompleteDecl();
590 Expr *ReturnValueExpr = convertPlaceholder(ReturnValue);
591 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
601 assert(CD &&
"no copy constructor found");
615 assert(!DeclBuilder.Record->isCompleteDefinition() &&
616 "record is already complete");
618 ensureCompleteDecl();
620 if (!Method->hasBody()) {
621 ASTContext &AST = DeclBuilder.SemaRef.getASTContext();
622 assert((ReturnTy == AST.
VoidTy || !StmtsList.empty()) &&
623 "nothing to return from non-void method");
624 if (ReturnTy != AST.
VoidTy) {
625 if (
Expr *LastExpr = dyn_cast<Expr>(StmtsList.back())) {
627 ReturnTy.getNonReferenceType()) &&
628 "Return type of the last statement must match the return type "
631 StmtsList.pop_back();
640 Method->setLexicalDeclContext(DeclBuilder.Record);
642 Method->addAttr(AlwaysInlineAttr::CreateImplicit(
643 AST,
SourceRange(), AlwaysInlineAttr::CXX11_clang_always_inline));
644 DeclBuilder.Record->addDecl(Method);
650 : SemaRef(SemaRef), Record(R) {
651 Record->startDefinition();
652 Template = Record->getDescribedClassTemplate();
658 : SemaRef(SemaRef), HLSLNamespace(Namespace) {
664 if (SemaRef.LookupQualifiedName(
Result, HLSLNamespace)) {
667 if (
auto *TD = dyn_cast<ClassTemplateDecl>(
Found)) {
668 PrevDecl = TD->getTemplatedDecl();
671 PrevDecl = dyn_cast<CXXRecordDecl>(
Found);
672 assert(PrevDecl &&
"Unexpected lookup result type.");
677 Template = PrevTemplate;
684 Record->setImplicit(
true);
685 Record->setLexicalDeclContext(HLSLNamespace);
686 Record->setHasExternalLexicalStorage();
690 FinalAttr::CreateImplicit(AST,
SourceRange(), FinalAttr::Keyword_final));
694 if (HLSLNamespace && !Template && Record->getDeclContext() == HLSLNamespace)
695 HLSLNamespace->addDecl(Record);
702 assert(!Record->isCompleteDefinition() &&
"record is already complete");
703 assert(Record->isBeingDefined() &&
704 "Definition must be started before adding members!");
713 Field->setAccess(Access);
714 Field->setImplicit(
true);
715 for (
Attr *A : Attrs) {
720 Record->addDecl(Field);
721 Fields[Name] = Field;
726 ResourceClass RC,
bool IsROV,
bool RawBuffer,
AccessSpecifier Access) {
727 assert(!Record->isCompleteDefinition() &&
"record is already complete");
736 HLSLResourceClassAttr::CreateImplicit(Ctx, RC),
737 IsROV ? HLSLROVAttr::CreateImplicit(Ctx) :
nullptr,
738 RawBuffer ? HLSLRawBufferAttr::CreateImplicit(Ctx) :
nullptr,
740 ? HLSLContainedTypeAttr::CreateImplicit(Ctx, ElementTypeInfo)
751 assert(!Record->isCompleteDefinition() &&
"record is already complete");
753 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
754 QualType HandleType = getResourceHandleField()->getType();
757 .callBuiltin(
"__builtin_hlsl_resource_uninitializedhandle", HandleType,
759 .assign(PH::Handle, PH::LastStmt)
775 assert(!Record->isCompleteDefinition() &&
"record is already complete");
777 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
779 QualType HandleType = getResourceHandleField()->getType();
781 BuiltinTypeMethodBuilder::LocalVar TmpVar(
"tmp", RecordType);
787 .addParam(
"range", AST.
IntTy)
790 .declareLocalVar(TmpVar)
791 .accessHandleFieldOnResource(TmpVar)
792 .callBuiltin(
"__builtin_hlsl_resource_handlefrombinding", HandleType,
793 PH::LastStmt, PH::_0, PH::_1, PH::_2, PH::_3, PH::_4)
794 .setHandleFieldOnResource(TmpVar, PH::LastStmt)
812 assert(!Record->isCompleteDefinition() &&
"record is already complete");
814 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
816 QualType HandleType = getResourceHandleField()->getType();
818 BuiltinTypeMethodBuilder::LocalVar TmpVar(
"tmp", RecordType);
824 .addParam(
"range", AST.
IntTy)
827 .declareLocalVar(TmpVar)
828 .accessHandleFieldOnResource(TmpVar)
829 .callBuiltin(
"__builtin_hlsl_resource_handlefromimplicitbinding",
830 HandleType, PH::LastStmt, PH::_0, PH::_1, PH::_2, PH::_3,
832 .setHandleFieldOnResource(TmpVar, PH::LastStmt)
838 assert(!Record->isCompleteDefinition() &&
"record is already complete");
845 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
849 .addParam(
"other", ConstRecordRefType)
850 .accessHandleFieldOnResource(PH::_0)
851 .assign(PH::Handle, PH::LastStmt)
856 assert(!Record->isCompleteDefinition() &&
"record is already complete");
864 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
867 .addParam(
"other", ConstRecordRefType)
868 .accessHandleFieldOnResource(PH::_0)
869 .assign(PH::Handle, PH::LastStmt)
880 if (getResourceAttrs().ResourceClass == llvm::dxil::ResourceClass::UAV)
887 assert(!Record->isCompleteDefinition() &&
"record is already complete");
898FieldDecl *BuiltinTypeDeclBuilder::getResourceHandleField()
const {
899 auto I = Fields.find(
"__handle");
900 assert(I != Fields.end() &&
901 I->second->getType()->isHLSLAttributedResourceType() &&
902 "record does not have resource handle field");
906QualType BuiltinTypeDeclBuilder::getFirstTemplateTypeParam() {
907 assert(
Template &&
"record it not a template");
908 if (
const auto *TTD = dyn_cast<TemplateTypeParmDecl>(
909 Template->getTemplateParameters()->getParam(0))) {
910 return QualType(TTD->getTypeForDecl(), 0);
915QualType BuiltinTypeDeclBuilder::getHandleElementType() {
917 return getFirstTemplateTypeParam();
919 return SemaRef.getASTContext().Char8Ty;
922HLSLAttributedResourceType::Attributes
923BuiltinTypeDeclBuilder::getResourceAttrs()
const {
924 QualType HandleType = getResourceHandleField()->getType();
929 assert(!Record->isCompleteDefinition() &&
"record is already complete");
930 assert(Record->isBeingDefined() &&
931 "Definition must be started before completing it.");
933 Record->completeDefinition();
937Expr *BuiltinTypeDeclBuilder::getConstantIntExpr(
int value) {
947 if (Record->isCompleteDefinition()) {
948 assert(Template &&
"existing record it not a template");
949 assert(Template->getTemplateParameters()->size() == Names.size() &&
950 "template param count mismatch");
955 for (StringRef Name : Names)
956 Builder.addTypeParameter(Name);
957 return Builder.finalizeTemplateArgs(CD);
961 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
963 SemaRef.getASTContext().UnsignedIntTy)
964 .callBuiltin(
"__builtin_hlsl_buffer_update_counter",
QualType(),
965 PH::Handle, getConstantIntExpr(1))
970 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
972 SemaRef.getASTContext().UnsignedIntTy)
973 .callBuiltin(
"__builtin_hlsl_buffer_update_counter",
QualType(),
974 PH::Handle, getConstantIntExpr(-1))
980 bool IsConst,
bool IsRef) {
981 assert(!Record->isCompleteDefinition() &&
"record is already complete");
983 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
985 QualType ElemTy = getHandleElementType();
992 ReturnTy = AddrSpaceElemTy;
1004 .callBuiltin(
"__builtin_hlsl_resource_getpointer", ElemPtrTy, PH::Handle,
1006 .dereference(PH::LastStmt)
1011 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1013 QualType ElemTy = getHandleElementType();
1017 .addParam(
"value", ElemTy)
1018 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", AST.
UnsignedIntTy,
1019 PH::Handle, getConstantIntExpr(1))
1020 .callBuiltin(
"__builtin_hlsl_resource_getpointer",
1023 .dereference(PH::LastStmt)
1024 .assign(PH::LastStmt, PH::_0)
1029 using PH = BuiltinTypeMethodBuilder::PlaceHolder;
1031 QualType ElemTy = getHandleElementType();
1035 .callBuiltin(
"__builtin_hlsl_buffer_update_counter", AST.
UnsignedIntTy,
1036 PH::Handle, getConstantIntExpr(-1))
1037 .callBuiltin(
"__builtin_hlsl_resource_getpointer",
1040 .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 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 & addCreateFromBinding()
BuiltinTypeDeclBuilder & addConsumeMethod()
~BuiltinTypeDeclBuilder()
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_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()
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