Skip to content

Commit cf1a7fd

Browse files
committed
address Chris
1 parent 1159b02 commit cf1a7fd

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

clang/lib/Sema/HLSLExternalSemaSource.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -624,19 +624,20 @@ Expr *constructTypedBufferConstraintExpr(Sema &S, SourceLocation NameLoc,
624624

625625
// first get the "sizeof(T) <= 16" expression, as a binary operator
626626
BinaryOperator *SizeOfLEQ16 = constructSizeOfLEQ16Expr(Context, NameLoc, T);
627-
// TODO: add the '__builtin_hlsl_is_line_vector_layout_compatible' builtin
627+
// TODO: add the 'builtin_hlsl_is_typed_resource_element_compatible' builtin
628628
// and return a binary operator that evaluates the builtin on the given
629-
// template type parameter 'T'
629+
// template type parameter 'T'.
630+
// Defined in issue https://github.com/llvm/llvm-project/issues/113223
630631
return SizeOfLEQ16;
631632
}
632633

633-
ConceptDecl *constructTypedBufferConceptDecl(Sema &S) {
634-
DeclContext *DC = S.CurContext;
634+
ConceptDecl *constructTypedBufferConceptDecl(Sema &S, NamespaceDecl *NSD) {
635635
ASTContext &Context = S.getASTContext();
636+
DeclContext *DC = NSD->getDeclContext();
636637
SourceLocation DeclLoc = SourceLocation();
637638

638-
IdentifierInfo &IsValidLineVectorII =
639-
Context.Idents.get("is_valid_line_vector");
639+
IdentifierInfo &IsTypedResourceElementCompatibleII =
640+
Context.Idents.get("__is_typed_resource_element_compatible");
640641
IdentifierInfo &ElementTypeII = Context.Idents.get("element_type");
641642
TemplateTypeParmDecl *T = TemplateTypeParmDecl::Create(
642643
Context, Context.getTranslationUnitDecl(), DeclLoc, DeclLoc,
@@ -653,7 +654,8 @@ ConceptDecl *constructTypedBufferConceptDecl(Sema &S) {
653654
TemplateParameterList *ConceptParams = TemplateParameterList::Create(
654655
Context, DeclLoc, DeclLoc, {T}, DeclLoc, nullptr);
655656

656-
DeclarationName DeclName = DeclarationName(&IsValidLineVectorII);
657+
DeclarationName DeclName =
658+
DeclarationName(&IsTypedResourceElementCompatibleII);
657659
Expr *ConstraintExpr = constructTypedBufferConstraintExpr(S, DeclLoc, T);
658660

659661
// Create a ConceptDecl
@@ -672,7 +674,8 @@ ConceptDecl *constructTypedBufferConceptDecl(Sema &S) {
672674

673675
void HLSLExternalSemaSource::defineHLSLTypesWithForwardDeclarations() {
674676
CXXRecordDecl *Decl;
675-
ConceptDecl *TypeBufferConcept = constructTypedBufferConceptDecl(*SemaPtr);
677+
ConceptDecl *TypeBufferConcept =
678+
constructTypedBufferConceptDecl(*SemaPtr, HLSLNamespace);
676679

677680
Decl = BuiltinTypeDeclBuilder(*SemaPtr, HLSLNamespace, "RWBuffer")
678681
.addSimpleTemplateParams(*SemaPtr, {"element_type"},

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
// EMPTY: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit RWBuffer
1414
// 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_valid_line_vector'
15+
// EMPTY-NEXT: ConceptSpecializationExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'bool' Concept 0x{{[0-9A-Fa-f]+}} '__is_typed_resource_element_compatible'
1616
// EMPTY-NEXT: ImplicitConceptSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc>
1717
// EMPTY-NEXT: TemplateArgument type 'type-parameter-0-0'
1818
// EMPTY-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-0' dependent depth 0 index 0
@@ -34,7 +34,7 @@ RWBuffer<float> Buffer;
3434

3535
// CHECK: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit RWBuffer
3636
// 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_valid_line_vector'
37+
// CHECK-NEXT: ConceptSpecializationExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'bool' Concept 0x{{[0-9A-Fa-f]+}} '__is_typed_resource_element_compatible'
3838
// CHECK-NEXT: ImplicitConceptSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc>
3939
// CHECK-NEXT: TemplateArgument type 'type-parameter-0-0'
4040
// CHECK-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-0' dependent depth 0 index 0

clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ typedef vector<float, 3> float3;
55
RWBuffer<float3> Buffer;
66

77
// expected-error@+2 {{class template 'RWBuffer' requires template arguments}}
8-
// expected-note@*:* {{template declaration from hidden source: template <typename element_type> requires is_valid_line_vector<element_type> class RWBuffer {}}}
8+
// expected-note@*:* {{template declaration from hidden source: template <typename element_type> requires __is_typed_resource_element_compatible<element_type> class RWBuffer {}}}
99
RWBuffer BufferErr1;
1010

1111
// expected-error@+2 {{too few template arguments for class template 'RWBuffer'}}
12-
// expected-note@*:* {{template declaration from hidden source: template <typename element_type> requires is_valid_line_vector<element_type> class RWBuffer {}}}
12+
// expected-note@*:* {{template declaration from hidden source: template <typename element_type> requires __is_typed_resource_element_compatible<element_type> class RWBuffer {}}}
1313
RWBuffer<> BufferErr2;
1414

1515
struct threeDoubles {
@@ -19,7 +19,7 @@ struct threeDoubles {
1919
};
2020

2121
// expected-error@+3 {{constraints not satisfied for class template 'RWBuffer'}}
22-
// expected-note@*:* {{because 'threeDoubles' does not satisfy 'is_valid_line_vector'}}
22+
// expected-note@*:* {{because 'threeDoubles' does not satisfy '__is_typed_resource_element_compatible'}}
2323
// expected-note@*:* {{because 'sizeof(threeDoubles) <= 16UL' (24 <= 16) evaluated to false}}
2424
RWBuffer<threeDoubles> BufferErr3;
2525

0 commit comments

Comments
 (0)