Skip to content

Commit 6abee77

Browse files
committed
preserve semantic name case for diagnostics
1 parent 5097f34 commit 6abee77

File tree

12 files changed

+43
-36
lines changed

12 files changed

+43
-36
lines changed

clang/lib/Parse/ParseHLSL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ void Parser::ParseHLSLAnnotations(ParsedAttributes &Attrs,
334334
SourceLocation()));
335335
ArgExprs.push_back(IntegerLiteral::Create(
336336
Ctx, llvm::APInt(1, Semantic.Explicit), Ctx.BoolTy, SourceLocation()));
337-
II = PP.getIdentifierInfo(Semantic.Name.upper());
337+
II = PP.getIdentifierInfo(Semantic.Name);
338338
break;
339339
}
340340
case ParsedAttr::UnknownAttribute: // FIXME: maybe this is obsolete?

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ bool SemaHLSL::isSemanticValid(FunctionDecl *FD, DeclaratorDecl *D) {
783783
if (!RT)
784784
return false;
785785

786-
const RecordDecl *RD = RT->getDecl();
786+
const RecordDecl *RD = RT->getOriginalDecl();
787787
for (FieldDecl *Field : RD->fields()) {
788788
if (!isSemanticValid(FD, Field))
789789
return false;
@@ -1577,7 +1577,7 @@ bool SemaHLSL::diagnosePositionType(QualType T, const ParsedAttr &AL) {
15771577

15781578
void SemaHLSL::diagnoseSystemSemanticAttr(Decl *D, const ParsedAttr &AL,
15791579
std::optional<unsigned> Index) {
1580-
StringRef SemanticName = AL.getAttrName()->getName();
1580+
std::string SemanticName = AL.getAttrName()->getName().upper();
15811581

15821582
auto *VD = cast<ValueDecl>(D);
15831583
QualType ValueType = VD->getType();
@@ -1635,7 +1635,7 @@ void SemaHLSL::handleSemanticAttr(Decl *D, const ParsedAttr &AL) {
16351635
std::optional<unsigned> Index =
16361636
ExplicitIndex ? std::optional<unsigned>(IndexValue) : std::nullopt;
16371637

1638-
if (AL.getAttrName()->getName().starts_with("SV_"))
1638+
if (AL.getAttrName()->getName().starts_with_insensitive("SV_"))
16391639
diagnoseSystemSemanticAttr(D, AL, Index);
16401640
else
16411641
Diag(AL.getLoc(), diag::err_hlsl_unknown_semantic) << AL;

clang/test/CodeGenHLSL/semantics/DispatchThreadID-noindex.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
[shader("compute")]
55
[numthreads(8,8,1)]
66
void foo(uint Idx : SV_DispatchThreadID1) {
7-
// expected-error@-1 {{semantic SV_DISPATCHTHREADID does not allow indexing}}
7+
// expected-error@-1 {{semantic SV_DispatchThreadID does not allow indexing}}
88
}

clang/test/CodeGenHLSL/semantics/SV_GroupID-noindex.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
[shader("compute")]
55
[numthreads(8,8,1)]
66
void foo(uint Idx : SV_GroupID1) {
7-
// expected-error@-1 {{semantic SV_GROUPID does not allow indexing}}
7+
// expected-error@-1 {{semantic SV_GroupID does not allow indexing}}
88
}
99

clang/test/CodeGenHLSL/semantics/SV_GroupThreadID-noindex.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
[shader("compute")]
55
[numthreads(8,8,1)]
66
void foo(uint Idx : SV_GroupThreadID1) {
7-
// expected-error@-1 {{semantic SV_GROUPTHREADID does not allow indexing}}
7+
// expected-error@-1 {{semantic SV_GroupThreadID does not allow indexing}}
88
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// RUN: %clang_cc1 -triple spirv-unknown-vulkan1.3-pixel -x hlsl -emit-llvm -finclude-default-header -disable-llvm-passes -o - %s | FileCheck %s
22

3-
// CHECK: @SV_POSITION = external hidden thread_local addrspace(7) externally_initialized constant <4 x float>, !spirv.Decorations !0
3+
// CHECK: @SV_Position = external hidden thread_local addrspace(7) externally_initialized constant <4 x float>, !spirv.Decorations !0
44

55
// CHECK: define void @main() {{.*}} {
66
float4 main(float4 p : SV_Position) {
7-
// CHECK: %[[#P:]] = load <4 x float>, ptr addrspace(7) @SV_POSITION, align 16
7+
// CHECK: %[[#P:]] = load <4 x float>, ptr addrspace(7) @SV_Position, align 16
88
// CHECK: %[[#R:]] = call spir_func <4 x float> @_Z4mainDv4_f(<4 x float> %[[#P]])
99
return p;
1010
}

clang/test/ParserHLSL/semantic_parsing.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
// expected-error@+1 {{expected HLSL Semantic identifier}}
55
void Entry(int GI : ) { }
66

7-
// expected-error@+1 {{unknown HLSL semantic 'SV_IWANTAPONY'}}
7+
// expected-error@+1 {{unknown HLSL semantic 'SV_IWantAPony'}}
88
void Pony(int GI : SV_IWantAPony) { }
99

1010
// expected-error@+3 {{expected HLSL Semantic identifier}}
@@ -37,5 +37,5 @@ void BigPony(int GI : é) { }
3737
void UTFPony(int GI : 😊) { }
3838

3939
// expected-error@+2 {{character <U+1F60A> not allowed in an identifier}}
40-
// expected-error@+1 {{unknown HLSL semantic 'PONYWITHA😊'}}
40+
// expected-error@+1 {{unknown HLSL semantic 'PonyWithA😊'}}
4141
void SmilingPony(int GI : PonyWithA😊) { }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -o - %s -verify
2+
// RUN: %clang_cc1 -triple spirv-unknown-vulkan1.3-compute -x hlsl -o - %s -verify
3+
4+
#define SomeDefine SV_IWantAPony
5+
6+
// expected-error@7 {{unknown HLSL semantic 'SV_IWantAPony'}}
7+
void Pony(int GI : SomeDefine) { }

clang/test/SemaHLSL/Semantics/groupindex.hlsl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44
[shader("compute")][numthreads(32,1,1)]
55
void compute(int GI : SV_GroupIndex) {}
66

7-
// expected-error@+2 {{attribute 'SV_GROUPINDEX' is unsupported in 'pixel' shaders}}
7+
// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'pixel' shaders}}
88
[shader("pixel")]
99
void pixel(int GI : SV_GroupIndex) {}
1010

11-
// expected-error@+2 {{attribute 'SV_GROUPINDEX' is unsupported in 'vertex' shaders}}
11+
// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'vertex' shaders}}
1212
[shader("vertex")]
1313
void vertex(int GI : SV_GroupIndex) {}
1414

15-
// expected-error@+2 {{attribute 'SV_GROUPINDEX' is unsupported in 'geometry' shaders}}
15+
// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'geometry' shaders}}
1616
[shader("geometry")]
1717
void geometry(int GI : SV_GroupIndex) {}
1818

19-
// expected-error@+2 {{attribute 'SV_GROUPINDEX' is unsupported in 'domain' shaders}}
19+
// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'domain' shaders}}
2020
[shader("domain")]
2121
void domain(int GI : SV_GroupIndex) {}
2222

23-
// expected-error@+2 {{attribute 'SV_GROUPINDEX' is unsupported in 'amplification' shaders}}
23+
// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'amplification' shaders}}
2424
[shader("amplification")][numthreads(32,1,1)]
2525
void amplification(int GI : SV_GroupIndex) {}
2626

27-
// expected-error@+2 {{attribute 'SV_GROUPINDEX' is unsupported in 'mesh' shaders}}
27+
// expected-error@+2 {{attribute 'SV_GroupIndex' is unsupported in 'mesh' shaders}}
2828
[shader("mesh")][numthreads(32,1,1)]
2929
void mesh(int GI : SV_GroupIndex) {}
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -finclude-default-header -x hlsl -ast-dump -verify -o - %s
22

33
[numthreads(8,8,1)]
4-
// expected-error@+1 {{attribute 'SV_DISPATCHTHREADID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
4+
// expected-error@+1 {{attribute 'SV_DispatchThreadID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
55
void CSMain(float ID : SV_DispatchThreadID) {
66

77
}
@@ -11,71 +11,71 @@ struct ST {
1111
float b;
1212
};
1313
[numthreads(8,8,1)]
14-
// expected-error@+1 {{attribute 'SV_DISPATCHTHREADID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
14+
// expected-error@+1 {{attribute 'SV_DispatchThreadID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
1515
void CSMain2(ST ID : SV_DispatchThreadID) {
1616

1717
}
1818

1919
void foo() {
20-
// expected-warning@+1 {{'SV_DISPATCHTHREADID' attribute only applies to parameters, non-static data members, and functions}}
20+
// expected-warning@+1 {{'SV_DispatchThreadID' attribute only applies to parameters, non-static data members, and functions}}
2121
uint V : SV_DispatchThreadID;
2222

2323
}
2424

2525
struct ST2 {
26-
// expected-warning@+1 {{'SV_DISPATCHTHREADID' attribute only applies to parameters, non-static data members, and functions}}
26+
// expected-warning@+1 {{'SV_DispatchThreadID' attribute only applies to parameters, non-static data members, and functions}}
2727
static uint X : SV_DispatchThreadID;
2828
uint s : SV_DispatchThreadID;
2929
};
3030

3131
[numthreads(8,8,1)]
32-
// expected-error@+1 {{attribute 'SV_GROUPID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
32+
// expected-error@+1 {{attribute 'SV_GroupID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
3333
void CSMain_GID(float ID : SV_GroupID) {
3434
}
3535

3636
[numthreads(8,8,1)]
37-
// expected-error@+1 {{attribute 'SV_GROUPID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
37+
// expected-error@+1 {{attribute 'SV_GroupID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
3838
void CSMain2_GID(ST GID : SV_GroupID) {
3939

4040
}
4141

4242
void foo_GID() {
43-
// expected-warning@+1 {{'SV_GROUPID' attribute only applies to parameters, non-static data members, and functions}}
43+
// expected-warning@+1 {{'SV_GroupID' attribute only applies to parameters, non-static data members, and functions}}
4444
uint GIS : SV_GroupID;
4545
}
4646

4747
struct ST2_GID {
48-
// expected-warning@+1 {{'SV_GROUPID' attribute only applies to parameters, non-static data members, and functions}}
48+
// expected-warning@+1 {{'SV_GroupID' attribute only applies to parameters, non-static data members, and functions}}
4949
static uint GID : SV_GroupID;
5050
uint s_gid : SV_GroupID;
5151
};
5252

5353
[numthreads(8,8,1)]
54-
// expected-error@+1 {{attribute 'SV_GROUPTHREADID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
54+
// expected-error@+1 {{attribute 'SV_GroupThreadID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
5555
void CSMain_GThreadID(float ID : SV_GroupThreadID) {
5656
}
5757

5858
[numthreads(8,8,1)]
59-
// expected-error@+1 {{attribute 'SV_GROUPTHREADID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
59+
// expected-error@+1 {{attribute 'SV_GroupThreadID' only applies to a field or parameter of type 'uint/uint2/uint3'}}
6060
void CSMain2_GThreadID(ST GID : SV_GroupThreadID) {
6161

6262
}
6363

6464
void foo_GThreadID() {
65-
// expected-warning@+1 {{'SV_GROUPTHREADID' attribute only applies to parameters, non-static data members, and functions}}
65+
// expected-warning@+1 {{'SV_GroupThreadID' attribute only applies to parameters, non-static data members, and functions}}
6666
uint GThreadIS : SV_GroupThreadID;
6767
}
6868

6969
struct ST2_GThreadID {
70-
// expected-warning@+1 {{'SV_GROUPTHREADID' attribute only applies to parameters, non-static data members, and functions}}
70+
// expected-warning@+1 {{'SV_GroupThreadID' attribute only applies to parameters, non-static data members, and functions}}
7171
static uint GThreadID : SV_GroupThreadID;
7272
uint s_gthreadid : SV_GroupThreadID;
7373
};
7474

7575

7676
[shader("vertex")]
77-
// expected-error@+4 {{attribute 'SV_GROUPINDEX' is unsupported in 'vertex' shaders, requires compute}}
78-
// expected-error@+3 {{attribute 'SV_DISPATCHTHREADID' is unsupported in 'vertex' shaders, requires compute}}
79-
// expected-error@+2 {{attribute 'SV_GROUPID' is unsupported in 'vertex' shaders, requires compute}}
80-
// expected-error@+1 {{attribute 'SV_GROUPTHREADID' is unsupported in 'vertex' shaders, requires compute}}
77+
// expected-error@+4 {{attribute 'SV_GroupIndex' is unsupported in 'vertex' shaders, requires compute}}
78+
// expected-error@+3 {{attribute 'SV_DispatchThreadID' is unsupported in 'vertex' shaders, requires compute}}
79+
// expected-error@+2 {{attribute 'SV_GroupID' is unsupported in 'vertex' shaders, requires compute}}
80+
// expected-error@+1 {{attribute 'SV_GroupThreadID' is unsupported in 'vertex' shaders, requires compute}}
8181
void vs_main(int GI : SV_GroupIndex, uint ID : SV_DispatchThreadID, uint GID : SV_GroupID, uint GThreadID : SV_GroupThreadID) {}

0 commit comments

Comments
 (0)