@@ -128,6 +128,7 @@ class CompilerTest : public ::testing::Test {
128128 TEST_METHOD (CompileWhenWorksThenAddRemovePrivate)
129129 TEST_METHOD (CompileThenAddCustomDebugName)
130130 TEST_METHOD (CompileThenTestPdbUtils)
131+ TEST_METHOD (CompileThenTestPdbUtilsWarningOpt)
131132 TEST_METHOD (CompileThenTestPdbInPrivate)
132133 TEST_METHOD (CompileThenTestPdbUtilsStripped)
133134 TEST_METHOD (CompileThenTestPdbUtilsEmptyEntry)
@@ -1632,6 +1633,113 @@ TEST_F(CompilerTest, CompileThenTestPdbUtils) {
16321633 TestPdbUtils (/* bSlim*/ false , /* bSourceInDebugModule*/ false , /* strip*/ true ); // Full PDB, where source info is stored in its own part, and debug module is present
16331634}
16341635
1636+
1637+ TEST_F (CompilerTest, CompileThenTestPdbUtilsWarningOpt) {
1638+ CComPtr<IDxcCompiler> pCompiler;
1639+ VERIFY_SUCCEEDED (CreateCompiler (&pCompiler));
1640+
1641+ std::string main_source = R"x(
1642+ cbuffer MyCbuffer : register(b1) {
1643+ float4 my_cbuf_foo;
1644+ }
1645+
1646+ [RootSignature("CBV(b1)")]
1647+ float4 main() : SV_Target {
1648+ return my_cbuf_foo;
1649+ }
1650+ )x" ;
1651+
1652+ CComPtr<IDxcUtils> pUtils;
1653+ VERIFY_SUCCEEDED (m_dllSupport.CreateInstance (CLSID_DxcUtils, &pUtils));
1654+
1655+
1656+
1657+ CComPtr<IDxcCompiler3> pCompiler3;
1658+ VERIFY_SUCCEEDED (pCompiler.QueryInterface (&pCompiler3));
1659+
1660+ const WCHAR *args[] = {
1661+ L" /Zs" ,
1662+ L" .\r edundant_input" ,
1663+ L" -Wno-parentheses-equality" ,
1664+ L" hlsl.hlsl" ,
1665+ L" /Tps_6_0" ,
1666+ L" /Emain" ,
1667+ };
1668+
1669+ DxcBuffer buf = {};
1670+ buf.Ptr = main_source.c_str ();
1671+ buf.Size = main_source.size ();
1672+ buf.Encoding = CP_UTF8;
1673+
1674+ CComPtr<IDxcResult> pResult;
1675+ VERIFY_SUCCEEDED (pCompiler3->Compile (&buf, args, _countof (args), nullptr , IID_PPV_ARGS (&pResult)));
1676+
1677+ CComPtr<IDxcBlob> pPdb;
1678+ VERIFY_SUCCEEDED (pResult->GetOutput (DXC_OUT_PDB, IID_PPV_ARGS (&pPdb), nullptr ));
1679+
1680+ auto TestPdb = [](IDxcPdbUtils *pPdbUtils) {
1681+ UINT32 uArgsCount = 0 ;
1682+ VERIFY_SUCCEEDED (pPdbUtils->GetArgCount (&uArgsCount));
1683+ bool foundArg = false ;
1684+ for (UINT32 i = 0 ; i < uArgsCount; i++) {
1685+ CComBSTR pArg;
1686+ VERIFY_SUCCEEDED (pPdbUtils->GetArg (i, &pArg));
1687+ if (pArg) {
1688+ std::wstring arg (pArg);
1689+ if (arg == L" -Wno-parentheses-equality" || arg == L" /Wno-parentheses-equality" ) {
1690+ foundArg = true ;
1691+ }
1692+ else {
1693+ // Make sure arg value "no-parentheses-equality" doesn't show up
1694+ // as its own argument token.
1695+ VERIFY_ARE_NOT_EQUAL (arg, L" no-parentheses-equality" );
1696+
1697+ // Make sure the presence of the argument ".\redundant_input"
1698+ // doesn't cause "<input>" to show up.
1699+ VERIFY_ARE_NOT_EQUAL (arg, L" <input>" );
1700+ }
1701+ }
1702+ }
1703+ VERIFY_IS_TRUE (foundArg);
1704+
1705+ UINT32 uFlagsCount = 0 ;
1706+ VERIFY_SUCCEEDED (pPdbUtils->GetFlagCount (&uFlagsCount));
1707+ bool foundFlag = false ;
1708+ for (UINT32 i = 0 ; i < uFlagsCount; i++) {
1709+ CComBSTR pFlag;
1710+ VERIFY_SUCCEEDED (pPdbUtils->GetFlag (i, &pFlag));
1711+ if (pFlag) {
1712+ std::wstring arg (pFlag);
1713+ if (arg == L" -Wno-parentheses-equality" || arg == L" /Wno-parentheses-equality" ) {
1714+ foundFlag = true ;
1715+ }
1716+ else {
1717+ // Make sure arg value "no-parentheses-equality" doesn't show up
1718+ // as its own flag token.
1719+ VERIFY_ARE_NOT_EQUAL (arg, L" no-parentheses-equality" );
1720+ }
1721+ }
1722+ }
1723+ VERIFY_IS_TRUE (foundFlag);
1724+
1725+ CComBSTR pMainFileName;
1726+ VERIFY_SUCCEEDED (pPdbUtils->GetMainFileName (&pMainFileName));
1727+ std::wstring mainFileName = pMainFileName;
1728+ VERIFY_ARE_EQUAL (mainFileName, L" hlsl.hlsl" );
1729+ };
1730+
1731+ CComPtr<IDxcPdbUtils> pPdbUtils;
1732+ VERIFY_SUCCEEDED (m_dllSupport.CreateInstance (CLSID_DxcPdbUtils, &pPdbUtils));
1733+
1734+ VERIFY_SUCCEEDED (pPdbUtils->Load (pPdb));
1735+ TestPdb (pPdbUtils);
1736+
1737+ CComPtr<IDxcBlob> pFullPdb;
1738+ VERIFY_SUCCEEDED (pPdbUtils->GetFullPDB (&pFullPdb));
1739+ VERIFY_SUCCEEDED (pPdbUtils->Load (pFullPdb));
1740+ TestPdb (pPdbUtils);
1741+ }
1742+
16351743TEST_F (CompilerTest, CompileThenTestPdbInPrivate) {
16361744 CComPtr<IDxcCompiler> pCompiler;
16371745 VERIFY_SUCCEEDED (CreateCompiler (&pCompiler));
0 commit comments