Skip to content

Commit b46def4

Browse files
committed
fix undeclared variables in non windows case, and pointer lifetime bug
1 parent c274e5b commit b46def4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tools/clang/unittests/HLSL/ValidationTest.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4217,11 +4217,11 @@ std::wstring GetEnvVarW(const std::wstring &VarName) {
42174217
if (const wchar_t *Result = _wgetenv(VarName.c_str()))
42184218
return std::wstring(Result);
42194219
#else
4220-
std::string NameUtf8;
4221-
WideToUTF8String(Name.c_str, &NameUtf8);
4222-
if (const char *Result = std::getenv(NameUtf8.c_str())) {
4220+
std::string VarNameUtf8;
4221+
WideToUTF8String(VarName.c_str, &VarNameUtf8);
4222+
if (const char *Result = std::getenv(VarNameUtf8.c_str())) {
42234223
std::wstring ResultWide;
4224-
Unicode::UTF8ToWideString(Result.c_str(), &ResultWide);
4224+
Unicode::UTF8ToWideString(Result, &ResultWide);
42254225
return std::wstring(ResultWide);
42264226
}
42274227
#endif
@@ -4268,7 +4268,8 @@ TEST_F(ValidationTest, UnitTestExtValidationSupport) {
42684268
VERIFY_SUCCEEDED(ExtSupportEmpty.Initialize());
42694269

42704270
VERIFY_IS_FALSE(ExtSupportEmpty.DxilDllFailedToLoad());
4271-
VERIFY_ARE_EQUAL_STR(ExtSupportEmpty.GetDxilDllPath().c_str(), "");
4271+
std::string EmptyPath = ExtSupportBogus.GetDxilDllPath();
4272+
VERIFY_ARE_EQUAL_STR(EmptyPath.c_str(), "");
42724273

42734274
// 2. Test with a bogus path in the environment variable
42744275
SetEnvVarW(L"DXC_DXIL_DLL_PATH", L"bogus");
@@ -4279,7 +4280,8 @@ TEST_F(ValidationTest, UnitTestExtValidationSupport) {
42794280

42804281
// validate that m_dllExtSupport2 was able to capture the environment
42814282
// variable's value, and that loading the bogus path was unsuccessful
4282-
VERIFY_ARE_EQUAL_STR(ExtSupportBogus.GetDxilDllPath().c_str(), "bogus");
4283+
std::string BogusPath = ExtSupportBogus.GetDxilDllPath();
4284+
VERIFY_ARE_EQUAL_STR(BogusPath.c_str(), "bogus");
42834285
VERIFY_IS_TRUE(ExtSupportBogus.DxilDllFailedToLoad());
42844286

42854287
// 3. Test production of class IDs CLSID_DxcCompiler, CLSID_DxcLinker,

0 commit comments

Comments
 (0)