@@ -19,49 +19,54 @@ using TokenKind = RootSignatureToken::Kind;
1919
2020RootSignatureParser::RootSignatureParser (
2121 llvm::dxbc::RootSignatureVersion Version,
22- SmallVector<RootElement > &Elements, StringLiteral *Signature,
22+ SmallVector<RootSignatureElement > &Elements, StringLiteral *Signature,
2323 Preprocessor &PP)
2424 : Version(Version), Elements(Elements), Signature(Signature),
2525 Lexer (Signature->getString ()), PP(PP), CurToken(0 ) {}
2626
2727bool RootSignatureParser::parse () {
28- // Iterate as many RootElements as possible
28+ // Iterate as many RootSignatureElements as possible
2929 do {
30+ std::optional<RootSignatureElement> Element = std::nullopt ;
3031 if (tryConsumeExpectedToken (TokenKind::kw_RootFlags)) {
3132 auto Flags = parseRootFlags ();
3233 if (!Flags.has_value ())
3334 return true ;
34- Elements. push_back (*Flags);
35+ Element = RootSignatureElement (*Flags);
3536 }
3637
3738 if (tryConsumeExpectedToken (TokenKind::kw_RootConstants)) {
3839 auto Constants = parseRootConstants ();
3940 if (!Constants.has_value ())
4041 return true ;
41- Elements. push_back (*Constants);
42+ Element = RootSignatureElement (*Constants);
4243 }
4344
4445 if (tryConsumeExpectedToken (TokenKind::kw_DescriptorTable)) {
4546 auto Table = parseDescriptorTable ();
4647 if (!Table.has_value ())
4748 return true ;
48- Elements. push_back (*Table);
49+ Element = RootSignatureElement (*Table);
4950 }
5051
5152 if (tryConsumeExpectedToken (
5253 {TokenKind::kw_CBV, TokenKind::kw_SRV, TokenKind::kw_UAV})) {
5354 auto Descriptor = parseRootDescriptor ();
5455 if (!Descriptor.has_value ())
5556 return true ;
56- Elements. push_back (*Descriptor);
57+ Element = RootSignatureElement (*Descriptor);
5758 }
5859
5960 if (tryConsumeExpectedToken (TokenKind::kw_StaticSampler)) {
6061 auto Sampler = parseStaticSampler ();
6162 if (!Sampler.has_value ())
6263 return true ;
63- Elements. push_back (*Sampler);
64+ Element = RootSignatureElement (*Sampler);
6465 }
66+
67+ if (Element.has_value ())
68+ Elements.push_back (*Element);
69+
6570 } while (tryConsumeExpectedToken (TokenKind::pu_comma));
6671
6772 return consumeExpectedToken (TokenKind::end_of_stream,
@@ -256,7 +261,7 @@ std::optional<DescriptorTable> RootSignatureParser::parseDescriptorTable() {
256261 auto Clause = parseDescriptorTableClause ();
257262 if (!Clause.has_value ())
258263 return std::nullopt ;
259- Elements.push_back (*Clause);
264+ Elements.push_back (RootSignatureElement ( *Clause) );
260265 Table.NumClauses ++;
261266 }
262267
0 commit comments