Skip to content

Commit b9d40cb

Browse files
committed
add note to denote where the other overlapping range is
1 parent 02e9ebd commit b9d40cb

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13079,6 +13079,7 @@ def err_hlsl_resource_range_overlap: Error<
1307913079
"resource ranges %sub{subst_hlsl_format_ranges}0,1,2,3 and %sub{subst_hlsl_format_ranges}4,5,6,7 "
1308013080
"overlap within space = %8 and visibility = "
1308113081
"%select{All|Vertex|Hull|Domain|Geometry|Pixel|Amplification|Mesh}9">;
13082+
def note_hlsl_resource_range_here: Note<"overlapping resource range here">;
1308213083

1308313084
// Layout randomization diagnostics.
1308413085
def err_non_designated_init_used : Error<

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,6 +1234,10 @@ bool SemaHLSL::handleRootSignatureElements(
12341234
<< OInfo->LowerBound
12351235
<< /*unbounded=*/(OInfo->UpperBound == RangeInfo::Unbounded)
12361236
<< OInfo->UpperBound << Info->Space << CommonVis;
1237+
1238+
const hlsl::RootSignatureElement *OElem = InfoIndexMap.at(OInfo->Index);
1239+
SourceLocation OInfoLoc = OElem->getLocation();
1240+
this->Diag(OInfoLoc, diag::note_hlsl_resource_range_here);
12371241
};
12381242

12391243
// 3: Iterate through collected RangeInfos

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,61 @@
11
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - %s -verify
22

3+
// expected-note@+2 {{overlapping resource range here}}
34
// expected-error@+1 {{resource ranges b[42;42] and b[42;42] overlap within space = 0 and visibility = All}}
45
[RootSignature("CBV(b42), CBV(b42)")]
56
void bad_root_signature_0() {}
67

8+
// expected-note@+2 {{overlapping resource range here}}
79
// expected-error@+1 {{resource ranges t[0;0] and t[0;0] overlap within space = 3 and visibility = All}}
810
[RootSignature("SRV(t0, space = 3), SRV(t0, space = 3)")]
911
void bad_root_signature_1() {}
1012

13+
// expected-note@+2 {{overlapping resource range here}}
1114
// expected-error@+1 {{resource ranges u[0;0] and u[0;0] overlap within space = 0 and visibility = Pixel}}
1215
[RootSignature("UAV(u0, visibility = SHADER_VISIBILITY_PIXEL), UAV(u0, visibility = SHADER_VISIBILITY_PIXEL)")]
1316
void bad_root_signature_2() {}
1417

18+
// expected-note@+2 {{overlapping resource range here}}
1519
// expected-error@+1 {{resource ranges u[0;0] and u[0;0] overlap within space = 0 and visibility = Pixel}}
1620
[RootSignature("UAV(u0, visibility = SHADER_VISIBILITY_ALL), UAV(u0, visibility = SHADER_VISIBILITY_PIXEL)")]
1721
void bad_root_signature_3() {}
1822

23+
// expected-note@+2 {{overlapping resource range here}}
1924
// expected-error@+1 {{resource ranges u[0;0] and u[0;0] overlap within space = 0 and visibility = Pixel}}
2025
[RootSignature("UAV(u0, visibility = SHADER_VISIBILITY_PIXEL), UAV(u0, visibility = SHADER_VISIBILITY_ALL)")]
2126
void bad_root_signature_4() {}
2227

28+
// expected-note@+2 {{overlapping resource range here}}
2329
// expected-error@+1 {{resource ranges b[0;0] and b[0;0] overlap within space = 0 and visibility = All}}
2430
[RootSignature("RootConstants(num32BitConstants=4, b0), RootConstants(num32BitConstants=2, b0)")]
2531
void bad_root_signature_5() {}
2632

33+
// expected-note@+2 {{overlapping resource range here}}
2734
// expected-error@+1 {{resource ranges s[3;3] and s[3;3] overlap within space = 0 and visibility = All}}
2835
[RootSignature("StaticSampler(s3), StaticSampler(s3)")]
2936
void bad_root_signature_6() {}
3037

38+
// expected-note@+2 {{overlapping resource range here}}
3139
// expected-error@+1 {{resource ranges t[2;5] and t[0;3] overlap within space = 0 and visibility = All}}
3240
[RootSignature("DescriptorTable(SRV(t0, numDescriptors=4), SRV(t2, numDescriptors=4))")]
3341
void bad_root_signature_7() {}
3442

43+
// expected-note@+2 {{overlapping resource range here}}
3544
// expected-error@+1 {{resource ranges u[2;5] and u[0;unbounded) overlap within space = 0 and visibility = Hull}}
3645
[RootSignature("DescriptorTable(UAV(u0, numDescriptors=unbounded), visibility = SHADER_VISIBILITY_HULL), DescriptorTable(UAV(u2, numDescriptors=4))")]
3746
void bad_root_signature_8() {}
3847

48+
// expected-note@+2 {{overlapping resource range here}}
3949
// expected-error@+1 {{resource ranges b[0;2] and b[2;2] overlap within space = 0 and visibility = All}}
4050
[RootSignature("RootConstants(num32BitConstants=4, b2), DescriptorTable(CBV(b0, numDescriptors=3))")]
4151
void bad_root_signature_9() {}
4252

53+
// expected-note@+2 {{overlapping resource range here}}
4354
// expected-error@+1 {{resource ranges s[4;unbounded) and s[17;17] overlap within space = 0 and visibility = All}}
4455
[RootSignature("StaticSampler(s17), DescriptorTable(Sampler(s0, numDescriptors=3),Sampler(s4, numDescriptors=unbounded))")]
4556
void bad_root_signature_10() {}
4657

58+
// expected-note@+2 {{overlapping resource range here}}
4759
// expected-error@+1 {{resource ranges b[45;45] and b[4;unbounded) overlap within space = 0 and visibility = Geometry}}
4860
[RootSignature("DescriptorTable(CBV(b4, numDescriptors=unbounded)), CBV(b45, visibility = SHADER_VISIBILITY_GEOMETRY)")]
4961
void bad_root_signature_11() {}
@@ -55,10 +67,12 @@ void bad_root_signature_11() {}
5567
" CBV(b0, numDescriptors = 8), " \
5668
")"
5769

70+
// expected-note@+2 {{overlapping resource range here}}
5871
// expected-error@+1 {{resource ranges b[0;7] and b[1;2] overlap within space = 0 and visibility = All}}
5972
[RootSignature(ReportFirstOverlap)]
6073
void bad_root_signature_12() {}
6174

75+
// expected-note@+2 {{overlapping resource range here}}
6276
// expected-error@+1 {{resource ranges s[2;2] and s[2;2] overlap within space = 0 and visibility = Vertex}}
6377
[RootSignature("StaticSampler(s2, visibility=SHADER_VISIBILITY_ALL), DescriptorTable(Sampler(s2), visibility=SHADER_VISIBILITY_VERTEX)")]
6478
void valid_root_signature_13() {}

0 commit comments

Comments
 (0)