Skip to content

Commit c59e666

Browse files
committed
improve diag for unbounded
1 parent 2ce85d7 commit c59e666

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13054,10 +13054,13 @@ def err_invalid_hlsl_resource_type: Error<
1305413054
def err_hlsl_spirv_only: Error<"%0 is only available for the SPIR-V target">;
1305513055
def err_hlsl_vk_literal_must_contain_constant: Error<"the argument to vk::Literal must be a vk::integral_constant">;
1305613056

13057+
def subst_hlsl_format_ranges: TextSubstitution<
13058+
"%select{t|u|b|s}0[%1;%select{%3]|unbounded)}2">;
13059+
1305713060
def err_hlsl_resource_range_overlap: Error<
13058-
"resource ranges %select{t|u|b|s}0[%1;%2] and %select{t|u|b|s}3[%4;%5] "
13059-
"overlap within space = %6 and visibility = "
13060-
"%select{All|Vertex|Hull|Domain|Geometry|Pixel|Amplification|Mesh}7">;
13061+
"resource ranges %sub{subst_hlsl_format_ranges}0,1,2,3 and %sub{subst_hlsl_format_ranges}4,5,6,7 "
13062+
"overlap within space = %8 and visibility = "
13063+
"%select{All|Vertex|Hull|Domain|Geometry|Pixel|Amplification|Mesh}9">;
1306113064

1306213065
// Layout randomization diagnostics.
1306313066
def err_non_designated_init_used : Error<

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,8 +1207,11 @@ bool SemaHLSL::handleRootSignatureDecl(HLSLRootSignatureDecl *D,
12071207
: Info->Visibility;
12081208
this->Diag(Loc, diag::err_hlsl_resource_range_overlap)
12091209
<< llvm::to_underlying(Info->Class) << Info->LowerBound
1210+
<< /*unbounded=*/(Info->UpperBound == RangeInfo::Unbounded)
12101211
<< Info->UpperBound << llvm::to_underlying(OInfo->Class)
1211-
<< OInfo->LowerBound << OInfo->UpperBound << Info->Space << CommonVis;
1212+
<< OInfo->LowerBound
1213+
<< /*unbounded=*/(OInfo->UpperBound == RangeInfo::Unbounded)
1214+
<< OInfo->UpperBound << Info->Space << CommonVis;
12121215
};
12131216

12141217
// 3: Iterate through collected RangeInfos

clang/test/SemaHLSL/RootSignature-resource-ranges-err.hlsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@ void bad_root_signature_6() {}
3232
[RootSignature("DescriptorTable(SRV(t0, numDescriptors=4), SRV(t2, numDescriptors=4))")]
3333
void bad_root_signature_7() {}
3434

35-
// expected-error@+1 {{resource ranges u[2;5] and u[0;4294967295] overlap within space = 0 and visibility = Hull}}
35+
// expected-error@+1 {{resource ranges u[2;5] and u[0;unbounded) overlap within space = 0 and visibility = Hull}}
3636
[RootSignature("DescriptorTable(UAV(u0, numDescriptors=unbounded), visibility = SHADER_VISIBILITY_HULL), DescriptorTable(UAV(u2, numDescriptors=4))")]
3737
void bad_root_signature_8() {}
3838

3939
// expected-error@+1 {{resource ranges b[0;2] and b[2;2] overlap within space = 0 and visibility = All}}
4040
[RootSignature("RootConstants(num32BitConstants=4, b2), DescriptorTable(CBV(b0, numDescriptors=3))")]
4141
void bad_root_signature_9() {}
4242

43-
// expected-error@+1 {{resource ranges s[4;4294967295] and s[17;17] overlap within space = 0 and visibility = All}}
43+
// expected-error@+1 {{resource ranges s[4;unbounded) and s[17;17] overlap within space = 0 and visibility = All}}
4444
[RootSignature("StaticSampler(s17), DescriptorTable(Sampler(s0, numDescriptors=3),Sampler(s4, numDescriptors=unbounded))")]
4545
void bad_root_signature_10() {}
4646

47-
// expected-error@+1 {{resource ranges b[45;45] and b[4;4294967295] overlap within space = 0 and visibility = Geometry}}
47+
// expected-error@+1 {{resource ranges b[45;45] and b[4;unbounded) overlap within space = 0 and visibility = Geometry}}
4848
[RootSignature("DescriptorTable(CBV(b4, numDescriptors=unbounded)), CBV(b45, visibility = SHADER_VISIBILITY_GEOMETRY)")]
4949
void bad_root_signature_11() {}
5050

0 commit comments

Comments
 (0)