Skip to content

Commit e042f72

Browse files
committed
desugar types and check for resource builtin type
1 parent a12bcbc commit e042f72

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,14 +282,15 @@ static bool isResourceRecordTypeOrArrayOf(const Type *Ty) {
282282
// array, or a builtin intangible type. Returns false it is a valid leaf element
283283
// type or if it is a record type that needs to be inspected further.
284284
static bool isInvalidConstantBufferLeafElementType(const Type *Ty) {
285+
Ty = Ty->getUnqualifiedDesugaredType();
285286
if (isResourceRecordTypeOrArrayOf(Ty))
286287
return true;
287288
if (Ty->isRecordType())
288289
return Ty->getAsCXXRecordDecl()->isEmpty();
289290
if (Ty->isConstantArrayType() &&
290291
isZeroSizedArray(cast<ConstantArrayType>(Ty)))
291292
return true;
292-
if (Ty->isHLSLBuiltinIntangibleType())
293+
if (Ty->isHLSLBuiltinIntangibleType() || Ty->isHLSLAttributedResourceType())
293294
return true;
294295
return false;
295296
}

clang/test/AST/HLSL/cbuffer.hlsl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ cbuffer CB {
7575
groupshared float g2;
7676
// CHECK: VarDecl {{.*}} e2 'hlsl_constant float'
7777
float e2;
78+
// CHECK: VarDecl {{.*}} h2 '__hlsl_resource_t'
79+
__hlsl_resource_t h2;
7880
// CHECK: CXXRecordDecl {{.*}} implicit referenced struct __cblayout_CB_1 definition
7981
// CHECK: PackedAttr
8082
// CHECK-NEXT: FieldDecl {{.*}} a2 'float'

0 commit comments

Comments
 (0)