Skip to content

Commit a0750d0

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 a744555 commit a0750d0

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
@@ -5263,8 +5263,10 @@ void Parser::ParseMicrosoftRootSignatureAttributeArgs(ParsedAttributes &Attrs) {
52635263
// Check if we have already found a decl of the same name, if we haven't
52645264
// then parse the root signature string and construct the in-memory elements
52655265
if (!Actions.LookupQualifiedName(R, Actions.CurContext)) {
5266+
SourceLocation SignatureLoc =
5267+
StrLiteral.value()->getExprLoc().getLocWithOffset(1); // offset 1 for '"'
52665268
// Invoke the root signature parser to construct the in-memory constructs
5267-
hlsl::RootSignatureLexer Lexer(Signature, RootSignatureLoc);
5269+
hlsl::RootSignatureLexer Lexer(Signature, SignatureLoc);
52685270
SmallVector<llvm::hlsl::rootsig::RootElement> Elements;
52695271
hlsl::RootSignatureParser Parser(Elements, Lexer, PP);
52705272
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)