Skip to content

Commit 17d8022

Browse files
inbelicAnthony Tran
authored andcommitted
[HLSL][RootSignature] Use "stringified" version for diagnostic output of punctuator tokens (llvm#145827)
This pr will corrects the output with a stringified version of a puncuator (eg `')'`) instead of its ascii value. - Update `LexHLSLRootSignature` to fix the `DiagnosticBuilder` `operator<<` overload to correclty format the puncuator - Add testcase demonstrating the stringified version is output Resolves llvm#145814.
1 parent 7a2887a commit 17d8022

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

clang/include/clang/Lex/LexHLSLRootSignature.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ operator<<(const DiagnosticBuilder &DB, const RootSignatureToken::Kind Kind) {
5050
case RootSignatureToken::Kind::X: \
5151
DB << SPELLING; \
5252
break;
53+
#define PUNCTUATOR(X, SPELLING) \
54+
case RootSignatureToken::Kind::pu_##X: \
55+
DB << #SPELLING; \
56+
break;
5357
#include "clang/Lex/HLSLRootSignatureTokenKinds.def"
5458
}
5559
return DB;

clang/test/SemaHLSL/RootSignature-err.hlsl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ void bad_root_signature_3() {}
1818

1919
[RootSignature("DescriptorTable(), invalid")] // expected-error {{expected end of stream to denote end of parameters, or, another valid parameter of RootSignature}}
2020
void bad_root_signature_4() {}
21+
22+
// expected-error@+1 {{expected ')' to denote end of parameters, or, another valid parameter of RootConstants}}
23+
[RootSignature("RootConstants(b0, num32BitConstants = 1, invalid)")]
24+
void bad_root_signature_5() {}

0 commit comments

Comments
 (0)