Skip to content

Commit e20bf28

Browse files
authored
[HLSL] Replace element_type* handles in HLSLExternalSemaSource with __hlsl_resource_t builtin type (#110079)
Replace `element_type*` handles in HLSLExternalSemaSource with `__hlsl_resource_t` builtin type. The handle used to be defined as `element_type*` which was used by the provisional subscript operator implementation. Now that the handle is `__hlsl_resource_t` the subscript placeholder implementation was updated to add `element_type* e;` field to the resource struct. and return a reference to that. This field is just a temporary workaround until the indexing is implemented properly in #95956, at which point the field will be removed. This seemed like a better solution than disabling many of the existing tests that already use the `[]` operator. One test has to be disabled nevertheless because an error based on interactions of const and template instantiation (potential bug that can be investigated once indexing is implemented the right way). Fixes #84824
1 parent 6292f11 commit e20bf28

File tree

9 files changed

+62
-78
lines changed

9 files changed

+62
-78
lines changed

clang/include/clang/AST/Type.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6191,7 +6191,9 @@ class HLSLAttributedResourceType : public Type, public llvm::FoldingSetNode {
61916191

61926192
HLSLAttributedResourceType(QualType Canon, QualType Wrapped,
61936193
QualType Contained, const Attributes &Attrs)
6194-
: Type(HLSLAttributedResource, Canon, Wrapped->getDependence()),
6194+
: Type(HLSLAttributedResource, Canon,
6195+
Contained.isNull() ? TypeDependence::None
6196+
: Contained->getDependence()),
61956197
WrappedType(Wrapped), ContainedType(Contained), Attrs(Attrs) {}
61966198

61976199
public:

clang/lib/AST/ASTContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2272,8 +2272,8 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const {
22722272
#include "clang/Basic/AMDGPUTypes.def"
22732273
#define HLSL_INTANGIBLE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
22742274
#include "clang/Basic/HLSLIntangibleTypes.def"
2275-
Width = 0;
2276-
Align = 8;
2275+
Width = Target->getPointerWidth(LangAS::Default);
2276+
Align = Target->getPointerAlign(LangAS::Default);
22772277
break;
22782278
}
22792279
break;

clang/lib/Sema/HLSLExternalSemaSource.cpp

Lines changed: 34 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -117,33 +117,30 @@ struct BuiltinTypeDeclBuilder {
117117
if (Record->isCompleteDefinition())
118118
return *this;
119119

120+
ASTContext &Ctx = S.getASTContext();
120121
TypeSourceInfo *ElementTypeInfo = nullptr;
121122

122-
QualType Ty = Record->getASTContext().VoidPtrTy;
123+
QualType ElemTy = Ctx.Char8Ty;
123124
if (Template) {
124125
if (const auto *TTD = dyn_cast<TemplateTypeParmDecl>(
125126
Template->getTemplateParameters()->getParam(0))) {
126-
Ty = Record->getASTContext().getPointerType(
127-
QualType(TTD->getTypeForDecl(), 0));
128-
QualType ElemType = QualType(TTD->getTypeForDecl(), 0);
129-
ElementTypeInfo = S.getASTContext().getTrivialTypeSourceInfo(
130-
ElemType, SourceLocation());
127+
ElemTy = QualType(TTD->getTypeForDecl(), 0);
131128
}
132129
}
130+
ElementTypeInfo = Ctx.getTrivialTypeSourceInfo(ElemTy, SourceLocation());
133131

134132
// add handle member with resource type attributes
135133
QualType AttributedResTy = QualType();
136134
SmallVector<const Attr *> Attrs = {
137-
HLSLResourceClassAttr::CreateImplicit(Record->getASTContext(), RC),
138-
IsROV ? HLSLROVAttr::CreateImplicit(Record->getASTContext()) : nullptr,
139-
RawBuffer ? HLSLRawBufferAttr::CreateImplicit(Record->getASTContext())
140-
: nullptr,
141-
ElementTypeInfo ? HLSLContainedTypeAttr::CreateImplicit(
142-
Record->getASTContext(), ElementTypeInfo)
143-
: nullptr};
144-
Attr *ResourceAttr =
145-
HLSLResourceAttr::CreateImplicit(Record->getASTContext(), RK);
146-
if (CreateHLSLAttributedResourceType(S, Ty, Attrs, AttributedResTy))
135+
HLSLResourceClassAttr::CreateImplicit(Ctx, RC),
136+
IsROV ? HLSLROVAttr::CreateImplicit(Ctx) : nullptr,
137+
RawBuffer ? HLSLRawBufferAttr::CreateImplicit(Ctx) : nullptr,
138+
ElementTypeInfo
139+
? HLSLContainedTypeAttr::CreateImplicit(Ctx, ElementTypeInfo)
140+
: nullptr};
141+
Attr *ResourceAttr = HLSLResourceAttr::CreateImplicit(Ctx, RK);
142+
if (CreateHLSLAttributedResourceType(S, Ctx.HLSLResourceTy, Attrs,
143+
AttributedResTy))
147144
addMemberVariable("h", AttributedResTy, {ResourceAttr}, Access);
148145
return *this;
149146
}
@@ -214,14 +211,14 @@ struct BuiltinTypeDeclBuilder {
214211
assert(Fields.count("h") > 0 &&
215212
"Subscript operator must be added after the handle.");
216213

217-
FieldDecl *Handle = Fields["h"];
218214
ASTContext &AST = Record->getASTContext();
219-
220-
assert(Handle->getType().getCanonicalType() != AST.VoidPtrTy &&
221-
"Not yet supported for void pointer handles.");
222-
223-
QualType ElemTy =
224-
QualType(Handle->getType()->getPointeeOrArrayElementType(), 0);
215+
QualType ElemTy = AST.Char8Ty;
216+
if (Template) {
217+
if (const auto *TTD = dyn_cast<TemplateTypeParmDecl>(
218+
Template->getTemplateParameters()->getParam(0))) {
219+
ElemTy = QualType(TTD->getTypeForDecl(), 0);
220+
}
221+
}
225222
QualType ReturnTy = ElemTy;
226223

227224
FunctionProtoType::ExtProtoInfo ExtInfo;
@@ -257,22 +254,23 @@ struct BuiltinTypeDeclBuilder {
257254
auto FnProtoLoc = TSInfo->getTypeLoc().getAs<FunctionProtoTypeLoc>();
258255
FnProtoLoc.setParam(0, IdxParam);
259256

257+
// FIXME: Placeholder to make sure we return the correct type - create
258+
// field of element_type and return reference to it. This field will go
259+
// away once indexing into resources is properly implemented in
260+
// llvm/llvm-project#95956.
261+
if (Fields.count("e") == 0) {
262+
addMemberVariable("e", ElemTy, {});
263+
}
264+
FieldDecl *ElemFieldDecl = Fields["e"];
265+
260266
auto *This =
261267
CXXThisExpr::Create(AST, SourceLocation(),
262268
MethodDecl->getFunctionObjectParameterType(), true);
263-
auto *HandleAccess = MemberExpr::CreateImplicit(
264-
AST, This, false, Handle, Handle->getType(), VK_LValue, OK_Ordinary);
265-
266-
auto *IndexExpr = DeclRefExpr::Create(
267-
AST, NestedNameSpecifierLoc(), SourceLocation(), IdxParam, false,
268-
DeclarationNameInfo(IdxParam->getDeclName(), SourceLocation()),
269-
AST.UnsignedIntTy, VK_PRValue);
270-
271-
auto *Array =
272-
new (AST) ArraySubscriptExpr(HandleAccess, IndexExpr, ElemTy, VK_LValue,
273-
OK_Ordinary, SourceLocation());
274-
275-
auto *Return = ReturnStmt::Create(AST, SourceLocation(), Array, nullptr);
269+
Expr *ElemField = MemberExpr::CreateImplicit(
270+
AST, This, false, ElemFieldDecl, ElemFieldDecl->getType(), VK_LValue,
271+
OK_Ordinary);
272+
auto *Return =
273+
ReturnStmt::Create(AST, SourceLocation(), ElemField, nullptr);
276274

277275
MethodDecl->setBody(CompoundStmt::Create(AST, {Return}, FPOptionsOverride(),
278276
SourceLocation(),

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

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,45 +29,35 @@ RWBuffer<float> Buffer;
2929
// CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit class RWBuffer definition
3030

3131
// CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final
32-
// CHECK-NEXT: implicit h 'element_type *
32+
// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit h '__hlsl_resource_t
3333
// CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
3434
// CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]
35-
// CHECK-SAME:':'element_type *'
35+
// CHECK-SAME: ':'__hlsl_resource_t'
3636
// CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit TypedBuffer
3737

3838
// CHECK: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> operator[] 'element_type &const (unsigned int) const'
3939
// CHECK-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Idx 'unsigned int'
4040
// CHECK-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>>
4141
// CHECK-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>>
42-
// CHECK-NEXT: ArraySubscriptExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' lvalue
43-
// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type *
44-
// CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
45-
// CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]
46-
// CHECK-SAME: ':'element_type *' lvalue .h 0x{{[0-9A-Fa-f]+}}
42+
// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' lvalue .e 0x{{[0-9A-Fa-f]+}}
4743
// CHECK-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'const RWBuffer<element_type>' lvalue implicit this
48-
// CHECK-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' ParmVar 0x{{[0-9A-Fa-f]+}} 'Idx' 'unsigned int'
4944
// CHECK-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit always_inline
5045

5146
// CHECK-NEXT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> operator[] 'element_type &(unsigned int)'
5247
// CHECK-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Idx 'unsigned int'
5348
// CHECK-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>>
5449
// CHECK-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>>
55-
// CHECK-NEXT: ArraySubscriptExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' lvalue
56-
// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type *
57-
// CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
58-
// CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]
59-
// CHECK-SAME: ':'element_type *' lvalue .h 0x{{[0-9A-Fa-f]+}}
50+
// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' lvalue .e 0x{{[0-9A-Fa-f]+}}
6051
// CHECK-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'RWBuffer<element_type>' lvalue implicit this
61-
// CHECK-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' ParmVar 0x{{[0-9A-Fa-f]+}} 'Idx' 'unsigned int'
6252
// CHECK-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit always_inline
6353

6454
// CHECK: ClassTemplateSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class RWBuffer definition
6555

6656
// CHECK: TemplateArgument type 'float'
6757
// CHECK-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'float'
6858
// CHECK-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final
69-
// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit h 'float *
59+
// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit h '__hlsl_resource_t
7060
// CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
7161
// CHECK-SAME{LITERAL}: [[hlsl::contained_type(float)]]
72-
// CHECK-SAME: ':'float *'
62+
// CHECK-SAME: ':'__hlsl_resource_t'
7363
// CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit TypedBuffer

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

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,49 +30,37 @@ StructuredBuffer<float> Buffer;
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
33-
// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit h 'element_type *
33+
// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit h '__hlsl_resource_t
3434
// CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
3535
// CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]]
3636
// CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]
37-
// CHECK-SAME: ':'element_type *'
37+
// CHECK-SAME: ':'__hlsl_resource_t'
3838
// CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit TypedBuffer
3939

4040
// CHECK: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> operator[] 'element_type &const (unsigned int) const'
4141
// CHECK-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Idx 'unsigned int'
4242
// CHECK-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>>
4343
// CHECK-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>>
44-
// CHECK-NEXT: ArraySubscriptExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' lvalue
45-
// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type *
46-
// CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
47-
// CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]]
48-
// CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]
49-
// CHECK-SAME: ':'element_type *' lvalue .h 0x{{[0-9A-Fa-f]+}}
44+
// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' lvalue .e 0x{{[0-9A-Fa-f]+}}
5045
// CHECK-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'const StructuredBuffer<element_type>' lvalue implicit this
51-
// CHECK-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' ParmVar 0x{{[0-9A-Fa-f]+}} 'Idx' 'unsigned int'
5246
// CHECK-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit always_inline
5347

5448
// CHECK-NEXT: CXXMethodDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> operator[] 'element_type &(unsigned int)'
5549
// CHECK-NEXT: ParmVarDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> Idx 'unsigned int'
5650
// CHECK-NEXT: CompoundStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>>
5751
// CHECK-NEXT: ReturnStmt 0x{{[0-9A-Fa-f]+}} <<invalid sloc>>
58-
// CHECK-NEXT: ArraySubscriptExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' lvalue
59-
// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type *
60-
// CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
61-
// CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]]
62-
// CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]
63-
// CHECK-SAME: ':'element_type *' lvalue .h 0x{{[0-9A-Fa-f]+}}
52+
// CHECK-NEXT: MemberExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'element_type' lvalue .e 0x{{[0-9A-Fa-f]+}}
6453
// CHECK-NEXT: CXXThisExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'StructuredBuffer<element_type>' lvalue implicit this
65-
// CHECK-NEXT: DeclRefExpr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> 'unsigned int' ParmVar 0x{{[0-9A-Fa-f]+}} 'Idx' 'unsigned int'
6654
// CHECK-NEXT: AlwaysInlineAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit always_inline
6755

6856
// CHECK: ClassTemplateSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> class StructuredBuffer definition
6957

7058
// CHECK: TemplateArgument type 'float'
7159
// CHECK-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'float'
7260
// CHECK-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit final
73-
// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit h 'float *
61+
// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> implicit h '__hlsl_resource_t
7462
// CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
7563
// CHECK-SAME{LITERAL}: [[hlsl::raw_buffer]]
7664
// CHECK-SAME{LITERAL}: [[hlsl::contained_type(float)]]
77-
// CHECK-SAME: ':'float *'
65+
// CHECK-SAME: ':'__hlsl_resource_t'
7866
// CHECK-NEXT: HLSLResourceAttr 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> Implicit TypedBuffer

clang/test/CodeGenHLSL/buffer-array-operator.hlsl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s
22

3+
// XFAIL: *
4+
// Resource indexing will be properly implemented in llvm/llvm-project#95956
5+
36
const RWBuffer<float> In;
47
RWBuffer<float> Out;
58

clang/test/CodeGenHLSL/implicit-norecurse-attrib.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ uint Find(Node SortedTree[MAX], uint key) {
3131
}
3232

3333
// CHECK: Function Attrs:{{.*}}norecurse
34-
// CHECK: define noundef i1 @"?InitTree@@YA_NY0GE@UNode@@V?$RWBuffer@T?$__vector@I$03@__clang@@@hlsl@@I@Z"(ptr noundef byval([100 x %struct.Node]) align 4 %tree, ptr noundef byval(%"class.hlsl::RWBuffer") align 4 %encodedTree, i32 noundef %maxDepth) [[ExtAttr:\#[0-9]+]]
34+
// CHECK: define noundef i1 @"?InitTree@@YA_NY0GE@UNode@@V?$RWBuffer@T?$__vector@I$03@__clang@@@hlsl@@I@Z"(ptr noundef byval([100 x %struct.Node]) align 4 %tree, ptr noundef byval(%"class.hlsl::RWBuffer") align 16 %encodedTree, i32 noundef %maxDepth) [[ExtAttr:\#[0-9]+]]
3535
// CHECK: ret i1
3636
// Initialize tree with given buffer
3737
// Imagine the inout works

clang/test/ParserHLSL/hlsl_resource_handle_attrs.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33
// CHECK: -ClassTemplateSpecializationDecl 0x{{[0-9a-f]+}} <<invalid sloc>> <invalid sloc> class RWBuffer definition implicit_instantiation
44
// CHECK: -TemplateArgument type 'float'
55
// CHECK: `-BuiltinType 0x{{[0-9a-f]+}} 'float'
6-
// CHECK: -FieldDecl 0x{{[0-9a-f]+}} <<invalid sloc>> <invalid sloc> implicit h 'float *
6+
// CHECK: -FieldDecl 0x{{[0-9a-f]+}} <<invalid sloc>> <invalid sloc> implicit h '__hlsl_resource_t
77
// CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
88
// CHECK-SAME{LITERAL}: [[hlsl::contained_type(float)]]
9-
// CHECK-SAME: ':'float *'
9+
// CHECK-SAME: ':'__hlsl_resource_t'
1010
// CHECK: -HLSLResourceAttr 0x{{[0-9a-f]+}} <<invalid sloc>> Implicit TypedBuffer
1111
RWBuffer<float> Buffer1;
1212

1313
// CHECK: -ClassTemplateSpecializationDecl 0x{{[0-9a-f]+}} <<invalid sloc>> <invalid sloc> class RasterizerOrderedBuffer definition implicit_instantiation
1414
// CHECK: -TemplateArgument type 'vector<float, 4>'
1515
// CHECK: `-ExtVectorType 0x{{[0-9a-f]+}} 'vector<float, 4>' 4
1616
// CHECK: `-BuiltinType 0x{{[0-9a-f]+}} 'float'
17-
// CHECK: -FieldDecl 0x{{[0-9a-f]+}} <<invalid sloc>> <invalid sloc> implicit h 'vector<float *, 4>
17+
// CHECK: -FieldDecl 0x{{[0-9a-f]+}} <<invalid sloc>> <invalid sloc> implicit h '__hlsl_resource_t
1818
// CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]
1919
// CHECK-SAME{LITERAL}: [[hlsl::is_rov]]
2020
// CHECK-SAME{LITERAL}: [[hlsl::contained_type(vector<float, 4>)]]
21-
// CHECK-SAME: ':'vector<float *, 4>'
21+
// CHECK-SAME: ':'__hlsl_resource_t'
2222
// CHECK: -HLSLResourceAttr 0x{{[0-9a-f]+}} <<invalid sloc>> Implicit TypedBuffer
2323
RasterizerOrderedBuffer<vector<float, 4> > BufferArray3[4];

clang/test/SemaHLSL/Types/Traits/IsIntangibleType.hlsl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,6 @@ template<typename T> struct SimpleTemplate {
7676
};
7777
_Static_assert(__builtin_hlsl_is_intangible(SimpleTemplate<__hlsl_resource_t>), "");
7878
_Static_assert(!__builtin_hlsl_is_intangible(SimpleTemplate<float>), "");
79+
80+
_Static_assert(__builtin_hlsl_is_intangible(RWBuffer<float>), "");
81+
_Static_assert(__builtin_hlsl_is_intangible(StructuredBuffer<Simple>), "");

0 commit comments

Comments
 (0)