Skip to content

Commit 80609f4

Browse files
committed
self-review: correct retrieved start location
- increment the location by one to better point past the initial " character of a string literal - add test that demonstrates an HLSLRootSignature parsing error being propogated up and it correctly continues parsing after the closed paren enclosing the string literal
1 parent a0fd705 commit 80609f4

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

clang/lib/Parse/ParseDeclCXX.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5365,8 +5365,10 @@ void Parser::ParseMicrosoftRootSignatureAttributeArgs(ParsedAttributes &Attrs) {
53655365
// Check if we have already found a decl of the same name, if we haven't
53665366
// then parse the root signature string and construct the in-memory elements
53675367
if (!Actions.LookupQualifiedName(R, Actions.CurContext)) {
5368+
SourceLocation SignatureLoc =
5369+
StrLiteral.value()->getExprLoc().getLocWithOffset(1); // offset 1 for '"'
53685370
// Invoke the root signature parser to construct the in-memory constructs
5369-
hlsl::RootSignatureLexer Lexer(Signature, RootSignatureLoc);
5371+
hlsl::RootSignatureLexer Lexer(Signature, SignatureLoc);
53705372
SmallVector<llvm::hlsl::rootsig::RootElement> Elements;
53715373
hlsl::RootSignatureParser Parser(Elements, Lexer, PP);
53725374
if (Parser.parse()) {

clang/test/SemaHLSL/RootSignature-err.hlsl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ void bad_root_signature_2() {}
1515

1616
[RootSignature(""), RootSignature("")] // expected-warning {{attribute 'RootSignature' is already applied}}
1717
void bad_root_signature_3() {}
18+
19+
[RootSignature("DescriptorTable(), invalid")] // expected-error {{expected end of stream to denote end of parameters, or, another valid parameter of RootSignature}}
20+
void bad_root_signature_4() {}

0 commit comments

Comments
 (0)