Skip to content

Commit 94f9146

Browse files
committed
move where the attribute string is made lowercase so error messages are in capitalization the user wrote
1 parent 6c2e22d commit 94f9146

File tree

6 files changed

+29
-27
lines changed

6 files changed

+29
-27
lines changed

clang/lib/Basic/Attributes.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,17 @@ static SmallString<64> normalizeName(const IdentifierInfo *Name,
143143
StringRef ScopeName = normalizeAttrScopeName(Scope, SyntaxUsed);
144144
StringRef AttrName = normalizeAttrName(Name, ScopeName, SyntaxUsed);
145145

146+
std::string StrAttrName = AttrName.str();
147+
if (SyntaxUsed == AttributeCommonInfo::AS_HLSLAnnotation)
148+
StrAttrName = AttrName.lower();
149+
146150
SmallString<64> FullName = ScopeName;
147151
if (!ScopeName.empty()) {
148152
assert(SyntaxUsed == AttributeCommonInfo::AS_CXX11 ||
149153
SyntaxUsed == AttributeCommonInfo::AS_C23);
150154
FullName += "::";
151155
}
152-
FullName += AttrName;
156+
FullName += StrAttrName;
153157

154158
return FullName;
155159
}

clang/lib/Parse/ParseHLSL.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ void Parser::ParseHLSLAnnotations(ParsedAttributes &Attrs,
141141
return;
142142
}
143143

144-
II = PP.getIdentifierInfo(II->getName().lower());
145-
146144
SourceLocation Loc = ConsumeToken();
147145
if (EndLoc)
148146
*EndLoc = Tok.getLocation();

clang/lib/Sema/SemaHLSL.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ void SemaHLSL::DiagnoseAttrStageMismatch(
752752
HLSLShaderAttr::ConvertEnvironmentTypeToStr(ST));
753753
});
754754
Diag(A->getLoc(), diag::err_hlsl_attr_unsupported_in_stage)
755-
<< A << llvm::Triple::getEnvironmentTypeName(Stage)
755+
<< A->getAttrName() << llvm::Triple::getEnvironmentTypeName(Stage)
756756
<< (AllowedStages.size() != 1) << join(StageStrings, ", ");
757757
}
758758

clang/test/ParserHLSL/semantic_parsing.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
// expected-error@+1 {{expected HLSL Semantic identifier}}
44
void Entry(int GI : ) { }
55

6-
// expected-error@+1 {{unknown HLSL semantic 'sv_iwantapony'}}
6+
// expected-error@+1 {{unknown HLSL semantic 'SV_IWantAPony'}}
77
void Pony(int GI : SV_IWantAPony) { }

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 and non-static data members}}
20+
// expected-warning@+1 {{'SV_DispatchThreadID' attribute only applies to parameters and non-static data members}}
2121
uint V : SV_DispatchThreadID;
2222

2323
}
2424

2525
struct ST2 {
26-
// expected-warning@+1 {{'sv_dispatchthreadid' attribute only applies to parameters and non-static data members}}
26+
// expected-warning@+1 {{'SV_DispatchThreadID' attribute only applies to parameters and non-static data members}}
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 and non-static data members}}
43+
// expected-warning@+1 {{'SV_GroupID' attribute only applies to parameters and non-static data members}}
4444
uint GIS : SV_GroupID;
4545
}
4646

4747
struct ST2_GID {
48-
// expected-warning@+1 {{'sv_groupid' attribute only applies to parameters and non-static data members}}
48+
// expected-warning@+1 {{'SV_GroupID' attribute only applies to parameters and non-static data members}}
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 and non-static data members}}
65+
// expected-warning@+1 {{'SV_GroupThreadID' attribute only applies to parameters and non-static data members}}
6666
uint GThreadIS : SV_GroupThreadID;
6767
}
6868

6969
struct ST2_GThreadID {
70-
// expected-warning@+1 {{'sv_groupthreadid' attribute only applies to parameters and non-static data members}}
70+
// expected-warning@+1 {{'SV_GroupThreadID' attribute only applies to parameters and non-static data members}}
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)