clang 23.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// Add a partial specialization for a template. The `TextureTemplate` is
285// `Texture<element_type>`, and it will be specialized for vectors:
286// `Texture<vector<element_type, element_count>>`.
289 ClassTemplateDecl *TextureTemplate) {
290 ASTContext &AST = S.getASTContext();
291
292 // Create the template parameters: element_type and element_count.
293 auto *ElementType = TemplateTypeParmDecl::Create(
294 AST, HLSLNamespace, SourceLocation(), SourceLocation(), 0, 0,
295 &AST.Idents.get("element_type"), false, false);
296 auto *ElementCount = NonTypeTemplateParmDecl::Create(
297 AST, HLSLNamespace, SourceLocation(), SourceLocation(), 0, 1,
298 &AST.Idents.get("element_count"), AST.IntTy, false,
300
301 auto *TemplateParams = TemplateParameterList::Create(
302 AST, SourceLocation(), SourceLocation(), {ElementType, ElementCount},
303 SourceLocation(), nullptr);
304
305 // Create the dependent vector type: vector<element_type, element_count>.
307 AST.getTemplateTypeParmType(0, 0, false, ElementType),
309 AST, NestedNameSpecifierLoc(), SourceLocation(), ElementCount, false,
310 DeclarationNameInfo(ElementCount->getDeclName(), SourceLocation()),
311 AST.IntTy, VK_LValue),
313
314 // Create the partial specialization declaration.
315 QualType CanonInjectedTST =
319
321 AST, TagDecl::TagKind::Class, HLSLNamespace, SourceLocation(),
322 SourceLocation(), TemplateParams, TextureTemplate,
324 CanQualType::CreateUnsafe(CanonInjectedTST), nullptr);
325
326 // Set the template arguments as written.
328 TemplateArgumentLoc ArgLoc =
330 TemplateArgumentListInfo ArgsInfo =
332 ArgsInfo.addArgument(ArgLoc);
333 PartialSpec->setTemplateArgsAsWritten(
335
336 PartialSpec->setImplicit(true);
337 PartialSpec->setLexicalDeclContext(HLSLNamespace);
338 PartialSpec->setHasExternalLexicalStorage();
339
340 // Add the partial specialization to the namespace and the class template.
341 HLSLNamespace->addDecl(PartialSpec);
342 TextureTemplate->AddPartialSpecialization(PartialSpec, nullptr);
343
344 return PartialSpec;
345}
346
347// This function is responsible for constructing the constraint expression for
348// this concept:
349// template<typename T> concept is_typed_resource_element_compatible =
350// __is_typed_resource_element_compatible<T>;
353 ASTContext &Context = S.getASTContext();
354
355 // Obtain the QualType for 'bool'
356 QualType BoolTy = Context.BoolTy;
357
358 // Create a QualType that points to this TemplateTypeParmDecl
359 QualType TType = Context.getTypeDeclType(T);
360
361 // Create a TypeSourceInfo for the template type parameter 'T'
362 TypeSourceInfo *TTypeSourceInfo =
363 Context.getTrivialTypeSourceInfo(TType, NameLoc);
364
365 TypeTraitExpr *TypedResExpr = TypeTraitExpr::Create(
366 Context, BoolTy, NameLoc, UTT_IsTypedResourceElementCompatible,
367 {TTypeSourceInfo}, NameLoc, true);
368
369 return TypedResExpr;
370}
371
372// This function is responsible for constructing the constraint expression for
373// this concept:
374// template<typename T> concept is_constant_buffer_element_compatible =
375// std::is_class_v<T> && !__is_intangible(T);
377 SourceLocation NameLoc,
379 ASTContext &Context = S.getASTContext();
380
381 // Obtain the QualType for 'bool'
382 QualType BoolTy = Context.BoolTy;
383
384 // Create a QualType that points to this TemplateTypeParmDecl
385 QualType TType = Context.getTypeDeclType(T);
386
387 // Create a TypeSourceInfo for the template type parameter 'T'
388 TypeSourceInfo *TTypeSourceInfo =
389 Context.getTrivialTypeSourceInfo(TType, NameLoc);
390
392 Context, BoolTy, NameLoc, UTT_IsConstantBufferElementCompatible,
393 {TTypeSourceInfo}, NameLoc, true);
394
395 return ResExpr;
396}
397
398// This function is responsible for constructing the constraint expression for
399// this concept:
400// template<typename T> concept is_structured_resource_element_compatible =
401// !__is_intangible<T> && sizeof(T) >= 1;
403 SourceLocation NameLoc,
405 ASTContext &Context = S.getASTContext();
406
407 // Obtain the QualType for 'bool'
408 QualType BoolTy = Context.BoolTy;
409
410 // Create a QualType that points to this TemplateTypeParmDecl
411 QualType TType = Context.getTypeDeclType(T);
412
413 // Create a TypeSourceInfo for the template type parameter 'T'
414 TypeSourceInfo *TTypeSourceInfo =
415 Context.getTrivialTypeSourceInfo(TType, NameLoc);
416
417 TypeTraitExpr *IsIntangibleExpr =
418 TypeTraitExpr::Create(Context, BoolTy, NameLoc, UTT_IsIntangibleType,
419 {TTypeSourceInfo}, NameLoc, true);
420
421 // negate IsIntangibleExpr
422 UnaryOperator *NotIntangibleExpr = UnaryOperator::Create(
423 Context, IsIntangibleExpr, UO_LNot, BoolTy, VK_LValue, OK_Ordinary,
424 NameLoc, false, FPOptionsOverride());
425
426 // element types also may not be of 0 size
427 UnaryExprOrTypeTraitExpr *SizeOfExpr = new (Context) UnaryExprOrTypeTraitExpr(
428 UETT_SizeOf, TTypeSourceInfo, BoolTy, NameLoc, NameLoc);
429
430 // Create a BinaryOperator that checks if the size of the type is not equal to
431 // 1 Empty structs have a size of 1 in HLSL, so we need to check for that
433 Context, llvm::APInt(Context.getTypeSize(Context.getSizeType()), 1, true),
434 Context.getSizeType(), NameLoc);
435
436 BinaryOperator *SizeGEQOneExpr =
437 BinaryOperator::Create(Context, SizeOfExpr, rhs, BO_GE, BoolTy, VK_LValue,
438 OK_Ordinary, NameLoc, FPOptionsOverride());
439
440 // Combine the two constraints
442 Context, NotIntangibleExpr, SizeGEQOneExpr, BO_LAnd, BoolTy, VK_LValue,
443 OK_Ordinary, NameLoc, FPOptionsOverride());
444
445 return CombinedExpr;
446}
447
449
451 HLSLBufferType BT) {
452 ASTContext &Context = S.getASTContext();
453 DeclContext *DC = NSD->getDeclContext();
454 SourceLocation DeclLoc = SourceLocation();
455
456 IdentifierInfo &ElementTypeII = Context.Idents.get("element_type");
458 Context, NSD->getDeclContext(), DeclLoc, DeclLoc,
459 /*D=*/0,
460 /*P=*/0,
461 /*Id=*/&ElementTypeII,
462 /*Typename=*/true,
463 /*ParameterPack=*/false);
464
465 T->setDeclContext(DC);
466 T->setReferenced();
467
468 // Create and Attach Template Parameter List to ConceptDecl
470 Context, DeclLoc, DeclLoc, {T}, DeclLoc, nullptr);
471
472 DeclarationName DeclName;
473 Expr *ConstraintExpr = nullptr;
474
475 switch (BT) {
477 DeclName = DeclarationName(
478 &Context.Idents.get("__is_typed_resource_element_compatible"));
479 ConstraintExpr = constructTypedBufferConstraintExpr(S, DeclLoc, T);
480 break;
482 DeclName = DeclarationName(
483 &Context.Idents.get("__is_structured_resource_element_compatible"));
484 ConstraintExpr = constructStructuredBufferConstraintExpr(S, DeclLoc, T);
485 break;
487 DeclName = DeclarationName(
488 &Context.Idents.get("__is_constant_buffer_element_compatible"));
489 ConstraintExpr = constructConstantBufferConstraintExpr(S, DeclLoc, T);
490 break;
491 }
492
493 // Create a ConceptDecl
494 ConceptDecl *CD =
495 ConceptDecl::Create(Context, NSD->getDeclContext(), DeclLoc, DeclName,
496 ConceptParams, ConstraintExpr);
497
498 // Attach the template parameter list to the ConceptDecl
499 CD->setTemplateParameters(ConceptParams);
500
501 // Add the concept declaration to the Translation Unit Decl
502 NSD->getDeclContext()->addDecl(CD);
503
504 return CD;
505}
506
507void HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
508 ASTContext &AST = SemaPtr->getASTContext();
509 CXXRecordDecl *Decl;
510 ConceptDecl *TypedBufferConcept = constructBufferConceptDecl(
511 *SemaPtr, HLSLNamespace, HLSLBufferType::Typed);
512 ConceptDecl *StructuredBufferConcept = constructBufferConceptDecl(
513 *SemaPtr, HLSLNamespace, HLSLBufferType::Structured);
514 ConceptDecl *ConstantBufferConcept = constructBufferConceptDecl(
515 *SemaPtr, HLSLNamespace, HLSLBufferType::Constant);
516
517 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "ConstantBuffer")
518 .addSimpleTemplateParams({"element_type"}, ConstantBufferConcept)
519 .finalizeForwardDeclaration();
520
521 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
522 setupBufferType(Decl, *SemaPtr, ResourceClass::CBuffer, /*IsROV=*/false,
523 /*RawBuffer=*/false, /*HasCounter=*/false)
526 });
527
528 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "Buffer")
529 .addSimpleTemplateParams({"element_type"}, TypedBufferConcept)
530 .finalizeForwardDeclaration();
531
532 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
533 setupBufferType(Decl, *SemaPtr, ResourceClass::SRV, /*IsROV=*/false,
534 /*RawBuffer=*/false, /*HasCounter=*/false)
539 });
540
541 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RWBuffer")
542 .addSimpleTemplateParams({"element_type"}, TypedBufferConcept)
543 .finalizeForwardDeclaration();
544
545 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
546 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/false,
547 /*RawBuffer=*/false, /*HasCounter=*/false)
552 });
553
554 Decl =
555 BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RasterizerOrderedBuffer")
556 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
557 .finalizeForwardDeclaration();
558 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
559 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/true,
560 /*RawBuffer=*/false, /*HasCounter=*/false)
565 });
566
567 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "StructuredBuffer")
568 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
569 .finalizeForwardDeclaration();
570 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
571 setupBufferType(Decl, *SemaPtr, ResourceClass::SRV, /*IsROV=*/false,
572 /*RawBuffer=*/true, /*HasCounter=*/false)
577 });
578
579 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RWStructuredBuffer")
580 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
581 .finalizeForwardDeclaration();
582 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
583 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/false,
584 /*RawBuffer=*/true, /*HasCounter=*/true)
591 });
592
593 Decl =
594 BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "AppendStructuredBuffer")
595 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
596 .finalizeForwardDeclaration();
597 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
598 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/false,
599 /*RawBuffer=*/true, /*HasCounter=*/true)
603 });
604
605 Decl =
606 BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "ConsumeStructuredBuffer")
607 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
608 .finalizeForwardDeclaration();
609 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
610 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/false,
611 /*RawBuffer=*/true, /*HasCounter=*/true)
615 });
616
617 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace,
618 "RasterizerOrderedStructuredBuffer")
619 .addSimpleTemplateParams({"element_type"}, StructuredBufferConcept)
620 .finalizeForwardDeclaration();
621 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
622 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/true,
623 /*RawBuffer=*/true, /*HasCounter=*/true)
630 });
631
632 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "ByteAddressBuffer")
633 .finalizeForwardDeclaration();
634 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
635 setupBufferType(Decl, *SemaPtr, ResourceClass::SRV, /*IsROV=*/false,
636 /*RawBuffer=*/true, /*HasCounter=*/false)
640 });
641 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RWByteAddressBuffer")
642 .finalizeForwardDeclaration();
643 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
644 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/false,
645 /*RawBuffer=*/true, /*HasCounter=*/false)
650 });
651 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace,
652 "RasterizerOrderedByteAddressBuffer")
653 .finalizeForwardDeclaration();
654 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
655 setupBufferType(Decl, *SemaPtr, ResourceClass::UAV, /*IsROV=*/true,
656 /*RawBuffer=*/true, /*HasCounter=*/false)
659 });
660
661 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "SamplerState")
662 .finalizeForwardDeclaration();
663 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
664 setupSamplerType(Decl, *SemaPtr).completeDefinition();
665 });
666
667 Decl =
668 BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "SamplerComparisonState")
669 .finalizeForwardDeclaration();
670 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
671 setupSamplerType(Decl, *SemaPtr).completeDefinition();
672 });
673
674 QualType Float4Ty = AST.getExtVectorType(AST.FloatTy, 4);
675 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "Texture2D")
676 .addSimpleTemplateParams({"element_type"}, {Float4Ty},
677 TypedBufferConcept)
678 .finalizeForwardDeclaration();
679
680 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
681 setupTextureType(Decl, *SemaPtr, ResourceClass::SRV, /*IsROV=*/false,
682 /*IsArray=*/false, ResourceDimension::Dim2D)
684 });
685
686 auto *PartialSpec = addVectorTexturePartialSpecialization(
687 *SemaPtr, HLSLNamespace, Decl->getDescribedClassTemplate());
688 onCompletion(PartialSpec, [this](CXXRecordDecl *Decl) {
689 setupTextureType(Decl, *SemaPtr, ResourceClass::SRV, /*IsROV=*/false,
690 /*IsArray=*/false, ResourceDimension::Dim2D)
692 });
693
694 // Texture2DArray — same as Texture2D but IsArray=true
695 Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "Texture2DArray")
696 .addSimpleTemplateParams({"element_type"}, {Float4Ty},
697 TypedBufferConcept)
698 .finalizeForwardDeclaration();
699
700 onCompletion(Decl, [this](CXXRecordDecl *Decl) {
701 setupTextureType(Decl, *SemaPtr, ResourceClass::SRV, /*IsROV=*/false,
702 /*IsArray=*/true, ResourceDimension::Dim2D)
704 });
705
706 auto *PartialSpec2DA = addVectorTexturePartialSpecialization(
707 *SemaPtr, HLSLNamespace, Decl->getDescribedClassTemplate());
708 onCompletion(PartialSpec2DA, [this](CXXRecordDecl *Decl) {
709 setupTextureType(Decl, *SemaPtr, ResourceClass::SRV, /*IsROV=*/false,
710 /*IsArray=*/true, ResourceDimension::Dim2D)
712 });
713}
714
715// Build a single overload of an HLSL atomic intrinsic in the hlsl namespace.
716// `dest` is an address-space-qualified reference; `original_value` (when
717// present) is a plain reference. The synthesized FunctionDecl aliases the
718// underlying clang builtin via BuiltinAliasAttr.
719static void buildAtomicOverload(Sema &S, NamespaceDecl *NS, StringRef FuncName,
720 StringRef BuiltinName, QualType ElemTy,
721 LangAS DestAS, bool ThreeArg) {
722 ASTContext &AST = S.getASTContext();
723
724 QualType DestTy =
725 AST.getLValueReferenceType(AST.getAddrSpaceQualType(ElemTy, DestAS));
726 QualType OrigRefTy = AST.getLValueReferenceType(ElemTy);
727
728 SmallVector<QualType, 3> ParamTypes;
729 ParamTypes.push_back(DestTy);
730 ParamTypes.push_back(ElemTy);
731 if (ThreeArg)
732 ParamTypes.push_back(OrigRefTy);
733
735 QualType FuncTy = AST.getFunctionType(AST.VoidTy, ParamTypes, EPI);
736 auto *TSInfo = AST.getTrivialTypeSourceInfo(FuncTy, SourceLocation());
737
738 IdentifierInfo &FuncII = AST.Idents.get(FuncName, tok::TokenKind::identifier);
739 DeclarationName FuncDeclName(&FuncII);
740
742 AST, NS, SourceLocation(), SourceLocation(), FuncDeclName, FuncTy, TSInfo,
743 SC_Extern, /*UsesFPIntrin=*/false, /*isInlineSpecified=*/false,
744 /*hasWrittenPrototype=*/true);
745
746 constexpr const char *ParamNames[] = {"dest", "value", "original_value"};
748 unsigned I = 0;
749 for (auto [ParamType, ParamName] : llvm::zip(ParamTypes, ParamNames)) {
750 IdentifierInfo &PII = AST.Idents.get(ParamName, tok::TokenKind::identifier);
752 AST, FD, SourceLocation(), SourceLocation(), &PII, ParamType,
754 nullptr);
755 Parm->setScopeInfo(0, I++);
756 ParmDecls.push_back(Parm);
757 }
758 FD->setParams(ParmDecls);
759
760 IdentifierInfo &BuiltinII =
761 S.getPreprocessor().getIdentifierTable().get(BuiltinName);
762 FD->addAttr(BuiltinAliasAttr::CreateImplicit(AST, &BuiltinII));
763 FD->setImplicit();
764 NS->addDecl(FD);
765}
766
767// Synthesize the InterlockedFunc overload set: {int, uint, int64_t, uint64_t}
768// x {groupshared, device} x {2-arg, 3-arg}.
770 StringRef FuncName,
771 StringRef BuiltinName) {
772 ASTContext &AST = S.getASTContext();
773 // HLSL: int64_t == long, uint64_t == unsigned long (see hlsl_basic_types.h).
774 QualType Elems[] = {AST.IntTy, AST.UnsignedIntTy, AST.LongTy,
775 AST.UnsignedLongTy};
777
778 for (QualType ElemTy : Elems)
779 for (LangAS AS : AddrSpaces)
780 for (bool ThreeArg : {false, true})
781 buildAtomicOverload(S, NS, FuncName, BuiltinName, ElemTy, AS, ThreeArg);
782}
783
784void HLSLExternalSemaSource::defineHLSLAtomicIntrinsics() {
785 defineHLSLInterlockedFunc(*SemaPtr, HLSLNamespace, "InterlockedAdd",
786 "__builtin_hlsl_interlocked_add");
787 defineHLSLInterlockedFunc(*SemaPtr, HLSLNamespace, "InterlockedOr",
788 "__builtin_hlsl_interlocked_or");
789}
790
791void HLSLExternalSemaSource::onCompletion(CXXRecordDecl *Record,
792 CompletionFunction Fn) {
793 if (!Record->isCompleteDefinition())
794 Completions.insert(std::make_pair(Record->getCanonicalDecl(), Fn));
795}
796
798 if (!isa<CXXRecordDecl>(Tag))
799 return;
800 auto Record = cast<CXXRecordDecl>(Tag);
801
802 // If this is a specialization, we need to get the underlying templated
803 // declaration and complete that.
804 if (auto TDecl = dyn_cast<ClassTemplateSpecializationDecl>(Record)) {
806 ClassTemplateDecl *Template = TDecl->getSpecializedTemplate();
808 Template->getPartialSpecializations(Partials);
809 ClassTemplatePartialSpecializationDecl *MatchedPartial = nullptr;
810 for (auto *Partial : Partials) {
811 sema::TemplateDeductionInfo Info(TDecl->getLocation());
812 if (SemaPtr->DeduceTemplateArguments(Partial, TDecl->getTemplateArgs(),
813 Info) ==
815 MatchedPartial = Partial;
816 break;
817 }
818 }
819 if (MatchedPartial)
820 Record = MatchedPartial;
821 else
822 Record = Template->getTemplatedDecl();
823 }
824 }
825 Record = Record->getCanonicalDecl();
826 auto It = Completions.find(Record);
827 if (It == Completions.end())
828 return;
829 // Move out the callback and erase before invoking it: the callback can
830 // re-enter CompleteType and mutate Completions, which invalidates It under
831 // backward-shift deletion.
832 CompletionFunction Fn = std::move(It->second);
833 Completions.erase(It);
834 Fn(Record);
835}
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)
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:805
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:5104
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:2705
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:2027
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:2216
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:3372
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:1817
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
Definition Decl.h:1850
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:2934
IdentifierTable & getIdentifierTable()
A (possibly-)qualified type.
Definition TypeBase.h:937
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:9438
Preprocessor & getPreprocessor() const
Definition Sema.h:939
ASTContext & getASTContext() const
Definition Sema.h:940
const LangOptions & getLangOpts() const
Definition Sema.h:933
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:3752
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:5814
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:8418
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:1907
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:5161
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:3328
Represents a GCC generic vector type.
Definition TypeBase.h:4239
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 & 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:905
@ 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:5981
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:5456