@@ -255,7 +255,9 @@ TEST_F(ParseHLSLRootSignatureTest, ValidSamplerFlagsTest) {
255255TEST_F (ParseHLSLRootSignatureTest, ValidParseRootConsantsTest) {
256256 const llvm::StringLiteral Source = R"cc(
257257 RootConstants(num32BitConstants = 1, b0),
258- RootConstants(b42, num32BitConstants = 4294967295)
258+ RootConstants(b42, space = 3, num32BitConstants = 4294967295,
259+ visibility = SHADER_VISIBILITY_HULL
260+ )
259261 )cc" ;
260262
261263 TrivialModuleLoader ModLoader;
@@ -278,12 +280,16 @@ TEST_F(ParseHLSLRootSignatureTest, ValidParseRootConsantsTest) {
278280 ASSERT_EQ (std::get<RootConstants>(Elem).Num32BitConstants , 1u );
279281 ASSERT_EQ (std::get<RootConstants>(Elem).Reg .ViewType , RegisterType::BReg);
280282 ASSERT_EQ (std::get<RootConstants>(Elem).Reg .Number , 0u );
283+ ASSERT_EQ (std::get<RootConstants>(Elem).Space , 0u );
284+ ASSERT_EQ (std::get<RootConstants>(Elem).Visibility , ShaderVisibility::All);
281285
282286 Elem = Elements[1 ];
283287 ASSERT_TRUE (std::holds_alternative<RootConstants>(Elem));
284288 ASSERT_EQ (std::get<RootConstants>(Elem).Num32BitConstants , 4294967295u );
285289 ASSERT_EQ (std::get<RootConstants>(Elem).Reg .ViewType , RegisterType::BReg);
286290 ASSERT_EQ (std::get<RootConstants>(Elem).Reg .Number , 42u );
291+ ASSERT_EQ (std::get<RootConstants>(Elem).Space , 3u );
292+ ASSERT_EQ (std::get<RootConstants>(Elem).Visibility , ShaderVisibility::Hull);
287293
288294 ASSERT_TRUE (Consumer->isSatisfied ());
289295}
@@ -469,7 +475,7 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedMandatoryRCParameterTest) {
469475 ASSERT_TRUE (Consumer->isSatisfied ());
470476}
471477
472- TEST_F (ParseHLSLRootSignatureTest, InvalidRepeatedOptionalParameterTest ) {
478+ TEST_F (ParseHLSLRootSignatureTest, InvalidRepeatedOptionalDTParameterTest ) {
473479 // This test will check that the parsing fails due the same optional
474480 // parameter being specified multiple times
475481 const llvm::StringLiteral Source = R"cc(
@@ -493,6 +499,32 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidRepeatedOptionalParameterTest) {
493499 ASSERT_TRUE (Consumer->isSatisfied ());
494500}
495501
502+ TEST_F (ParseHLSLRootSignatureTest, InvalidRepeatedOptionalRCParameterTest) {
503+ // This test will check that the parsing fails due the same optional
504+ // parameter being specified multiple times
505+ const llvm::StringLiteral Source = R"cc(
506+ RootConstants(
507+ visibility = Shader_Visibility_All,
508+ b0, num32BitConstants = 1,
509+ visibility = Shader_Visibility_Pixel
510+ )
511+ )cc" ;
512+
513+ TrivialModuleLoader ModLoader;
514+ auto PP = createPP (Source, ModLoader);
515+ auto TokLoc = SourceLocation ();
516+
517+ hlsl::RootSignatureLexer Lexer (Source, TokLoc);
518+ SmallVector<RootElement> Elements;
519+ hlsl::RootSignatureParser Parser (Elements, Lexer, *PP);
520+
521+ // Test correct diagnostic produced
522+ Consumer->setExpected (diag::err_hlsl_rootsig_repeat_param);
523+ ASSERT_TRUE (Parser.parse ());
524+
525+ ASSERT_TRUE (Consumer->isSatisfied ());
526+ }
527+
496528TEST_F (ParseHLSLRootSignatureTest, InvalidLexOverflowedNumberTest) {
497529 // This test will check that the lexing fails due to an integer overflow
498530 const llvm::StringLiteral Source = R"cc(
0 commit comments