Skip to content

Commit d35bf17

Browse files
authored
[HLSL] Add a warning for implicit bindings (#135909)
Implicit bindings will cause very confusing crashes in the backend at present, so this is intended at least partially as a stop gap until we get them implemented (see #110722). However, I do think that this is useful in the longer term as well as an off-by-default warning, as it is quite easy to miss a binding or two when using explicit bindings and the results of that can be surprisingly hard to debug. I've filed #135907 to track turning this into an off-by-default warning or removing it eventually as we see fit.
1 parent 8ebdd9d commit d35bf17

File tree

59 files changed

+168
-126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+168
-126
lines changed

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,9 @@ def HLSLExtension : DiagGroup<"hlsl-extensions", [HLSL202y]>;
16121612
// Warning for mix packoffset and non-packoffset.
16131613
def HLSLMixPackOffset : DiagGroup<"mix-packoffset">;
16141614

1615+
// Warning for implicit resource bindings.
1616+
def HLSLImplicitBinding : DiagGroup<"hlsl-implicit-binding">;
1617+
16151618
// Warnings for DXIL validation
16161619
def DXILValidation : DiagGroup<"dxil-validation">;
16171620

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12734,6 +12734,7 @@ def warn_hlsl_deprecated_register_type_i: Warning<"binding type 'i' ignored. The
1273412734
def err_hlsl_unsupported_register_number : Error<"register number should be an integer">;
1273512735
def err_hlsl_expected_space : Error<"invalid space specifier '%0' used; expected 'space' followed by an integer, like space1">;
1273612736
def err_hlsl_space_on_global_constant : Error<"register space cannot be specified on global constants">;
12737+
def warn_hlsl_implicit_binding : Warning<"resource has implicit register binding">, InGroup<HLSLImplicitBinding>, DefaultError;
1273712738
def warn_hlsl_packoffset_mix : Warning<"cannot mix packoffset elements with nonpackoffset elements in a cbuffer">,
1273812739
InGroup<HLSLMixPackOffset>;
1273912740
def err_hlsl_packoffset_overlap : Error<"packoffset overlap between %0, %1">;

clang/lib/Parse/ParseHLSL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ Decl *Parser::ParseHLSLBuffer(SourceLocation &DeclEnd) {
7575
Decl *D = Actions.HLSL().ActOnStartBuffer(getCurScope(), IsCBuffer, BufferLoc,
7676
Identifier, IdentifierLoc,
7777
T.getOpenLocation());
78+
Actions.ProcessDeclAttributeList(Actions.CurScope, D, Attrs);
7879

7980
while (Tok.isNot(tok::r_brace) && Tok.isNot(tok::eof)) {
8081
// FIXME: support attribute on constants inside cbuffer/tbuffer.
@@ -98,7 +99,6 @@ Decl *Parser::ParseHLSLBuffer(SourceLocation &DeclEnd) {
9899
BufferScope.Exit();
99100
Actions.HLSL().ActOnFinishBuffer(D, DeclEnd);
100101

101-
Actions.ProcessDeclAttributeList(Actions.CurScope, D, Attrs);
102102
return D;
103103
}
104104

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,10 @@ static bool isResourceRecordTypeOrArrayOf(const Type *Ty) {
305305
return HLSLAttributedResourceType::findHandleTypeOnResource(Ty) != nullptr;
306306
}
307307

308+
static bool isResourceRecordTypeOrArrayOf(VarDecl *VD) {
309+
return isResourceRecordTypeOrArrayOf(VD->getType().getTypePtr());
310+
}
311+
308312
// Returns true if the type is a leaf element type that is not valid to be
309313
// included in HLSL Buffer, such as a resource class, empty struct, zero-sized
310314
// array, or a builtin intangible type. Returns false it is a valid leaf element
@@ -541,6 +545,10 @@ void SemaHLSL::ActOnFinishBuffer(Decl *Dcl, SourceLocation RBrace) {
541545
// create buffer layout struct
542546
createHostLayoutStructForBuffer(SemaRef, BufDecl);
543547

548+
if (std::none_of(Dcl->attr_begin(), Dcl->attr_end(),
549+
[](Attr *A) { return isa<HLSLResourceBindingAttr>(A); }))
550+
SemaRef.Diag(Dcl->getLocation(), diag::warn_hlsl_implicit_binding);
551+
544552
SemaRef.PopDeclContext();
545553
}
546554

@@ -3248,10 +3256,12 @@ void SemaHLSL::collectResourceBindingsOnVarDecl(VarDecl *VD) {
32483256
void SemaHLSL::processExplicitBindingsOnDecl(VarDecl *VD) {
32493257
assert(VD->hasGlobalStorage() && "expected global variable");
32503258

3259+
bool HasBinding = false;
32513260
for (Attr *A : VD->attrs()) {
32523261
HLSLResourceBindingAttr *RBA = dyn_cast<HLSLResourceBindingAttr>(A);
32533262
if (!RBA)
32543263
continue;
3264+
HasBinding = true;
32553265

32563266
RegisterType RT = RBA->getRegisterType();
32573267
assert(RT != RegisterType::I && "invalid or obsolete register type should "
@@ -3278,6 +3288,9 @@ void SemaHLSL::processExplicitBindingsOnDecl(VarDecl *VD) {
32783288
<< static_cast<int>(RT);
32793289
}
32803290
}
3291+
3292+
if (!HasBinding && isResourceRecordTypeOrArrayOf(VD))
3293+
SemaRef.Diag(VD->getLocation(), diag::warn_hlsl_implicit_binding);
32813294
}
32823295

32833296
static bool CastInitializer(Sema &S, ASTContext &Ctx, Expr *E,

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
1+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
22
// RUN: -DRESOURCE=ByteAddressBuffer %s | FileCheck -DRESOURCE=ByteAddressBuffer \
33
// RUN: -check-prefix=EMPTY %s
44
//
5-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
5+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
66
// RUN: -DRESOURCE=ByteAddressBuffer %s | FileCheck -DRESOURCE=ByteAddressBuffer \
77
// RUN: -check-prefixes=CHECK,CHECK-SRV,CHECK-NOSUBSCRIPT %s
88
//
9-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
9+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
1010
// RUN: -DRESOURCE=RWByteAddressBuffer %s | FileCheck -DRESOURCE=RWByteAddressBuffer \
1111
// RUN: -check-prefix=EMPTY %s
1212
//
13-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
13+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
1414
// RUN: -DRESOURCE=RWByteAddressBuffer %s | FileCheck -DRESOURCE=RWByteAddressBuffer \
1515
// RUN: -check-prefixes=CHECK,CHECK-UAV,CHECK-NOSUBSCRIPT %s
1616
//
17-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
17+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
1818
// RUN: -DRESOURCE=RasterizerOrderedByteAddressBuffer %s | FileCheck -DRESOURCE=RasterizerOrderedByteAddressBuffer \
1919
// RUN: -check-prefix=EMPTY %s
2020
//
21-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
21+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
2222
// RUN: -DRESOURCE=RasterizerOrderedByteAddressBuffer %s | FileCheck -DRESOURCE=RasterizerOrderedByteAddressBuffer \
2323
// RUN: -check-prefixes=CHECK,CHECK-UAV,CHECK-NOSUBSCRIPT %s
2424

clang/test/AST/HLSL/OutArgExpr.hlsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: rm -f %t.pch
2-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -emit-pch -finclude-default-header -o %t.pch %s
3-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -finclude-default-header -include-pch %t.pch %s -ast-dump | FileCheck --check-prefix=AST %s
4-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -finclude-default-header -include-pch %t.pch %s -ast-print | FileCheck %s
2+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-compute -emit-pch -finclude-default-header -o %t.pch %s
3+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-compute -finclude-default-header -include-pch %t.pch %s -ast-dump | FileCheck --check-prefix=AST %s
4+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-compute -finclude-default-header -include-pch %t.pch %s -ast-print | FileCheck %s
55

66

77
#ifndef TEST_HLSL

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
1+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
22
// RUN: -DRESOURCE=StructuredBuffer %s | FileCheck -DRESOURCE=StructuredBuffer \
33
// RUN: -check-prefix=EMPTY %s
44
//
5-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
5+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
66
// RUN: -DRESOURCE=StructuredBuffer %s | FileCheck -DRESOURCE=StructuredBuffer \
77
// RUN: -check-prefixes=CHECK,CHECK-SRV,CHECK-SUBSCRIPT,CHECK-LOAD %s
88
//
9-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
9+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
1010
// RUN: -DRESOURCE=RWStructuredBuffer %s | FileCheck -DRESOURCE=RWStructuredBuffer \
1111
// RUN: -check-prefix=EMPTY %s
1212
//
13-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
13+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
1414
// RUN: -DRESOURCE=RWStructuredBuffer %s | FileCheck -DRESOURCE=RWStructuredBuffer \
1515
// RUN: -check-prefixes=CHECK,CHECK-UAV,CHECK-SUBSCRIPT,CHECK-COUNTER,CHECK-LOAD %s
1616
//
17-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
17+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
1818
// RUN: -DRESOURCE=AppendStructuredBuffer %s | FileCheck -DRESOURCE=AppendStructuredBuffer \
1919
// RUN: -check-prefix=EMPTY %s
2020
//
21-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
21+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
2222
// RUN: -DRESOURCE=AppendStructuredBuffer %s | FileCheck -DRESOURCE=AppendStructuredBuffer \
2323
// RUN: -check-prefixes=CHECK,CHECK-UAV,CHECK-NOSUBSCRIPT,CHECK-APPEND %s
2424
//
25-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
25+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
2626
// RUN: -DRESOURCE=ConsumeStructuredBuffer %s | FileCheck -DRESOURCE=ConsumeStructuredBuffer \
2727
// RUN: -check-prefix=EMPTY %s
2828
//
29-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
29+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
3030
// RUN: -DRESOURCE=ConsumeStructuredBuffer %s | FileCheck -DRESOURCE=ConsumeStructuredBuffer \
3131
// RUN: -check-prefixes=CHECK,CHECK-UAV,CHECK-NOSUBSCRIPT,CHECK-CONSUME %s
3232
//
33-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
33+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
3434
// RUN: -DRESOURCE=RasterizerOrderedStructuredBuffer %s | FileCheck -DRESOURCE=RasterizerOrderedStructuredBuffer \
3535
// RUN: -check-prefix=EMPTY %s
3636
//
37-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
37+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
3838
// RUN: -DRESOURCE=RasterizerOrderedStructuredBuffer %s | FileCheck -DRESOURCE=RasterizerOrderedStructuredBuffer \
3939
// RUN: -check-prefixes=CHECK,CHECK-UAV,CHECK-ROV,CHECK-SUBSCRIPT,CHECK-LOAD %s
4040

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
1+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -DEMPTY \
22
// RUN: -DRESOURCE=RWBuffer %s | FileCheck -DRESOURCE=RWBuffer -check-prefix=EMPTY %s
33
//
4-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
4+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump \
55
// RUN: -DRESOURCE=RWBuffer %s | FileCheck -DRESOURCE=RWBuffer \
66
// RUN: -check-prefixes=CHECK,CHECK-UAV %s
77

@@ -66,7 +66,7 @@ RESOURCE<float> Buffer;
6666
// CHECK-NEXT: MemberExpr {{.*}} '__hlsl_resource_t
6767
// CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
6868
// CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]
69-
// CHECK-SAME: ' lvalue .__handle {{.*}}
69+
// CHECK-SAME: ' lvalue .__handle {{.*}}
7070
// CHECK-NEXT: CXXThisExpr {{.*}} 'const [[RESOURCE]]<element_type>' lvalue implicit this
7171
// CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' ParmVar {{.*}} 'Index' 'unsigned int'
7272
// CHECK-NEXT: AlwaysInlineAttr {{.*}} Implicit always_inline
@@ -81,7 +81,7 @@ RESOURCE<float> Buffer;
8181
// CHECK-NEXT: MemberExpr {{.*}} '__hlsl_resource_t
8282
// CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
8383
// CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]
84-
// CHECK-SAME: ' lvalue .__handle {{.*}}
84+
// CHECK-SAME: ' lvalue .__handle {{.*}}
8585
// CHECK-NEXT: CXXThisExpr {{.*}} '[[RESOURCE]]<element_type>' lvalue implicit this
8686
// CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' ParmVar {{.*}} 'Index' 'unsigned int'
8787
// CHECK-NEXT: AlwaysInlineAttr {{.*}} Implicit always_inline
@@ -96,7 +96,7 @@ RESOURCE<float> Buffer;
9696
// CHECK-NEXT: MemberExpr {{.*}} '__hlsl_resource_t
9797
// CHECK-SAME{LITERAL}: [[hlsl::resource_class(UAV)]]
9898
// CHECK-SAME{LITERAL}: [[hlsl::contained_type(element_type)]]
99-
// CHECK-SAME: ' lvalue .__handle {{.*}}
99+
// CHECK-SAME: ' lvalue .__handle {{.*}}
100100
// CHECK-NEXT: CXXThisExpr {{.*}} '[[RESOURCE]]<element_type>' lvalue implicit this
101101
// CHECK-NEXT: DeclRefExpr {{.*}} 'unsigned int' ParmVar {{.*}} 'Index' 'unsigned int'
102102
// CHECK-NEXT: AlwaysInlineAttr {{.*}} Implicit always_inline

clang/test/AST/HLSL/ast-dump-comment-cbuffer.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang_cc1 -Wdocumentation -ast-dump=json -x hlsl -triple dxil-pc-shadermodel6.3-library %s | FileCheck %s --check-prefix=JSON
2-
// RUN: %clang_cc1 -Wdocumentation -ast-dump -x hlsl -triple dxil-pc-shadermodel6.3-library %s | FileCheck %s --check-prefix=AST
1+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -Wdocumentation -ast-dump=json -x hlsl -triple dxil-pc-shadermodel6.3-library %s | FileCheck %s --check-prefix=JSON
2+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -Wdocumentation -ast-dump -x hlsl -triple dxil-pc-shadermodel6.3-library %s | FileCheck %s --check-prefix=AST
33

44
// JSON:"kind": "HLSLBufferDecl",
55
// JSON:"name": "A",

clang/test/AST/HLSL/cbuffer.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -ast-dump -o - %s | FileCheck %s
1+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.3-library -ast-dump -o - %s | FileCheck %s
22

33
struct EmptyStruct {
44
};
@@ -55,14 +55,14 @@ cbuffer CB {
5555
}
5656
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(OneFloat, __cblayout_CB), "");
5757

58-
// Check that buffer layout struct does not include resources or empty types
58+
// Check that buffer layout struct does not include resources or empty types
5959
// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 2]]:9 cbuffer CB
6060
// CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer
6161
cbuffer CB {
6262
// CHECK: VarDecl {{.*}} used a2 'hlsl_constant float'
6363
float a2;
6464
// CHECK: VarDecl {{.*}} b2 'RWBuffer<float>':'hlsl::RWBuffer<float>'
65-
RWBuffer<float> b2;
65+
RWBuffer<float> b2;
6666
// CHECK: VarDecl {{.*}} c2 'EmptyStruct'
6767
EmptyStruct c2;
6868
// CHECK: VarDecl {{.*}} d2 'float[0]'
@@ -123,7 +123,7 @@ _Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(TwoFloats, __cblay
123123

124124
// check that layout struct is created for E because because its base struct
125125
// is empty and should be eliminated, and BTypedef should reuse the previously
126-
// defined '__cblayout_B'
126+
// defined '__cblayout_B'
127127
// CHECK: HLSLBufferDecl {{.*}} line:[[# @LINE + 2]]:9 cbuffer CB
128128
// CHECK: HLSLResourceClassAttr {{.*}} Implicit CBuffer
129129
cbuffer CB {

clang/test/AST/HLSL/cbuffer_and_namespaces.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -ast-dump -o - %s | FileCheck %s
1+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.3-library -ast-dump -o - %s | FileCheck %s
22

33
// CHECK: CXXRecordDecl {{.*}} struct EmptyStruct definition
44
struct EmptyStruct {
@@ -7,11 +7,11 @@ struct EmptyStruct {
77
// CHECK: NamespaceDecl {{.*}} NS1
88
namespace NS1 {
99
// CHECK: CXXRecordDecl {{.*}} struct Foo definition
10-
struct Foo {
10+
struct Foo {
1111
float a;
1212
EmptyStruct es;
1313
};
14-
14+
1515
// CHECK: CXXRecordDecl {{.*}} struct Bar definition
1616
struct Bar {
1717
// CHECK: CXXRecordDecl {{.*}} struct Foo definition
@@ -56,7 +56,7 @@ struct CB1ExpectedShape {
5656
_Static_assert(__builtin_hlsl_is_scalarized_layout_compatible(CB1ExpectedShape, __cblayout_CB1), "");
5757

5858
namespace NS2 {
59-
struct Foo {
59+
struct Foo {
6060
float d[4];
6161
EmptyStruct es;
6262
};

clang/test/AST/HLSL/default_cbuffer.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -ast-dump -o - %s | FileCheck %s
1+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.3-library -ast-dump -o - %s | FileCheck %s
22

33
struct EmptyStruct {
44
};
@@ -14,7 +14,7 @@ struct S {
1414
float a;
1515

1616
// CHECK: VarDecl {{.*}} b 'RWBuffer<float>':'hlsl::RWBuffer<float>'
17-
RWBuffer<float> b;
17+
RWBuffer<float> b;
1818

1919
// CHECK: VarDecl {{.*}} c 'EmptyStruct'
2020
EmptyStruct c;

clang/test/AST/HLSL/is_structured_resource_element_compatible_concept.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -ast-dump-filter=__is_structured_resource_element_compatible %s | FileCheck %s
1+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -ast-dump-filter=__is_structured_resource_element_compatible %s | FileCheck %s
22

33
// CHECK: ConceptDecl {{.*}} __is_structured_resource_element_compatible
44
// CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 element_type

clang/test/AST/HLSL/is_typed_resource_element_compatible_concept.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
1+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -ast-dump-filter=__is_typed_resource_element_compatible %s | FileCheck %s
22

33
// CHECK: ConceptDecl {{.*}} __is_typed_resource_element_compatible
44
// CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 element_type

clang/test/AST/HLSL/packoffset.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple dxil-unknown-shadermodel6.3-library -S -finclude-default-header -fnative-half-type -ast-dump -x hlsl %s | FileCheck %s
1+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-unknown-shadermodel6.3-library -S -finclude-default-header -fnative-half-type -ast-dump -x hlsl %s | FileCheck %s
22

33

44
// CHECK: HLSLBufferDecl {{.*}} cbuffer A

clang/test/AST/HLSL/pch.hlsl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
1-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
2-
// RUN: -finclude-default-header -emit-pch -o %t %S/Inputs/pch.hlsl
3-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
4-
// RUN: -finclude-default-header -include-pch %t -ast-dump-all %s \
5-
// RUN: | FileCheck %s
1+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.3-library -x hlsl -finclude-default-header -emit-pch -o %t %S/Inputs/pch.hlsl
2+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.3-library -x hlsl -finclude-default-header -include-pch %t -ast-dump-all %s | FileCheck %s
63

74
// Make sure PCH works by using function declared in PCH header and declare a RWBuffer in current file.
85
// CHECK:FunctionDecl 0x[[FOO:[0-9a-f]+]] <{{.*}}:2:1, line:4:1> line:2:8 imported used foo 'float2 (float2, float2)'
9-
// CHECK:VarDecl 0x{{[0-9a-f]+}} <{{.*}}:10:1, col:23> col:23 Buffer 'hlsl::RWBuffer<float>'
6+
// CHECK:VarDecl 0x{{[0-9a-f]+}} <{{.*}}:{{[0-9]+}}:1, col:23> col:23 Buffer 'hlsl::RWBuffer<float>'
107
hlsl::RWBuffer<float> Buffer;
118

129
float2 bar(float2 a, float2 b) {

clang/test/AST/HLSL/pch_hlsl_buffer.hlsl

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
2-
// RUN: -emit-pch -o %t %s
3-
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
4-
// RUN: -include-pch %t -ast-dump-all %S/Inputs/empty.hlsl \
5-
// RUN: | FileCheck %s
1+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.3-library -x hlsl -emit-pch -o %t %s
2+
// RUN: %clang_cc1 -Wno-hlsl-implicit-binding -triple dxil-pc-shadermodel6.3-library -x hlsl -include-pch %t -ast-dump-all %S/Inputs/empty.hlsl | FileCheck %s
63

74
cbuffer A {
85
float a;
@@ -17,19 +14,19 @@ float foo() {
1714
}
1815

1916
// Make sure cbuffer/tbuffer works for PCH.
20-
// CHECK: HLSLBufferDecl {{.*}} line:7:9 imported <undeserialized declarations> cbuffer A
17+
// CHECK: HLSLBufferDecl {{.*}} line:{{[0-9]+}}:9 imported <undeserialized declarations> cbuffer A
2118
// CHECK-NEXT: HLSLResourceClassAttr {{.*}} Implicit CBuffer
2219
// CHECK-NEXT: VarDecl 0x[[A:[0-9a-f]+]] {{.*}} imported used a 'hlsl_constant float'
2320
// CHECK-NEXT: CXXRecordDecl {{.*}} imported implicit <undeserialized declarations> struct __cblayout_A definition
2421
// CHECK: FieldDecl {{.*}} imported a 'float'
2522

26-
// CHECK: HLSLBufferDecl {{.*}} line:11:9 imported <undeserialized declarations> tbuffer B
23+
// CHECK: HLSLBufferDecl {{.*}} line:{{[0-9]+}}:9 imported <undeserialized declarations> tbuffer B
2724
// CHECK-NEXT: HLSLResourceClassAttr {{.*}} Implicit SRV
2825
// CHECK-NEXT: VarDecl 0x[[B:[0-9a-f]+]] {{.*}} imported used b 'hlsl_constant float'
2926
// CHECK-NEXT: CXXRecordDecl 0x{{[0-9a-f]+}} {{.*}} imported implicit <undeserialized declarations> struct __cblayout_B definition
3027
// CHECK: FieldDecl 0x{{[0-9a-f]+}} {{.*}} imported b 'float'
3128

32-
// CHECK-NEXT: FunctionDecl {{.*}} line:15:7 imported foo 'float ()'
29+
// CHECK-NEXT: FunctionDecl {{.*}} line:{{[0-9]+}}:7 imported foo 'float ()'
3330
// CHECK-NEXT: CompoundStmt {{.*}}
3431
// CHECK-NEXT: ReturnStmt {{.*}}
3532
// CHECK-NEXT: BinaryOperator {{.*}} 'float' '+'

0 commit comments

Comments
 (0)