Skip to content

Commit 9befc49

Browse files
committed
update parser to invoke with version
1 parent af70ea2 commit 9befc49

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

clang/include/clang/Parse/ParseHLSLRootSignature.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ namespace hlsl {
2727

2828
class RootSignatureParser {
2929
public:
30-
RootSignatureParser(SmallVector<llvm::hlsl::rootsig::RootElement> &Elements,
30+
RootSignatureParser(llvm::dxbc::RootSignatureVersion Version,
31+
SmallVector<llvm::hlsl::rootsig::RootElement> &Elements,
3132
RootSignatureLexer &Lexer, clang::Preprocessor &PP);
3233

3334
/// Consumes tokens from the Lexer and constructs the in-memory
@@ -187,6 +188,7 @@ class RootSignatureParser {
187188
bool tryConsumeExpectedToken(ArrayRef<RootSignatureToken::Kind> Expected);
188189

189190
private:
191+
llvm::dxbc::RootSignatureVersion Version;
190192
SmallVector<llvm::hlsl::rootsig::RootElement> &Elements;
191193
RootSignatureLexer &Lexer;
192194

clang/lib/Parse/ParseDeclCXX.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4957,7 +4957,8 @@ void Parser::ParseHLSLRootSignatureAttributeArgs(ParsedAttributes &Attrs) {
49574957
// Invoke the root signature parser to construct the in-memory constructs
49584958
hlsl::RootSignatureLexer Lexer(Signature, SignatureLoc);
49594959
SmallVector<llvm::hlsl::rootsig::RootElement> RootElements;
4960-
hlsl::RootSignatureParser Parser(RootElements, Lexer, PP);
4960+
hlsl::RootSignatureParser Parser(getLangOpts().HLSLRootSigVer, RootElements,
4961+
Lexer, PP);
49614962
if (Parser.parse()) {
49624963
T.consumeClose();
49634964
return;

clang/lib/Parse/ParseHLSLRootSignature.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@ namespace hlsl {
1717

1818
using TokenKind = RootSignatureToken::Kind;
1919

20-
RootSignatureParser::RootSignatureParser(SmallVector<RootElement> &Elements,
21-
RootSignatureLexer &Lexer,
22-
Preprocessor &PP)
23-
: Elements(Elements), Lexer(Lexer), PP(PP), CurToken(SourceLocation()) {}
20+
RootSignatureParser::RootSignatureParser(
21+
llvm::dxbc::RootSignatureVersion Version,
22+
SmallVector<RootElement> &Elements, RootSignatureLexer &Lexer,
23+
Preprocessor &PP)
24+
: Version(Version), Elements(Elements), Lexer(Lexer), PP(PP),
25+
CurToken(SourceLocation()) {}
2426

2527
bool RootSignatureParser::parse() {
2628
// Iterate as many RootElements as possible
@@ -199,7 +201,7 @@ std::optional<RootDescriptor> RootSignatureParser::parseRootDescriptor() {
199201
ExpectedReg = TokenKind::uReg;
200202
break;
201203
}
202-
Descriptor.setDefaultFlags();
204+
Descriptor.setDefaultFlags(Version);
203205

204206
auto Params = parseRootDescriptorParams(ExpectedReg);
205207
if (!Params.has_value())
@@ -318,7 +320,7 @@ RootSignatureParser::parseDescriptorTableClause() {
318320
ExpectedReg = TokenKind::sReg;
319321
break;
320322
}
321-
Clause.setDefaultFlags();
323+
Clause.setDefaultFlags(Version);
322324

323325
auto Params = parseDescriptorTableClauseParams(ExpectedReg);
324326
if (!Params.has_value())

0 commit comments

Comments
 (0)