Skip to content

[HLSL][RootSignature] Use "stringified" version for diagnostic output of punctuator tokens #145827

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions clang/include/clang/Lex/LexHLSLRootSignature.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ operator<<(const DiagnosticBuilder &DB, const RootSignatureToken::Kind Kind) {
case RootSignatureToken::Kind::X: \
DB << SPELLING; \
break;
#define PUNCTUATOR(X, SPELLING) \
case RootSignatureToken::Kind::pu_##X: \
DB << #SPELLING; \
break;
#include "clang/Lex/HLSLRootSignatureTokenKinds.def"
}
return DB;
Expand Down
4 changes: 4 additions & 0 deletions clang/test/SemaHLSL/RootSignature-err.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ void bad_root_signature_3() {}

[RootSignature("DescriptorTable(), invalid")] // expected-error {{expected end of stream to denote end of parameters, or, another valid parameter of RootSignature}}
void bad_root_signature_4() {}

// expected-error@+1 {{expected ')' to denote end of parameters, or, another valid parameter of RootConstants}}
[RootSignature("RootConstants(b0, num32BitConstants = 1, invalid)")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I missing a detail here? The parens are matched in this test case right? If so this error message would send me down a very wrong path.

Maybe that is because I'm not familiar with rootsigs, maybe someone more familiar with them would understand the error better

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also I'm aware this comment isn't related to the actual fix of the PR so it's not blocking, just a side point

Copy link
Contributor Author

@inbelic inbelic Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback, when you work with the code for months and write the diagnostic it is always makes sense to yourself.

Note: There is some missing info here, as it doesn't have where the diagnostic is pointing in the source location.
In this case it would be pointing right after the comma, and the desired interpretation would be:
"after this comma it is expected that we should either have a ')' to denote the end of parameters or another valid parameter of RootConstants".

With that being said, I am very open to feedback and I can see the confusion!

I will create a todo to take another look at clarifying the diagnostic messages.

void bad_root_signature_5() {}