Skip to content

Commit ee0ca4e

Browse files
authored
[HLSL] Add implicit resource element type concepts to AST (llvm#116413)
This PR is step one on the journey to implement resource element type validation via C++20 concepts. The PR sets up the infrastructure for injecting implicit concept decls / concept specialization expressions into the AST, which will then be evaluated after template arguments are instantiated. This is not meant to be a complete implementation of the desired validation for HLSL, there are a couple of missing elements: We need the __builtin_hlsl_is_typed_resource_element_compatible builtin to be implemented. We need other constraints, like is_intangible We need to put the first 2 points together, and construct a finalized constraint expression, which should differ between typed and raw buffers This is just an initial PR that puts some of the core infrastructure in place. This PR is an edit of llvm#112600, so that new tests that were put into main don't fail Fixes llvm#75676
1 parent 29f11f0 commit ee0ca4e

13 files changed

+319
-41
lines changed

clang/lib/Sema/HLSLExternalSemaSource.cpp

Lines changed: 173 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,9 @@ struct BuiltinTypeDeclBuilder {
289289
}
290290

291291
TemplateParameterListBuilder addTemplateArgumentList(Sema &S);
292-
BuiltinTypeDeclBuilder &addSimpleTemplateParams(Sema &S,
293-
ArrayRef<StringRef> Names);
292+
BuiltinTypeDeclBuilder &
293+
addSimpleTemplateParams(Sema &S, ArrayRef<StringRef> Names, ConceptDecl *CD);
294+
BuiltinTypeDeclBuilder &addConceptSpecializationExpr(Sema &S);
294295
};
295296

296297
struct TemplateParameterListBuilder {
@@ -312,8 +313,9 @@ struct TemplateParameterListBuilder {
312313
S.Context, Builder.Record->getDeclContext(), SourceLocation(),
313314
SourceLocation(), /* TemplateDepth */ 0, Position,
314315
&S.Context.Idents.get(Name, tok::TokenKind::identifier),
315-
/* Typename */ false,
316-
/* ParameterPack */ false);
316+
/* Typename */ true,
317+
/* ParameterPack */ false,
318+
/* HasTypeConstraint*/ false);
317319
if (!DefaultValue.isNull())
318320
Decl->setDefaultArgument(
319321
S.Context, S.getTrivialTemplateArgumentLoc(DefaultValue, QualType(),
@@ -323,19 +325,117 @@ struct TemplateParameterListBuilder {
323325
return *this;
324326
}
325327

326-
BuiltinTypeDeclBuilder &finalizeTemplateArgs() {
328+
// The concept specialization expression (CSE) constructed in
329+
// constructConceptSpecializationExpr is constructed so that it
330+
// matches the CSE that is constructed when parsing the below C++ code:
331+
//
332+
// template<typename T>
333+
// concept is_typed_resource_element_compatible =
334+
// __builtin_hlsl_typed_resource_element_compatible<T>
335+
//
336+
// template<typename element_type> requires
337+
// is_typed_resource_element_compatible<element_type>
338+
// struct RWBuffer {
339+
// element_type Val;
340+
// };
341+
//
342+
// int fn() {
343+
// RWBuffer<int> Buf;
344+
// }
345+
//
346+
// When dumping the AST and filtering for "RWBuffer", the resulting AST
347+
// structure is what we're trying to construct below, specifically the
348+
// CSE portion.
349+
ConceptSpecializationExpr *
350+
constructConceptSpecializationExpr(Sema &S, ConceptDecl *CD) {
351+
ASTContext &Context = S.getASTContext();
352+
SourceLocation Loc = Builder.Record->getBeginLoc();
353+
DeclarationNameInfo DNI(CD->getDeclName(), Loc);
354+
NestedNameSpecifierLoc NNSLoc;
355+
DeclContext *DC = Builder.Record->getDeclContext();
356+
TemplateArgumentListInfo TALI(Loc, Loc);
357+
358+
// Assume that the concept decl has just one template parameter
359+
// This parameter should have been added when CD was constructed
360+
// in getTypedBufferConceptDecl
361+
assert(CD->getTemplateParameters()->size() == 1 &&
362+
"unexpected concept decl parameter count");
363+
TemplateTypeParmDecl *ConceptTTPD = dyn_cast<TemplateTypeParmDecl>(
364+
CD->getTemplateParameters()->getParam(0));
365+
366+
// this TemplateTypeParmDecl is the template for the resource, and is
367+
// used to construct a template argumentthat will be used
368+
// to construct the ImplicitConceptSpecializationDecl
369+
TemplateTypeParmDecl *T = TemplateTypeParmDecl::Create(
370+
Context, // AST context
371+
Builder.Record->getDeclContext(), // DeclContext
372+
SourceLocation(), SourceLocation(),
373+
/*depth=*/0, // Depth in the template parameter list
374+
/*position=*/0, // Position in the template parameter list
375+
/*id=*/nullptr, // Identifier for 'T'
376+
/*Typename=*/true, // Indicates this is a 'typename' or 'class'
377+
/*ParameterPack=*/false, // Not a parameter pack
378+
/*HasTypeConstraint=*/false // Has no type constraint
379+
);
380+
381+
T->setDeclContext(DC);
382+
383+
QualType ConceptTType = Context.getTypeDeclType(ConceptTTPD);
384+
385+
// this is the 2nd template argument node, on which
386+
// the concept constraint is actually being applied: 'element_type'
387+
TemplateArgument ConceptTA = TemplateArgument(ConceptTType);
388+
389+
QualType CSETType = Context.getTypeDeclType(T);
390+
391+
// this is the 1st template argument node, which represents
392+
// the abstract type that a concept would refer to: 'T'
393+
TemplateArgument CSETA = TemplateArgument(CSETType);
394+
395+
ImplicitConceptSpecializationDecl *ImplicitCSEDecl =
396+
ImplicitConceptSpecializationDecl::Create(
397+
Context, Builder.Record->getDeclContext(), Loc, {CSETA});
398+
399+
// Constraint satisfaction is used to construct the
400+
// ConceptSpecailizationExpr, and represents the 2nd Template Argument,
401+
// located at the bottom of the sample AST above.
402+
const ConstraintSatisfaction CS(CD, {ConceptTA});
403+
TemplateArgumentLoc TAL = S.getTrivialTemplateArgumentLoc(
404+
ConceptTA, QualType(), SourceLocation());
405+
406+
TALI.addArgument(TAL);
407+
const ASTTemplateArgumentListInfo *ATALI =
408+
ASTTemplateArgumentListInfo::Create(Context, TALI);
409+
410+
// In the concept reference, ATALI is what adds the extra
411+
// TemplateArgument node underneath CSE
412+
ConceptReference *CR =
413+
ConceptReference::Create(Context, NNSLoc, Loc, DNI, CD, CD, ATALI);
414+
415+
ConceptSpecializationExpr *CSE =
416+
ConceptSpecializationExpr::Create(Context, CR, ImplicitCSEDecl, &CS);
417+
418+
return CSE;
419+
}
420+
421+
BuiltinTypeDeclBuilder &finalizeTemplateArgs(ConceptDecl *CD = nullptr) {
327422
if (Params.empty())
328423
return Builder;
424+
ConceptSpecializationExpr *CSE =
425+
CD ? constructConceptSpecializationExpr(S, CD) : nullptr;
426+
329427
auto *ParamList = TemplateParameterList::Create(S.Context, SourceLocation(),
330428
SourceLocation(), Params,
331-
SourceLocation(), nullptr);
429+
SourceLocation(), CSE);
332430
Builder.Template = ClassTemplateDecl::Create(
333431
S.Context, Builder.Record->getDeclContext(), SourceLocation(),
334432
DeclarationName(Builder.Record->getIdentifier()), ParamList,
335433
Builder.Record);
434+
336435
Builder.Record->setDescribedClassTemplate(Builder.Template);
337436
Builder.Template->setImplicit(true);
338437
Builder.Template->setLexicalDeclContext(Builder.Record->getDeclContext());
438+
339439
// NOTE: setPreviousDecl before addDecl so new decl replace old decl when
340440
// make visible.
341441
Builder.Template->setPreviousDecl(Builder.PrevTemplate);
@@ -355,13 +455,12 @@ BuiltinTypeDeclBuilder::addTemplateArgumentList(Sema &S) {
355455
return TemplateParameterListBuilder(S, *this);
356456
}
357457

358-
BuiltinTypeDeclBuilder &
359-
BuiltinTypeDeclBuilder::addSimpleTemplateParams(Sema &S,
360-
ArrayRef<StringRef> Names) {
458+
BuiltinTypeDeclBuilder &BuiltinTypeDeclBuilder::addSimpleTemplateParams(
459+
Sema &S, ArrayRef<StringRef> Names, ConceptDecl *CD = nullptr) {
361460
TemplateParameterListBuilder Builder = this->addTemplateArgumentList(S);
362461
for (StringRef Name : Names)
363462
Builder.addTypeParameter(Name);
364-
return Builder.finalizeTemplateArgs();
463+
return Builder.finalizeTemplateArgs(CD);
365464
}
366465

367466
HLSLExternalSemaSource::~HLSLExternalSemaSource() {}
@@ -472,10 +571,73 @@ static BuiltinTypeDeclBuilder setupBufferType(CXXRecordDecl *Decl, Sema &S,
472571
.addDefaultHandleConstructor(S);
473572
}
474573

574+
Expr *constructTypedBufferConstraintExpr(Sema &S, SourceLocation NameLoc,
575+
TemplateTypeParmDecl *T) {
576+
ASTContext &Context = S.getASTContext();
577+
578+
// Obtain the QualType for 'unsigned long'
579+
QualType BoolTy = Context.BoolTy;
580+
581+
// Create a QualType that points to this TemplateTypeParmDecl
582+
QualType TType = Context.getTypeDeclType(T);
583+
584+
// Create a TypeSourceInfo for the template type parameter 'T'
585+
TypeSourceInfo *TTypeSourceInfo =
586+
Context.getTrivialTypeSourceInfo(TType, NameLoc);
587+
588+
TypeTraitExpr *TypedResExpr = TypeTraitExpr::Create(
589+
Context, BoolTy, NameLoc, UTT_IsTypedResourceElementCompatible,
590+
{TTypeSourceInfo}, NameLoc, true);
591+
592+
return TypedResExpr;
593+
}
594+
595+
ConceptDecl *constructTypedBufferConceptDecl(Sema &S, NamespaceDecl *NSD) {
596+
ASTContext &Context = S.getASTContext();
597+
DeclContext *DC = NSD->getDeclContext();
598+
SourceLocation DeclLoc = SourceLocation();
599+
600+
IdentifierInfo &ElementTypeII = Context.Idents.get("element_type");
601+
TemplateTypeParmDecl *T = TemplateTypeParmDecl::Create(
602+
Context, NSD->getDeclContext(), DeclLoc, DeclLoc,
603+
/*depth=*/0,
604+
/*position=*/0,
605+
/*id=*/&ElementTypeII,
606+
/*Typename=*/true,
607+
/*ParameterPack=*/false);
608+
609+
T->setDeclContext(DC);
610+
T->setReferenced();
611+
612+
// Create and Attach Template Parameter List to ConceptDecl
613+
TemplateParameterList *ConceptParams = TemplateParameterList::Create(
614+
Context, DeclLoc, DeclLoc, {T}, DeclLoc, nullptr);
615+
616+
DeclarationName DeclName = DeclarationName(
617+
&Context.Idents.get("__is_typed_resource_element_compatible"));
618+
Expr *ConstraintExpr = constructTypedBufferConstraintExpr(S, DeclLoc, T);
619+
620+
// Create a ConceptDecl
621+
ConceptDecl *CD =
622+
ConceptDecl::Create(Context, NSD->getDeclContext(), DeclLoc, DeclName,
623+
ConceptParams, ConstraintExpr);
624+
625+
// Attach the template parameter list to the ConceptDecl
626+
CD->setTemplateParameters(ConceptParams);
627+
628+
// Add the concept declaration to the Translation Unit Decl
629+
NSD->getDeclContext()->addDecl(CD);
630+
631+
return CD;
632+
}
633+
475634
void HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
476635
CXXRecordDecl *Decl;
636+
ConceptDecl *TypedBufferConcept =
637+
constructTypedBufferConceptDecl(*SemaPtr, HLSLNamespace);
477638
Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RWBuffer")
478-
.addSimpleTemplateParams(*SemaPtr, {"element_type"})
639+
.addSimpleTemplateParams(*SemaPtr, {"element_type"},
640+
TypedBufferConcept)
479641
.Record;
480642

481643
onCompletion(Decl, [this](CXXRecordDecl *Decl) {

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5720,8 +5720,7 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT,
57205720
case UTT_IsTypedResourceElementCompatible:
57215721
assert(Self.getLangOpts().HLSL &&
57225722
"typed resource element compatible types are an HLSL-only feature");
5723-
if (Self.RequireCompleteType(TInfo->getTypeLoc().getBeginLoc(), T,
5724-
diag::err_incomplete_type))
5723+
if (T->isIncompleteType())
57255724
return false;
57265725

57275726
return Self.HLSL().IsTypedResourceElementCompatible(T);

clang/test/AST/HLSL/AppendStructuredBuffer-AST.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// instantiated specialization.
1313

1414
// EMPTY: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit AppendStructuredBuffer
15-
// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class depth 0 index 0 element_type
15+
// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> typename depth 0 index 0 element_type
1616
// EMPTY-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit <undeserialized declarations> class AppendStructuredBuffer
1717
// EMPTY-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final
1818

@@ -26,7 +26,7 @@ AppendStructuredBuffer<int> Buffer;
2626
#endif
2727

2828
// CHECK: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit AppendStructuredBuffer
29-
// CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class depth 0 index 0 element_type
29+
// CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> typename depth 0 index 0 element_type
3030
// CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit class AppendStructuredBuffer definition
3131

3232
// CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final

clang/test/AST/HLSL/ConsumeStructuredBuffer-AST.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// instantiated specialization.
1313

1414
// EMPTY: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit ConsumeStructuredBuffer
15-
// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class depth 0 index 0 element_type
15+
// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> typename depth 0 index 0 element_type
1616
// EMPTY-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit <undeserialized declarations> class ConsumeStructuredBuffer
1717
// EMPTY-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final
1818

@@ -26,7 +26,7 @@ ConsumeStructuredBuffer<int> Buffer;
2626
#endif
2727

2828
// CHECK: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit ConsumeStructuredBuffer
29-
// CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class depth 0 index 0 element_type
29+
// CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> typename depth 0 index 0 element_type
3030
// CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit class ConsumeStructuredBuffer definition
3131

3232
// CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final

clang/test/AST/HLSL/RWBuffer-AST.hlsl

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,15 @@
1111
// instantiated specialization.
1212

1313
// EMPTY: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit RWBuffer
14-
// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class depth 0 index 0 element_type
14+
// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> typename depth 0 index 0 element_type
15+
// EMPTY-NEXT: ConceptSpecializationExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'bool' Concept 0x{{[0-9A-Fa-f]+}} '__is_typed_resource_element_compatible'
16+
// EMPTY-NEXT: ImplicitConceptSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc>
17+
// EMPTY-NEXT: TemplateArgument type 'type-parameter-0-0'
18+
// EMPTY-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-0' dependent depth 0 index 0
19+
// EMPTY-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} ''
20+
// EMPTY-NEXT: TemplateArgument type 'element_type':'type-parameter-0-0'
21+
// EMPTY-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'element_type' dependent depth 0 index 0
22+
// EMPTY-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'element_type'
1523
// EMPTY-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit <undeserialized declarations> class RWBuffer
1624
// EMPTY-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final
1725

@@ -25,7 +33,15 @@ RWBuffer<float> Buffer;
2533
#endif
2634

2735
// CHECK: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit RWBuffer
28-
// CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class depth 0 index 0 element_type
36+
// CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> typename depth 0 index 0 element_type
37+
// CHECK-NEXT: ConceptSpecializationExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'bool' Concept 0x{{[0-9A-Fa-f]+}} '__is_typed_resource_element_compatible'
38+
// CHECK-NEXT: ImplicitConceptSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc>
39+
// CHECK-NEXT: TemplateArgument type 'type-parameter-0-0'
40+
// CHECK-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-0' dependent depth 0 index 0
41+
// CHECK-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} ''
42+
// CHECK-NEXT: TemplateArgument type 'element_type':'type-parameter-0-0'
43+
// CHECK-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'element_type' dependent depth 0 index 0
44+
// CHECK-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'element_type'
2945
// CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit class RWBuffer definition
3046

3147
// CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final

clang/test/AST/HLSL/RWStructuredBuffer-AST.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// instantiated specialization.
1313

1414
// EMPTY: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit RWStructuredBuffer
15-
// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class depth 0 index 0 element_type
15+
// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> typename depth 0 index 0 element_type
1616
// EMPTY-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit <undeserialized declarations> class RWStructuredBuffer
1717
// EMPTY-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final
1818

@@ -26,7 +26,7 @@ RWStructuredBuffer<int> Buffer;
2626
#endif
2727

2828
// CHECK: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit RWStructuredBuffer
29-
// CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class depth 0 index 0 element_type
29+
// CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> typename depth 0 index 0 element_type
3030
// CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit class RWStructuredBuffer definition
3131

3232
// CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final

clang/test/AST/HLSL/RasterizerOrderedStructuredBuffer-AST.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// instantiated specialization.
1313

1414
// EMPTY: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit RasterizerOrderedStructuredBuffer
15-
// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class depth 0 index 0 element_type
15+
// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> typename depth 0 index 0 element_type
1616
// EMPTY-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit <undeserialized declarations> class RasterizerOrderedStructuredBuffer
1717
// EMPTY-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final
1818

@@ -26,7 +26,7 @@ RasterizerOrderedStructuredBuffer<int> Buffer;
2626
#endif
2727

2828
// CHECK: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit RasterizerOrderedStructuredBuffer
29-
// CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class depth 0 index 0 element_type
29+
// CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> typename depth 0 index 0 element_type
3030
// CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit class RasterizerOrderedStructuredBuffer definition
3131

3232
// CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final

clang/test/AST/HLSL/StructuredBuffer-AST.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// instantiated specialization.
1313

1414
// EMPTY: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit StructuredBuffer
15-
// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class depth 0 index 0 element_type
15+
// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> typename depth 0 index 0 element_type
1616
// EMPTY-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit <undeserialized declarations> class StructuredBuffer
1717
// EMPTY-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final
1818

@@ -26,7 +26,7 @@ StructuredBuffer<float> Buffer;
2626
#endif
2727

2828
// CHECK: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit StructuredBuffer
29-
// CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class depth 0 index 0 element_type
29+
// CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> typename depth 0 index 0 element_type
3030
// CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit class StructuredBuffer definition
3131

3232
// CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -ast-dump-filter=__is_typed_resource_element_compatible %s | FileCheck %s
2+
3+
// CHECK: ConceptDecl 0x{{[0-9a-f]+}} <<invalid sloc>> <invalid sloc> __is_typed_resource_element_compatible
4+
// CHECK: |-TemplateTypeParmDecl 0x{{[0-9a-f]+}} <<invalid sloc>> <invalid sloc> referenced typename depth 0 index 0 element_type
5+
// CHECK: `-TypeTraitExpr 0x{{[0-9a-f]+}} <<invalid sloc>> 'bool' __builtin_hlsl_is_typed_resource_element_compatible
6+
// CHECK: `-TemplateTypeParmType 0x{{[0-9a-f]+}} 'element_type' dependent depth 0 index 0
7+
// CHECK: `-TemplateTypeParm 0x{{[0-9a-f]+}} 'element_type'
8+
9+
RWBuffer<float> Buffer;

0 commit comments

Comments
 (0)