@@ -1428,4 +1428,214 @@ TEST_F(ParseHLSLRootSignatureTest, InvalidVisibilityValueTest) {
14281428 ASSERT_TRUE (Consumer->isSatisfied ());
14291429}
14301430
1431+ TEST_F (ParseHLSLRootSignatureTest, InvalidRegisterValueTest) {
1432+ // This test will check that an error is produced when there is a invalid
1433+ // value of a parameter
1434+ const llvm::StringLiteral Source = R"cc(
1435+ StaticSampler(
1436+ b0
1437+ )
1438+ )cc" ;
1439+
1440+ auto Ctx = createMinimalASTContext ();
1441+ StringLiteral *Signature = wrapSource (Ctx, Source);
1442+
1443+ TrivialModuleLoader ModLoader;
1444+ auto PP = createPP (Source, ModLoader);
1445+
1446+ SmallVector<RootSignatureElement> Elements;
1447+ hlsl::RootSignatureParser Parser (RootSignatureVersion::V1_1, Elements,
1448+ Signature, *PP);
1449+
1450+ // Test correct diagnostic produced
1451+ Consumer->setExpected (diag::err_hlsl_invalid_token);
1452+ ASSERT_TRUE (Parser.parse ());
1453+
1454+ ASSERT_TRUE (Consumer->isSatisfied ());
1455+ }
1456+
1457+ TEST_F (ParseHLSLRootSignatureTest, InvalidFilterValueTest) {
1458+ // This test will check that an error is produced when there is a invalid
1459+ // value of a parameter
1460+ const llvm::StringLiteral Source = R"cc(
1461+ StaticSampler(
1462+ s0,
1463+ filter = FILTER_TYPO
1464+ )
1465+ )cc" ;
1466+
1467+ auto Ctx = createMinimalASTContext ();
1468+ StringLiteral *Signature = wrapSource (Ctx, Source);
1469+
1470+ TrivialModuleLoader ModLoader;
1471+ auto PP = createPP (Source, ModLoader);
1472+
1473+ SmallVector<RootSignatureElement> Elements;
1474+ hlsl::RootSignatureParser Parser (RootSignatureVersion::V1_1, Elements,
1475+ Signature, *PP);
1476+
1477+ // Test correct diagnostic produced
1478+ Consumer->setExpected (diag::err_hlsl_invalid_token);
1479+ ASSERT_TRUE (Parser.parse ());
1480+
1481+ ASSERT_TRUE (Consumer->isSatisfied ());
1482+ }
1483+
1484+ TEST_F (ParseHLSLRootSignatureTest, InvalidTextureAddressModeValueTest) {
1485+ // This test will check that an error is produced when there is a invalid
1486+ // value of a parameter
1487+ const llvm::StringLiteral Source = R"cc(
1488+ StaticSampler(
1489+ s0,
1490+ addressU = TEXTURE_ADDRESS_MODE_TYPO
1491+ )
1492+ )cc" ;
1493+
1494+ auto Ctx = createMinimalASTContext ();
1495+ StringLiteral *Signature = wrapSource (Ctx, Source);
1496+
1497+ TrivialModuleLoader ModLoader;
1498+ auto PP = createPP (Source, ModLoader);
1499+
1500+ SmallVector<RootSignatureElement> Elements;
1501+ hlsl::RootSignatureParser Parser (RootSignatureVersion::V1_1, Elements,
1502+ Signature, *PP);
1503+
1504+ // Test correct diagnostic produced
1505+ Consumer->setExpected (diag::err_hlsl_invalid_token);
1506+ ASSERT_TRUE (Parser.parse ());
1507+
1508+ ASSERT_TRUE (Consumer->isSatisfied ());
1509+ }
1510+
1511+ TEST_F (ParseHLSLRootSignatureTest, InvalidComparisonFuncValueTest) {
1512+ // This test will check that an error is produced when there is a invalid
1513+ // value of a parameter
1514+ const llvm::StringLiteral Source = R"cc(
1515+ StaticSampler(
1516+ s0,
1517+ comparisonFunc = COMPARISON_FUNC_TYPO
1518+ )
1519+ )cc" ;
1520+
1521+ auto Ctx = createMinimalASTContext ();
1522+ StringLiteral *Signature = wrapSource (Ctx, Source);
1523+
1524+ TrivialModuleLoader ModLoader;
1525+ auto PP = createPP (Source, ModLoader);
1526+
1527+ SmallVector<RootSignatureElement> Elements;
1528+ hlsl::RootSignatureParser Parser (RootSignatureVersion::V1_1, Elements,
1529+ Signature, *PP);
1530+
1531+ // Test correct diagnostic produced
1532+ Consumer->setExpected (diag::err_hlsl_invalid_token);
1533+ ASSERT_TRUE (Parser.parse ());
1534+
1535+ ASSERT_TRUE (Consumer->isSatisfied ());
1536+ }
1537+
1538+ TEST_F (ParseHLSLRootSignatureTest, InvalidStaticBorderColorValueTest) {
1539+ // This test will check that an error is produced when there is a invalid
1540+ // value of a parameter
1541+ const llvm::StringLiteral Source = R"cc(
1542+ StaticSampler(
1543+ s0,
1544+ borderColor = STATIC_BORDER_COLOR_TYPO
1545+ )
1546+ )cc" ;
1547+
1548+ auto Ctx = createMinimalASTContext ();
1549+ StringLiteral *Signature = wrapSource (Ctx, Source);
1550+
1551+ TrivialModuleLoader ModLoader;
1552+ auto PP = createPP (Source, ModLoader);
1553+
1554+ SmallVector<RootSignatureElement> Elements;
1555+ hlsl::RootSignatureParser Parser (RootSignatureVersion::V1_1, Elements,
1556+ Signature, *PP);
1557+
1558+ // Test correct diagnostic produced
1559+ Consumer->setExpected (diag::err_hlsl_invalid_token);
1560+ ASSERT_TRUE (Parser.parse ());
1561+
1562+ ASSERT_TRUE (Consumer->isSatisfied ());
1563+ }
1564+
1565+ TEST_F (ParseHLSLRootSignatureTest, InvalidRootFlagsValueTest) {
1566+ // This test will check that an error is produced when there is a invalid
1567+ // value of a parameter
1568+ const llvm::StringLiteral Source = R"cc(
1569+ RootFlags( ROOT_FLAG_TYPO )
1570+ )cc" ;
1571+
1572+ auto Ctx = createMinimalASTContext ();
1573+ StringLiteral *Signature = wrapSource (Ctx, Source);
1574+
1575+ TrivialModuleLoader ModLoader;
1576+ auto PP = createPP (Source, ModLoader);
1577+
1578+ SmallVector<RootSignatureElement> Elements;
1579+ hlsl::RootSignatureParser Parser (RootSignatureVersion::V1_1, Elements,
1580+ Signature, *PP);
1581+
1582+ // Test correct diagnostic produced
1583+ Consumer->setExpected (diag::err_hlsl_invalid_token);
1584+ ASSERT_TRUE (Parser.parse ());
1585+
1586+ ASSERT_TRUE (Consumer->isSatisfied ());
1587+ }
1588+
1589+ TEST_F (ParseHLSLRootSignatureTest, InvalidRootDescriptorFlagsValueTest) {
1590+ // This test will check that an error is produced when there is a invalid
1591+ // value of a parameter
1592+ const llvm::StringLiteral Source = R"cc(
1593+ CBV( flags = DATA_STATIC | ROOT_DESRIPTOR_FLAG_TYPO )
1594+ )cc" ;
1595+
1596+ auto Ctx = createMinimalASTContext ();
1597+ StringLiteral *Signature = wrapSource (Ctx, Source);
1598+
1599+ TrivialModuleLoader ModLoader;
1600+ auto PP = createPP (Source, ModLoader);
1601+
1602+ SmallVector<RootSignatureElement> Elements;
1603+ hlsl::RootSignatureParser Parser (RootSignatureVersion::V1_1, Elements,
1604+ Signature, *PP);
1605+
1606+ // Test correct diagnostic produced
1607+ Consumer->setExpected (diag::err_hlsl_invalid_token);
1608+ ASSERT_TRUE (Parser.parse ());
1609+
1610+ ASSERT_TRUE (Consumer->isSatisfied ());
1611+ }
1612+
1613+ TEST_F (ParseHLSLRootSignatureTest, InvalidDescriptorRangeFlagsValueTest) {
1614+ // This test will check that an error is produced when there is a invalid
1615+ // value of a parameter
1616+ const llvm::StringLiteral Source = R"cc(
1617+ DescriptorTable(
1618+ CBV(
1619+ flags = DATA_STATIC | DESRIPTOR_RANGE_FLAG_TYPO | DESCRIPTORS_VOLATILE
1620+ )
1621+ )
1622+ )cc" ;
1623+
1624+ auto Ctx = createMinimalASTContext ();
1625+ StringLiteral *Signature = wrapSource (Ctx, Source);
1626+
1627+ TrivialModuleLoader ModLoader;
1628+ auto PP = createPP (Source, ModLoader);
1629+
1630+ SmallVector<RootSignatureElement> Elements;
1631+ hlsl::RootSignatureParser Parser (RootSignatureVersion::V1_1, Elements,
1632+ Signature, *PP);
1633+
1634+ // Test correct diagnostic produced
1635+ Consumer->setExpected (diag::err_hlsl_invalid_token);
1636+ ASSERT_TRUE (Parser.parse ());
1637+
1638+ ASSERT_TRUE (Consumer->isSatisfied ());
1639+ }
1640+
14311641} // anonymous namespace
0 commit comments