clang 24.0.0git
HLSLExternalSemaSource.cpp
Go to the documentation of this file.
1//===--- HLSLExternalSemaSource.cpp - HLSL Sema Source --------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9//
10//===----------------------------------------------------------------------===//
11
15#include "clang/AST/Attr.h"
16#include "clang/AST/Decl.h"
17#include "clang/AST/DeclCXX.h"
19#include "clang/AST/Expr.h"
20#include "clang/AST/Type.h"
24#include "clang/Sema/Lookup.h"
25#include "clang/Sema/Sema.h"
26#include "clang/Sema/SemaHLSL.h"
28#include "llvm/ADT/STLExtras.h"
29#include "llvm/ADT/SmallVector.h"
30
31using namespace clang;
32using namespace llvm::hlsl;
33
35
37 SemaPtr = &S;
38 ASTContext &AST = SemaPtr->getASTContext();
39 // If the translation unit has external storage force external decls to load.
42
43 IdentifierInfo &HLSL = AST.Idents.get("hlsl", tok::TokenKind::identifier);
45 NamespaceDecl *PrevDecl = nullptr;
47 PrevDecl = Result.getAsSingle<NamespaceDecl>();
48 HLSLNamespace = NamespaceDecl::Create(
49 AST, AST.getTranslationUnitDecl(), /*Inline=*/false, SourceLocation(),
50 SourceLocation(), &HLSL, PrevDecl, /*Nested=*/false);
51 HLSLNamespace->setImplicit(true);
52 HLSLNamespace->setHasExternalLexicalStorage();
53 AST.getTranslationUnitDecl()->addDecl(HLSLNamespace);
54
55 // Force external decls in the HLSL namespace to load from the PCH.
56 (void)HLSLNamespace->getCanonicalDecl()->decls_begin();
57 defineTrivialHLSLTypes();
58 defineHLSLTypesWithForwardDeclarations();
59 defineHLSLAtomicIntrinsics();
60
61 // This adds a `using namespace hlsl` directive. In DXC, we don't put HLSL's
62 // built in types inside a namespace, but we are planning to change that in
63 // the near future. In order to be source compatible older versions of HLSL
64 // will need to implicitly use the hlsl namespace. For now in clang everything
65 // will get added to the namespace, and we can remove the using directive for
66 // future language versions to match HLSL's evolution.
69 NestedNameSpecifierLoc(), SourceLocation(), HLSLNamespace,
71
73}
74
75void HLSLExternalSemaSource::defineHLSLVectorAlias() {
76 ASTContext &AST = SemaPtr->getASTContext();
77
78 llvm::SmallVector<NamedDecl *> TemplateParams;
79
80 auto *TypeParam = TemplateTypeParmDecl::Create(
81 AST, HLSLNamespace, SourceLocation(), SourceLocation(), 0, 0,
82 &AST.Idents.get("element", tok::TokenKind::identifier), false, false);
83 TypeParam->setDefaultArgument(
86
87 TemplateParams.emplace_back(TypeParam);
88
89 auto *SizeParam = NonTypeTemplateParmDecl::Create(
90 AST, HLSLNamespace, SourceLocation(), SourceLocation(), 0, 1,
91 &AST.Idents.get("element_count", tok::TokenKind::identifier), AST.IntTy,
92 false, AST.getTrivialTypeSourceInfo(AST.IntTy));
93 llvm::APInt Val(AST.getIntWidth(AST.IntTy), 4);
94 TemplateArgument Default(AST, llvm::APSInt(std::move(Val)), AST.IntTy,
95 /*IsDefaulted=*/true);
96 SizeParam->setDefaultArgument(AST, SemaPtr->getTrivialTemplateArgumentLoc(
98 TemplateParams.emplace_back(SizeParam);
99
100 auto *ParamList =
102 TemplateParams, SourceLocation(), nullptr);
103
104 IdentifierInfo &II = AST.Idents.get("vector", tok::TokenKind::identifier);
105
107 AST.getTemplateTypeParmType(0, 0, false, TypeParam),
109 AST, NestedNameSpecifierLoc(), SourceLocation(), SizeParam, false,
110 DeclarationNameInfo(SizeParam->getDeclName(), SourceLocation()),
111 AST.IntTy, VK_LValue),
113
114 auto *Record = TypeAliasDecl::Create(AST, HLSLNamespace, SourceLocation(),
115 SourceLocation(), &II,
116 AST.getTrivialTypeSourceInfo(AliasType));
117 Record->setImplicit(true);
118
119 auto *Template =
120 TypeAliasTemplateDecl::Create(AST, HLSLNamespace, SourceLocation(),
121 Record->getIdentifier(), ParamList, Record);
122
123 Record->setDescribedAliasTemplate(Template);
124 Template->setImplicit(true);
125 Template->setLexicalDeclContext(Record->getDeclContext());
126 HLSLNamespace->addDecl(Template);
127}
128
129void HLSLExternalSemaSource::defineHLSLMatrixAlias() {
130 ASTContext &AST = SemaPtr->getASTContext();
131 llvm::SmallVector<NamedDecl *> TemplateParams;
132
133 auto *TypeParam = TemplateTypeParmDecl::Create(
134 AST, HLSLNamespace, SourceLocation(), SourceLocation(), 0, 0,
135 &AST.Idents.get("element", tok::TokenKind::identifier), false, false);
136 TypeParam->setDefaultArgument(
137 AST, SemaPtr->getTrivialTemplateArgumentLoc(
139
140 TemplateParams.emplace_back(TypeParam);
141
142 // these should be 64 bit to be consistent with other clang matrices.
143 auto *RowsParam = NonTypeTemplateParmDecl::Create(
144 AST, HLSLNamespace, SourceLocation(), SourceLocation(), 0, 1,
145 &AST.Idents.get("rows_count", tok::TokenKind::identifier), AST.IntTy,
146 false, AST.getTrivialTypeSourceInfo(AST.IntTy));
147 llvm::APInt RVal(AST.getIntWidth(AST.IntTy), 4);
148 TemplateArgument RDefault(AST, llvm::APSInt(std::move(RVal)), AST.IntTy,
149 /*IsDefaulted=*/true);
150 RowsParam->setDefaultArgument(
151 AST, SemaPtr->getTrivialTemplateArgumentLoc(RDefault, AST.IntTy,
152 SourceLocation()));
153 TemplateParams.emplace_back(RowsParam);
154
155 auto *ColsParam = NonTypeTemplateParmDecl::Create(
156 AST, HLSLNamespace, SourceLocation(), SourceLocation(), 0, 2,
157 &AST.Idents.get("cols_count", tok::TokenKind::identifier), AST.IntTy,
158 false, AST.getTrivialTypeSourceInfo(AST.IntTy));
159 llvm::APInt CVal(AST.getIntWidth(AST.IntTy), 4);
160 TemplateArgument CDefault(AST, llvm::APSInt(std::move(CVal)), AST.IntTy,
161 /*IsDefaulted=*/true);
162 ColsParam->setDefaultArgument(
163 AST, SemaPtr->getTrivialTemplateArgumentLoc(CDefault, AST.IntTy,
164 SourceLocation()));
165 TemplateParams.emplace_back(ColsParam);
166
167 const unsigned MaxMatDim = SemaPtr->getLangOpts().MaxMatrixDimension;
168
169 auto *MaxRow = IntegerLiteral::Create(
170 AST, llvm::APInt(AST.getIntWidth(AST.IntTy), MaxMatDim), AST.IntTy,
172 auto *MaxCol = IntegerLiteral::Create(
173 AST, llvm::APInt(AST.getIntWidth(AST.IntTy), MaxMatDim), AST.IntTy,
175
176 auto *RowsRef = DeclRefExpr::Create(
177 AST, NestedNameSpecifierLoc(), SourceLocation(), RowsParam,
178 /*RefersToEnclosingVariableOrCapture*/ false,
179 DeclarationNameInfo(RowsParam->getDeclName(), SourceLocation()),
180 AST.IntTy, VK_LValue);
181 auto *ColsRef = DeclRefExpr::Create(
182 AST, NestedNameSpecifierLoc(), SourceLocation(), ColsParam,
183 /*RefersToEnclosingVariableOrCapture*/ false,
184 DeclarationNameInfo(ColsParam->getDeclName(), SourceLocation()),
185 AST.IntTy, VK_LValue);
186
187 auto *RowsLE = BinaryOperator::Create(AST, RowsRef, MaxRow, BO_LE, AST.BoolTy,
190 auto *ColsLE = BinaryOperator::Create(AST, ColsRef, MaxCol, BO_LE, AST.BoolTy,
193
195 AST, RowsLE, ColsLE, BO_LAnd, AST.BoolTy, VK_PRValue, OK_Ordinary,
197
198 auto *ParamList = TemplateParameterList::Create(
199 AST, SourceLocation(), SourceLocation(), TemplateParams, SourceLocation(),
201
202 IdentifierInfo &II = AST.Idents.get("matrix", tok::TokenKind::identifier);
203
205 AST.getTemplateTypeParmType(0, 0, false, TypeParam),
207 AST, NestedNameSpecifierLoc(), SourceLocation(), RowsParam, false,
208 DeclarationNameInfo(RowsParam->getDeclName(), SourceLocation()),
209 AST.IntTy, VK_LValue),
211 AST, NestedNameSpecifierLoc(), SourceLocation(), ColsParam, false,
212 DeclarationNameInfo(ColsParam->getDeclName(), SourceLocation()),
213 AST.IntTy, VK_LValue),
215
216 auto *Record = TypeAliasDecl::Create(AST, HLSLNamespace, SourceLocation(),
217 SourceLocation(), &II,
218 AST.getTrivialTypeSourceInfo(AliasType));
219 Record->setImplicit(true);
220
221 auto *Template =
222 TypeAliasTemplateDecl::Create(AST, HLSLNamespace, SourceLocation(),
223 Record->getIdentifier(), ParamList, Record);
224
225 Record->setDescribedAliasTemplate(Template);
226 Template->setImplicit(true);
227 Template->setLexicalDeclContext(Record->getDeclContext());
228 HLSLNamespace->addDecl(Template);
229}
230
231void HLSLExternalSemaSource::defineTrivialHLSLTypes() {
232 defineHLSLVectorAlias();
233 defineHLSLMatrixAlias();
234}
235
236/// Set up common members and attributes for buffer types
238 ResourceClass RC, bool IsROV,
239 bool RawBuffer, bool HasCounter) {
241 .addBufferHandles(RC, IsROV, RawBuffer, HasCounter)
246}
247
248/// Set up common members and attributes for sampler types
257
258/// Set up common members and attributes for texture types
260 ResourceClass RC, bool IsROV,
261 bool IsArray,
262 ResourceDimension Dim) {
264 .addTextureHandle(RC, IsROV, IsArray, Dim)
265 .addTextureLoadMethods(Dim, IsArray)
272 .addSampleMethods(Dim, IsArray)
273 .addSampleBiasMethods(Dim, IsArray)
274 .addSampleGradMethods(Dim, IsArray)
275 .addSampleLevelMethods(Dim, IsArray)
276 .addSampleCmpMethods(Dim, IsArray)
280 .addGatherMethods(Dim, IsArray)
281 .addGatherCmpMethods(Dim, IsArray);
282}
283
284/// Set up RWTexture type: UAV texture with only operator[] (uint2, read/write),
285/// Load and GetDimensions (no sample/gather/mips/LOD).
287 bool IsArray,
288 ResourceDimension Dim) {
290 .addTextureHandle(ResourceClass::UAV, /*IsROV=*/false, IsArray, Dim)
291 .addTextureLoadMethods(Dim, IsArray)
298}
299
300// Add a partial specialization for a template. The `TextureTemplate` is
301// `Texture<element_type>`, and it will be specialized for vectors:
302// `Texture<vector<element_type, element_count>>`.
305 ClassTemplateDecl *TextureTemplate) {
306 ASTContext &AST = S.getASTContext();
307
308 // Create the template parameters: element_type and element_count.
309 auto *ElementType = TemplateTypeParmDecl::Create(
310 AST, HLSLNamespace, SourceLocation(), SourceLocation(), 0, 0,
311 &AST.Idents.get("element_type"), false, false);
312 auto *ElementCount = NonTypeTemplateParmDecl::Create(
313 AST, HLSLNamespace, SourceLocation(), SourceLocation(), 0, 1,
314 &AST.Idents.get("element_count"), AST.IntTy, false,
316
317 auto *TemplateParams = TemplateParameterList::Create(
318 AST, SourceLocation(), SourceLocation(), {ElementType, ElementCount},
319 SourceLocation(), nullptr);
320
321 // Create the dependent vector type: vector<element_type, element_count>.
323 AST.getTemplateTypeParmType(0, 0, false, ElementType),
325 AST, NestedNameSpecifierLoc(), SourceLocation(), ElementCount, false,
326 DeclarationNameInfo(ElementCount->getDeclName(), SourceLocation()),
327 AST.IntTy, VK_LValue),
329
330 // Create the partial specialization declaration.
331 QualType CanonInjectedTST =
335
337 AST, TagDecl::TagKind::Class, HLSLNamespace, SourceLocation(),
338 SourceLocation(), TemplateParams, TextureTemplate,
340 CanQualType::CreateUnsafe(CanonInjectedTST), nullptr);
341
342 // Set the template arguments as written.
344 TemplateArgumentLoc ArgLoc =
346 TemplateArgumentListInfo ArgsInfo =
348 ArgsInfo.addArgument(ArgLoc);
349 PartialSpec->setTemplateArgsAsWritten(
351
352 PartialSpec->setImplicit(true);
353 PartialSpec->setLexicalDeclContext(HLSLNamespace);
354 PartialSpec->setHasExternalLexicalStorage();
355
356 // Add the partial specialization to the namespace and the class template.
357 HLSLNamespace->addDecl(PartialSpec);
358 TextureTemplate->AddPartialSpecialization(PartialSpec, nullptr);
359
360 return PartialSpec;
361}
362
363// This function is responsible for constructing the constraint expression for
364// this concept:
365// template<typename T> concept is_typed_resource_element_compatible =
366// __is_typed_resource_element_compatible<T>;
369 ASTContext &Context = S.getASTContext();
370
371 // Obtain the QualType for 'bool'
372 QualType BoolTy = Context.BoolTy;
373
374 // Create a QualType that points to this TemplateTypeParmDecl
375 QualType TType = Context.getTypeDeclType(T);
376
377 // Create a TypeSourceInfo for the template type parameter 'T'
378 TypeSourceInfo *TTypeSourceInfo =
379 Context.getTrivialTypeSourceInfo(TType, NameLoc);
380
381 TypeTraitExpr *TypedResExpr = TypeTraitExpr::Create(
382 Context, BoolTy, NameLoc, UTT_IsTypedResourceElementCompatible,
383 {TTypeSourceInfo}, NameLoc, true);
384
385 return TypedResExpr;
386}
387
388// This function is responsible for constructing the constraint expression for
389// this concept:
390// template<typename T> concept is_constant_buffer_element_compatible =
391// std::is_class_v<T> && !__is_intangible(T);
393 SourceLocation NameLoc,
395 ASTContext &Context = S.getASTContext();
396
397 // Obtain the QualType for 'bool'
398 QualType BoolTy = Context.BoolTy;
399
400 // Create a QualType that points to this TemplateTypeParmDecl
401 QualType TType = Context.getTypeDeclType(T);
402
403 // Create a TypeSourceInfo for the template type parameter 'T'
404 TypeSourceInfo *TTypeSourceInfo =
405 Context.getTrivialTypeSourceInfo(TType, NameLoc);
406
408 Context, BoolTy, NameLoc, UTT_IsConstantBufferElementCompatible,
409 {TTypeSourceInfo}, NameLoc, true);
410
411 return ResExpr;
412}
413
414// This function is responsible for constructing the constraint expression for
415// this concept:
416// template<typename T> concept is_structured_resource_element_compatible =
417// !__is_intangible<T> && sizeof(T) >= 1;
419 SourceLocation NameLoc,
421 ASTContext &Context = S.getASTContext();
422
423 // Obtain the QualType for 'bool'
424 QualType BoolTy = Context.BoolTy;
425
426 // Create a QualType that points to this TemplateTypeParmDecl
427 QualType TType = Context.getTypeDeclType(T);
428
429 // Create a TypeSourceInfo for the template type parameter 'T'
430 TypeSourceInfo *TTypeSourceInfo =
431 Context.getTrivialTypeSourceInfo(TType, NameLoc);
432
433 TypeTraitExpr *IsIntangibleExpr =
434 TypeTraitExpr::Create(Context, BoolTy, NameLoc, UTT_IsIntangibleType,
435 {TTypeSourceInfo}, NameLoc, true);
436
437 // negate IsIntangibleExpr
438 UnaryOperator *NotIntangibleExpr = UnaryOperator::Create(
439 Context, IsIntangibleExpr, UO_LNot, BoolTy, VK_LValue, OK_Ordinary,
440 NameLoc, false, FPOptionsOverride());
441
442 // element types also may not be of 0 size
443 UnaryExprOrTypeTraitExpr *SizeOfExpr = new (Context) UnaryExprOrTypeTraitExpr(
444 UETT_SizeOf, TTypeSourceInfo, BoolTy, NameLoc, NameLoc);
445
446 // Create a BinaryOperator that checks if the size of the type is not equal to
447 // 1 Empty structs have a size of 1 in HLSL, so we need to check for that
449 Context, llvm::APInt(Context.getTypeSize(Context.getSizeType()), 1, true),
450 Context.getSizeType(), NameLoc);
451
452 BinaryOperator *SizeGEQOneExpr =
453 BinaryOperator::Create(Context, SizeOfExpr, rhs, BO_GE, BoolTy, VK_LValue,
454 OK_Ordinary, NameLoc, FPOptionsOverride());
455
456 // Combine the two constraints
458 Context, NotIntangibleExpr, SizeGEQOneExpr, BO_LAnd, BoolTy, VK_LValue,
459 OK_Ordinary, NameLoc, FPOptionsOverride());
460
461 return CombinedExpr;
462}
463
465
467 HLSLBufferType BT) {
468 ASTContext &Context = S.getASTContext();
469 DeclContext *DC = NSD->getDeclContext();
470 SourceLocation DeclLoc = SourceLocation();
471
472 IdentifierInfo &ElementTypeII = Context.Idents.get("element_type");
474 Context, NSD->getDeclContext(), DeclLoc, DeclLoc,
475 /*D=*/0,
476 /*P=*/0,
477 /*Id=*/&ElementTypeII,
478 /*Typename=*/true,
479 /*ParameterPack=*/false);
480
481 T->setDeclContext(DC);
482 T->setReferenced();
483
484 // Create and Attach Template Parameter List to ConceptDecl
486 Context, DeclLoc, DeclLoc, {T}, DeclLoc, nullptr);
487
488 DeclarationName DeclName;
489 Expr *ConstraintExpr = nullptr;
490
491 switch (BT) {
493 DeclName = DeclarationName(
494 &Context.Idents.get("__is_typed_resource_element_compatible"));
495 ConstraintExpr = constructTypedBufferConstraintExpr(S, DeclLoc, T);
496 break;
498 DeclName = DeclarationName(
499 &Context.Idents.get("__is_structured_resource_element_compatible"));
500 ConstraintExpr = constructStructuredBufferConstraintExpr(S, DeclLoc, T);
501 break;
503 DeclName = DeclarationName(
504 &Context.Idents.get("__is_constant_buffer_element_compatible"));
505 ConstraintExpr = constructConstantBufferConstraintExpr(S, DeclLoc, T);
506 break;
507 }
508
509 // Create a ConceptDecl
510 ConceptDecl *CD =
511 ConceptDecl::Create(Context, NSD->getDeclContext(), DeclLoc, DeclName,
512 ConceptParams, ConstraintExpr);
513
514 // Attach the template parameter list to the ConceptDecl
515 CD->setTemplateParameters(ConceptParams);
516
517 // Add the concept declaration to the Translation Unit Decl
518 NSD->getDeclContext()->addDecl(CD);
519
520 return CD;
521}
522
523void HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
524 ASTContext &AST = SemaPtr->getASTContext();
525 CXXRecordDecl *Decl;
526 ConceptDecl *TypedBufferConcept = constructBufferConceptDecl(
527 *SemaPtr, HLSLNamespace, HLSLBufferType::Typed);
528 ConceptDecl *StructuredBufferConcept = constructBufferConceptDecl(
529 *SemaPtr, HLSLNamespace, HLSLBufferType::Structured);
530 ConceptDecl *ConstantBufferConcept = constructBufferConceptDecl(
531 *SemaPtr, HLSLNamespace, HLSLBufferType::Constant);
532
533 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "ConstantBuffer")
534 .addSimpleTemplateParams({"element_type"}, ConstantBufferConcept)
535 .finalizeForwardDeclaration();
536
537 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
538 setupBufferType(Decl, *SemaPtr, ResourceClass::CBuffer, /*IsROV=*/false,
539 /*RawBuffer=*/false, /*HasCounter=*/false)
542 });
543
544 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "Buffer")
545 .addSimpleTemplateParams({"element_type"}, TypedBufferConcept)
546 .finalizeForwardDeclaration();
547
548 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
549 setupBufferType(Decl, *SemaPtr, ResourceClass::SRV, /*IsROV=*/false,
550 /*RawBuffer=*/false, /*HasCounter=*/false)
555 });
556
557 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RWBuffer")
558 .addSimpleTemplateParams({"element_type"}, TypedBufferConcept)
559 .finalizeForwardDeclaration();
560
561 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
562 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/false,
563 /*RawBuffer=*/false, /*HasCounter=*/false)
568 });
569
570 Decl =
571 BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RasterizerOrderedBuffer")
572 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
573 .finalizeForwardDeclaration();
574 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
575 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/true,
576 /*RawBuffer=*/false, /*HasCounter=*/false)
581 });
582
583 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "StructuredBuffer")
584 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
585 .finalizeForwardDeclaration();
586 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
587 setupBufferType(Decl, *SemaPtr, ResourceClass::SRV, /*IsROV=*/false,
588 /*RawBuffer=*/true, /*HasCounter=*/false)
593 });
594
595 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RWStructuredBuffer")
596 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
597 .finalizeForwardDeclaration();
598 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
599 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/false,
600 /*RawBuffer=*/true, /*HasCounter=*/true)
607 });
608
609 Decl =
610 BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "AppendStructuredBuffer")
611 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
612 .finalizeForwardDeclaration();
613 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
614 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/false,
615 /*RawBuffer=*/true, /*HasCounter=*/true)
619 });
620
621 Decl =
622 BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "ConsumeStructuredBuffer")
623 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
624 .finalizeForwardDeclaration();
625 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
626 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/false,
627 /*RawBuffer=*/true, /*HasCounter=*/true)
631 });
632
633 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace,
634 "RasterizerOrderedStructuredBuffer")
635 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
636 .finalizeForwardDeclaration();
637 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
638 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/true,
639 /*RawBuffer=*/true, /*HasCounter=*/true)
646 });
647
648 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "ByteAddressBuffer")
649 .finalizeForwardDeclaration();
650 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
651 setupBufferType(Decl, *SemaPtr, ResourceClass::SRV, /*IsROV=*/false,
652 /*RawBuffer=*/true, /*HasCounter=*/false)
656 });
657 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RWByteAddressBuffer")
658 .finalizeForwardDeclaration();
659 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
660 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/false,
661 /*RawBuffer=*/true, /*HasCounter=*/false)
667 });
668 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace,
669 "RasterizerOrderedByteAddressBuffer")
670 .finalizeForwardDeclaration();
671 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
672 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/true,
673 /*RawBuffer=*/true, /*HasCounter=*/false)
677 });
678
679 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "SamplerState")
680 .finalizeForwardDeclaration();
681 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
682 setupSamplerType(Decl, *SemaPtr).completeDefinition();
683 });
684
685 Decl =
686 BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "SamplerComparisonState")
687 .finalizeForwardDeclaration();
688 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
689 setupSamplerType(Decl, *SemaPtr).completeDefinition();
690 });
691
692 QualType Float4Ty = AST.getExtVectorType(AST.FloatTy, 4);
693 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "Texture2D")
694 .addSimpleTemplateParams({"element_type"}, {Float4Ty},
695 TypedBufferConcept)
696 .finalizeForwardDeclaration();
697
698 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
699 setupTextureType(Decl, *SemaPtr, ResourceClass::SRV, /*IsROV=*/false,
700 /*IsArray=*/false, ResourceDimension::Dim2D)
702 });
703
704 auto *PartialSpec = addVectorTexturePartialSpecialization(
705 *SemaPtr, HLSLNamespace, Decl->getDescribedClassTemplate());
706 onCompletion(PartialSpec, [this](CXXRecordDecl *Decl) {
707 setupTextureType(Decl, *SemaPtr, ResourceClass::SRV, /*IsROV=*/false,
708 /*IsArray=*/false, ResourceDimension::Dim2D)
710 });
711
712 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RWTexture2D")
713 .addSimpleTemplateParams({"element_type"}, {Float4Ty},
714 TypedBufferConcept)
715 .finalizeForwardDeclaration();
716
717 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
718 setupRWTextureType(Decl, *SemaPtr, /*IsArray=*/false,
719 ResourceDimension::Dim2D)
721 });
722
723 auto *PartialSpecRW = addVectorTexturePartialSpecialization(
724 *SemaPtr, HLSLNamespace, Decl->getDescribedClassTemplate());
725 onCompletion(PartialSpecRW, [this](CXXRecordDecl *Decl) {
726 setupRWTextureType(Decl, *SemaPtr, /*IsArray=*/false,
727 ResourceDimension::Dim2D)
729 });
730
731 // Texture2DArray — same as Texture2D but IsArray=true
732 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "Texture2DArray")
733 .addSimpleTemplateParams({"element_type"}, {Float4Ty},
734 TypedBufferConcept)
735 .finalizeForwardDeclaration();
736
737 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
738 setupTextureType(Decl, *SemaPtr, ResourceClass::SRV, /*IsROV=*/false,
739 /*IsArray=*/true, ResourceDimension::Dim2D)
741 });
742
743 auto *PartialSpec2DA = addVectorTexturePartialSpecialization(
744 *SemaPtr, HLSLNamespace, Decl->getDescribedClassTemplate());
745 onCompletion(PartialSpec2DA, [this](CXXRecordDecl *Decl) {
746 setupTextureType(Decl, *SemaPtr, ResourceClass::SRV, /*IsROV=*/false,
747 /*IsArray=*/true, ResourceDimension::Dim2D)
749 });
750
751 // RWTexture2DArray — same as RWTexture2D but IsArray=true
752 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RWTexture2DArray")
753 .addSimpleTemplateParams({"element_type"}, {Float4Ty},
754 TypedBufferConcept)
755 .finalizeForwardDeclaration();
756
757 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
758 setupRWTextureType(Decl, *SemaPtr, /*IsArray=*/true,
759 ResourceDimension::Dim2D)
761 });
762
763 auto *PartialSpecRW2DA = addVectorTexturePartialSpecialization(
764 *SemaPtr, HLSLNamespace, Decl->getDescribedClassTemplate());
765 onCompletion(PartialSpecRW2DA, [this](CXXRecordDecl *Decl) {
766 setupRWTextureType(Decl, *SemaPtr, /*IsArray=*/true,
767 ResourceDimension::Dim2D)
769 });
770}
771
772// Build a single overload of an HLSL atomic intrinsic in the hlsl namespace.
773// `dest` is an address-space-qualified reference; `original_value` (when
774// present) is a plain reference. The synthesized FunctionDecl aliases the
775// underlying clang builtin via BuiltinAliasAttr.
776static void buildAtomicOverload(Sema &S, NamespaceDecl *NS, StringRef FuncName,
777 StringRef BuiltinName, QualType ElemTy,
778 LangAS DestAS, bool ThreeArg) {
779 ASTContext &AST = S.getASTContext();
780
781 QualType DestTy =
782 AST.getLValueReferenceType(AST.getAddrSpaceQualType(ElemTy, DestAS));
783 QualType OrigRefTy = AST.getLValueReferenceType(ElemTy);
784
785 SmallVector<QualType, 3> ParamTypes;
786 ParamTypes.push_back(DestTy);
787 ParamTypes.push_back(ElemTy);
788 if (ThreeArg)
789 ParamTypes.push_back(OrigRefTy);
790
792 QualType FuncTy = AST.getFunctionType(AST.VoidTy, ParamTypes, EPI);
793 auto *TSInfo = AST.getTrivialTypeSourceInfo(FuncTy, SourceLocation());
794
795 IdentifierInfo &FuncII = AST.Idents.get(FuncName, tok::TokenKind::identifier);
796 DeclarationName FuncDeclName(&FuncII);
797
799 AST, NS, SourceLocation(), SourceLocation(), FuncDeclName, FuncTy, TSInfo,
800 SC_Extern, /*UsesFPIntrin=*/false, /*isInlineSpecified=*/false,
801 /*hasWrittenPrototype=*/true);
802
803 constexpr const char *ParamNames[] = {"dest", "value", "original_value"};
805 unsigned I = 0;
806 for (auto [ParamType, ParamName] : llvm::zip(ParamTypes, ParamNames)) {
807 IdentifierInfo &PII = AST.Idents.get(ParamName, tok::TokenKind::identifier);
809 AST, FD, SourceLocation(), SourceLocation(), &PII, ParamType,
811 nullptr);
812 Parm->setScopeInfo(0, I++);
813 ParmDecls.push_back(Parm);
814 }
815 FD->setParams(ParmDecls);
816
817 IdentifierInfo &BuiltinII =
818 S.getPreprocessor().getIdentifierTable().get(BuiltinName);
819 FD->addAttr(BuiltinAliasAttr::CreateImplicit(AST, &BuiltinII));
820 FD->setImplicit();
821 NS->addDecl(FD);
822}
823
824// Synthesize the InterlockedFunc overload set: {int, uint, int64_t, uint64_t}
825// x {groupshared, device} x {2-arg, 3-arg}.
827 StringRef FuncName,
828 StringRef BuiltinName) {
829 ASTContext &AST = S.getASTContext();
830 // HLSL: int64_t == long, uint64_t == unsigned long (see hlsl_basic_types.h).
831 QualType Elems[] = {AST.IntTy, AST.UnsignedIntTy, AST.LongTy,
832 AST.UnsignedLongTy};
834
835 for (QualType ElemTy : Elems)
836 for (LangAS AS : AddrSpaces)
837 for (bool ThreeArg : {false, true})
838 buildAtomicOverload(S, NS, FuncName, BuiltinName, ElemTy, AS, ThreeArg);
839}
840
841void HLSLExternalSemaSource::defineHLSLAtomicIntrinsics() {
842 defineHLSLInterlockedFunc(*SemaPtr, HLSLNamespace, "InterlockedAdd",
843 "__builtin_hlsl_interlocked_add");
844 defineHLSLInterlockedFunc(*SemaPtr, HLSLNamespace, "InterlockedOr",
845 "__builtin_hlsl_interlocked_or");
846}
847
848void HLSLExternalSemaSource::onCompletion(CXXRecordDecl *Record,
849 CompletionFunction Fn) {
850 if (!Record->isCompleteDefinition())
851 Completions.insert(std::make_pair(Record->getCanonicalDecl(), Fn));
852}
853
855 if (!isa<CXXRecordDecl>(Tag))
856 return;
857 auto Record = cast<CXXRecordDecl>(Tag);
858
859 // If this is a specialization, we need to get the underlying templated
860 // declaration and complete that.
861 if (auto TDecl = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
863 ClassTemplateDecl *Template = TDecl->getSpecializedTemplate();
865 Template->getPartialSpecializations(Partials);
866 ClassTemplatePartialSpecializationDecl *MatchedPartial = nullptr;
867 for (auto *Partial : Partials) {
868 sema::TemplateDeductionInfo Info(TDecl->getLocation());
869 if (SemaPtr->DeduceTemplateArguments(Partial, TDecl->getTemplateArgs(),
870 Info) ==
872 MatchedPartial = Partial;
873 break;
874 }
875 }
876 if (MatchedPartial)
877 Record = MatchedPartial;
878 else
879 Record = Template->getTemplatedDecl();
880 }
881 }
882 Record = Record->getCanonicalDecl();
883 auto It = Completions.find(Record);
884 if (It == Completions.end())
885 return;
886 // Move out the callback and erase before invoking it: the callback can
887 // re-enter CompleteType and mutate Completions, which invalidates It under
888 // backward-shift deletion.
889 CompletionFunction Fn = std::move(It->second);
890 Completions.erase(It);
891 Fn(Record);
892}
Defines the clang::ASTContext interface.
Provides definitions for the various language-specific address spaces.
llvm::dxil::ResourceClass ResourceClass
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the C++ template declaration subclasses.
static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl *Decl, Sema &S, ResourceClass RC, bool IsROV, bool RawBuffer, bool HasCounter)
Set up common members and attributes for buffer types.
static BuiltinTypeDeclBuilder setupTextureType(CXXRecordDecl *Decl, Sema &S, ResourceClass RC, bool IsROV, bool IsArray, ResourceDimension Dim)
Set up common members and attributes for texture types.
static void defineHLSLInterlockedFunc(Sema &S, NamespaceDecl *NS, StringRef FuncName, StringRef BuiltinName)
static BuiltinTypeDeclBuilder setupSamplerType(CXXRecordDecl *Decl, Sema &S)
Set up common members and attributes for sampler types.
static void buildAtomicOverload(Sema &S, NamespaceDecl *NS, StringRef FuncName, StringRef BuiltinName, QualType ElemTy, LangAS DestAS, bool ThreeArg)
static Expr * constructTypedBufferConstraintExpr(Sema &S, SourceLocation NameLoc, TemplateTypeParmDecl *T)
static ConceptDecl * constructBufferConceptDecl(Sema &S, NamespaceDecl *NSD, HLSLBufferType BT)
static Expr * constructConstantBufferConstraintExpr(Sema &S, SourceLocation NameLoc, TemplateTypeParmDecl *T)
static ClassTemplatePartialSpecializationDecl * addVectorTexturePartialSpecialization(Sema &S, NamespaceDecl *HLSLNamespace, ClassTemplateDecl *TextureTemplate)
static Expr * constructStructuredBufferConstraintExpr(Sema &S, SourceLocation NameLoc, TemplateTypeParmDecl *T)
static BuiltinTypeDeclBuilder setupRWTextureType(CXXRecordDecl *Decl, Sema &S, bool IsArray, ResourceDimension Dim)
Set up RWTexture type: UAV texture with only operator[] (uint2, read/write), Load and GetDimensions (...
llvm::MachO::Record Record
Definition MachO.h:31
Defines the clang::Preprocessor interface.
This file declares semantic analysis for HLSL constructs.
Defines the clang::SourceLocation class and associated facilities.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Definition ASTContext.h:223
TranslationUnitDecl * getTranslationUnitDecl() const
QualType getDependentSizedMatrixType(QualType ElementType, Expr *RowExpr, Expr *ColumnExpr, SourceLocation AttrLoc) const
Return the unique reference to the matrix type of the specified element type and size.
CanQualType LongTy
unsigned getIntWidth(QualType T) const
static CanQualType getCanonicalType(QualType T)
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
CanQualType FloatTy
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type.
IdentifierTable & Idents
Definition ASTContext.h:808
CanQualType BoolTy
CanQualType UnsignedLongTy
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location,...
CanQualType IntTy
CanQualType VoidTy
CanQualType UnsignedIntTy
QualType getTemplateSpecializationType(ElaboratedTypeKeyword Keyword, TemplateName T, ArrayRef< TemplateArgument > SpecifiedArgs, ArrayRef< TemplateArgument > CanonicalArgs, QualType Underlying=QualType()) const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getTemplateTypeParmType(int Depth, int Index, bool ParameterPack, TemplateTypeParmDecl *ParmDecl=nullptr) const
Retrieve the template type parameter type for a template parameter or parameter pack with the given d...
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size.
QualType getAddrSpaceQualType(QualType T, LangAS AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
QualType getDependentSizedExtVectorType(QualType VectorType, Expr *SizeExpr, SourceLocation AttrLoc) const
A builtin binary operation expression such as "x + y" or "x <= y".
Definition Expr.h:4044
static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)
Definition Expr.cpp:5107
Represents a C++ struct/union/class.
Definition DeclCXX.h:258
static CanQual< Type > CreateUnsafe(QualType Other)
Declaration of a class template.
void AddPartialSpecialization(ClassTemplatePartialSpecializationDecl *D, void *InsertPos)
Insert the specified partial specialization knowing that it is not already in.
static ClassTemplatePartialSpecializationDecl * Create(ASTContext &Context, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, TemplateParameterList *Params, ClassTemplateDecl *SpecializedTemplate, ArrayRef< TemplateArgument > Args, CanQualType CanonInjectedTST, ClassTemplatePartialSpecializationDecl *PrevDecl)
Declaration of a C++20 concept.
static ConceptDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, Expr *ConstraintExpr=nullptr)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1466
void addDecl(Decl *D)
Add the declaration D into this context.
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
Definition DeclBase.h:2718
decl_iterator decls_begin() const
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)
Definition Expr.cpp:494
Decl - This represents one declaration (or definition), e.g.
Definition DeclBase.h:86
void addAttr(Attr *A)
void setImplicit(bool I=true)
Definition DeclBase.h:602
DeclContext * getDeclContext()
Definition DeclBase.h:456
The name of a declaration.
This represents one expression.
Definition Expr.h:112
Represents difference between two FPOptions values.
Represents a function declaration or definition.
Definition Decl.h:2029
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool UsesFPIntrin=false, bool isInlineSpecified=false, bool hasWrittenPrototype=true, ConstexprSpecKind ConstexprKind=ConstexprSpecKind::Unspecified, const AssociatedConstraint &TrailingRequiresClause={})
Definition Decl.h:2225
void CompleteType(TagDecl *Tag) override
Complete an incomplete HLSL builtin type.
void InitializeSema(Sema &S) override
Initialize the semantic source with the Sema instance being used to perform semantic analysis on the ...
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 IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
Definition Expr.cpp:981
Represents the results of name lookup.
Definition Lookup.h:147
Represent a C++ namespace.
Definition Decl.h:592
static NamespaceDecl * Create(ASTContext &C, DeclContext *DC, bool Inline, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, NamespaceDecl *PrevDecl, bool Nested)
Definition DeclCXX.cpp:3374
A C++ nested-name-specifier augmented with source location information.
static NonTypeTemplateParmDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, int D, int P, const IdentifierInfo *Id, QualType T, bool ParameterPack, TypeSourceInfo *TInfo)
Represents a parameter to a function.
Definition Decl.h:1819
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition Decl.h:1852
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
Definition Decl.cpp:2936
IdentifierTable & getIdentifierTable()
A (possibly-)qualified type.
Definition TypeBase.h:938
C++2a [expr.prim.req]: A requires-expression provides a concise way to express requirements on templa...
Sema - This implements semantic analysis and AST building for C.
Definition Sema.h:869
@ LookupNamespaceName
Look up a namespace name within a C++ using directive or namespace alias definition,...
Definition Sema.h:9444
Preprocessor & getPreprocessor() const
Definition Sema.h:940
ASTContext & getASTContext() const
Definition Sema.h:941
const LangOptions & getLangOpts() const
Definition Sema.h:934
TemplateArgumentLoc getTrivialTemplateArgumentLoc(const TemplateArgument &Arg, QualType NTTPType, SourceLocation Loc)
Allocate a TemplateArgumentLoc where all locations have been initialized to the given location.
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
Encodes a location in the source.
Represents the declaration of a struct/union/class/enum.
Definition Decl.h:3761
A convenient class for passing around template argument information.
void addArgument(const TemplateArgumentLoc &Loc)
Location wrapper for a TemplateArgument.
Represents a template argument.
void setTemplateParameters(TemplateParameterList *TParams)
Represents a C++ template name within the type system.
Stores a list of template parameters for a TemplateDecl and its derived classes.
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, int D, int P, IdentifierInfo *Id, bool Typename, bool ParameterPack, bool HasTypeConstraint=false, UnsignedOrNone NumExpanded=std::nullopt)
static TypeAliasDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, TypeSourceInfo *TInfo)
Definition Decl.cpp:5817
static TypeAliasTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
A container of type source information.
Definition TypeBase.h:8460
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
Definition ExprCXX.h:2900
static TypeTraitExpr * Create(const ASTContext &C, QualType T, SourceLocation Loc, TypeTrait Kind, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc, bool Value)
Create a new type trait expression.
Definition ExprCXX.cpp:1906
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
Definition Expr.h:2631
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Definition Expr.h:2250
static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)
Definition Expr.cpp:5164
Represents a C++ using-declaration.
Definition DeclCXX.h:3612
static UsingDirectiveDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation UsingLoc, SourceLocation NamespaceLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation IdentLoc, NamedDecl *Nominated, DeclContext *CommonAncestor)
Definition DeclCXX.cpp:3330
Represents a GCC generic vector type.
Definition TypeBase.h:4274
BuiltinTypeDeclBuilder & addDefaultHandleConstructor(AccessSpecifier Access=AccessSpecifier::AS_public)
BuiltinTypeDeclBuilder & addSampleGradMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addCopyAssignmentOperator(AccessSpecifier Access=AccessSpecifier::AS_public)
BuiltinTypeDeclBuilder & addGatherCmpMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addGetDimensionsMethodForBuffer()
BuiltinTypeDeclBuilder & addConstantBufferConversionToType()
BuiltinTypeDeclBuilder & addTextureLoadMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addSampleBiasMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addBufferHandles(ResourceClass RC, bool IsROV, bool RawBuffer, bool HasCounter, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addByteAddressBufferStoreMethods()
BuiltinTypeDeclBuilder & addSampleMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addArraySubscriptOperators(ResourceDimension Dim=ResourceDimension::Unknown, bool IsArray=false)
BuiltinTypeDeclBuilder & addSampleLevelMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addCopyConstructor(AccessSpecifier Access=AccessSpecifier::AS_public)
BuiltinTypeDeclBuilder & addTextureHandle(ResourceClass RC, bool IsROV, bool IsArray, ResourceDimension RD, AccessSpecifier Access=AccessSpecifier::AS_private)
BuiltinTypeDeclBuilder & addSampleCmpMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addMipsMember(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addByteAddressBufferLoadMethods()
BuiltinTypeDeclBuilder & addStaticInitializationFunctions(bool HasCounter)
BuiltinTypeDeclBuilder & addGatherMethods(ResourceDimension Dim, bool IsArray=false)
BuiltinTypeDeclBuilder & addCalculateLodMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addGetDimensionsMethods(ResourceDimension Dim)
BuiltinTypeDeclBuilder & addByteAddressBufferInterlockedMethods()
BuiltinTypeDeclBuilder & addSampleCmpLevelZeroMethods(ResourceDimension Dim, bool IsArray=false)
Provides information about an attempted template argument deduction, whose success or failure was des...
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
The JSON file list parser is used to communicate input to InstallAPI.
bool isa(CodeGen::Address addr)
Definition Address.h:330
@ OK_Ordinary
An ordinary object is located at an address in memory.
Definition Specifiers.h:152
@ SC_Extern
Definition Specifiers.h:252
@ SC_None
Definition Specifiers.h:251
@ Default
Set to the current date and time.
@ Result
The result type of a method or function.
Definition TypeBase.h:906
const FunctionProtoType * T
@ Template
We are parsing a template declaration.
Definition Parser.h:81
LangAS
Defines the address space values used by the address space qualifier of QualType.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
Definition Specifiers.h:136
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
Definition Specifiers.h:140
@ Success
Template argument deduction was successful.
Definition Sema.h:371
U cast(CodeGen::Address addr)
Definition Address.h:327
@ Class
The "class" keyword introduces the elaborated-type-specifier.
Definition TypeBase.h:6016
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.
Definition TypeBase.h:5491