@@ -254,7 +254,8 @@ TEST_F(ParseHLSLRootSignatureTest, ValidSamplerFlagsTest) {
254
254
255
255
TEST_F (ParseHLSLRootSignatureTest, ValidParseRootConsantsTest) {
256
256
const llvm::StringLiteral Source = R"cc(
257
- RootConstants()
257
+ RootConstants(num32BitConstants = 1, b0),
258
+ RootConstants(b42, num32BitConstants = 4294967295)
258
259
)cc" ;
259
260
260
261
TrivialModuleLoader ModLoader;
@@ -270,10 +271,19 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootConsantsTest) {
270
271
271
272
ASSERT_FALSE (Parser.parse ());
272
273
273
- ASSERT_EQ (Elements.size (), 1u );
274
+ ASSERT_EQ (Elements.size (), 2u );
274
275
275
276
RootElement Elem = Elements[0 ];
276
277
ASSERT_TRUE (std::holds_alternative<RootConstants>(Elem));
278
+ ASSERT_EQ (std::get<RootConstants>(Elem).Num32BitConstants , 1u );
279
+ ASSERT_EQ (std::get<RootConstants>(Elem).Reg .ViewType , RegisterType::BReg);
280
+ ASSERT_EQ (std::get<RootConstants>(Elem).Reg .Number , 0u );
281
+
282
+ Elem = Elements[1 ];
283
+ ASSERT_TRUE (std::holds_alternative<RootConstants>(Elem));
284
+ ASSERT_EQ (std::get<RootConstants>(Elem).Num32BitConstants , 4294967295u );
285
+ ASSERT_EQ (std::get<RootConstants>(Elem).Reg .ViewType , RegisterType::BReg);
286
+ ASSERT_EQ (std::get<RootConstants>(Elem).Reg .Number , 42u );
277
287
278
288
ASSERT_TRUE (Consumer->isSatisfied ());
279
289
}
@@ -367,7 +377,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidParseUnexpectedEndOfStreamTest) {
367
377
ASSERT_TRUE (Consumer->isSatisfied ());
368
378
}
369
379
370
- TEST_F (ParseHLSLRootSignatureTest, InvalidMissingParameterTest ) {
380
+ TEST_F (ParseHLSLRootSignatureTest, InvalidMissingDTParameterTest ) {
371
381
// This test will check that the parsing fails due a mandatory
372
382
// parameter (register) not being specified
373
383
const llvm::StringLiteral Source = R"cc(
@@ -391,7 +401,29 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidMissingParameterTest) {
391
401
ASSERT_TRUE (Consumer->isSatisfied ());
392
402
}
393
403
394
- TEST_F (ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryParameterTest) {
404
+ TEST_F (ParseHLSLRootSignatureTest, InvalidMissingRCParameterTest) {
405
+ // This test will check that the parsing fails due a mandatory
406
+ // parameter (num32BitConstants) not being specified
407
+ const llvm::StringLiteral Source = R"cc(
408
+ RootConstants(b0)
409
+ )cc" ;
410
+
411
+ TrivialModuleLoader ModLoader;
412
+ auto PP = createPP (Source, ModLoader);
413
+ auto TokLoc = SourceLocation ();
414
+
415
+ hlsl::RootSignatureLexer Lexer (Source, TokLoc);
416
+ SmallVector<RootElement> Elements;
417
+ hlsl::RootSignatureParser Parser (Elements, Lexer, *PP);
418
+
419
+ // Test correct diagnostic produced
420
+ Consumer->setExpected (diag::err_hlsl_rootsig_missing_param);
421
+ ASSERT_TRUE (Parser.parse ());
422
+
423
+ ASSERT_TRUE (Consumer->isSatisfied ());
424
+ }
425
+
426
+ TEST_F (ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryDTParameterTest) {
395
427
// This test will check that the parsing fails due the same mandatory
396
428
// parameter being specified multiple times
397
429
const llvm::StringLiteral Source = R"cc(
@@ -415,6 +447,28 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryParameterTest) {
415
447
ASSERT_TRUE (Consumer->isSatisfied ());
416
448
}
417
449
450
+ TEST_F (ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryRCParameterTest) {
451
+ // This test will check that the parsing fails due the same mandatory
452
+ // parameter being specified multiple times
453
+ const llvm::StringLiteral Source = R"cc(
454
+ RootConstants(num32BitConstants = 32, num32BitConstants = 24)
455
+ )cc" ;
456
+
457
+ TrivialModuleLoader ModLoader;
458
+ auto PP = createPP (Source, ModLoader);
459
+ auto TokLoc = SourceLocation ();
460
+
461
+ hlsl::RootSignatureLexer Lexer (Source, TokLoc);
462
+ SmallVector<RootElement> Elements;
463
+ hlsl::RootSignatureParser Parser (Elements, Lexer, *PP);
464
+
465
+ // Test correct diagnostic produced
466
+ Consumer->setExpected (diag::err_hlsl_rootsig_repeat_param);
467
+ ASSERT_TRUE (Parser.parse ());
468
+
469
+ ASSERT_TRUE (Consumer->isSatisfied ());
470
+ }
471
+
418
472
TEST_F (ParseHLSLRootSignatureTest, InvalidRepeatedOptionalParameterTest) {
419
473
// This test will check that the parsing fails due the same optional
420
474
// parameter being specified multiple times
0 commit comments