Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion tools/clang/unittests/HLSLExec/HlslExecTestUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,8 @@ void compileShader(dxc::SpecificDllLoader &DxcSupport, const char *Source,

if (VerboseLogging) {
hlsl_test::LogCommentFmt(L"Shader Source:");
hlsl_test::LogCommentFmt(L"%c", Source);
hlsl_test::LogCommentFmt(
std::wstring(Source, Source + strlen(Source)).c_str());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct, as Source is a utf-8 char string, and you're just constructing a wide string (which assumes utf-16 for Win32 or utf-32 for nix) from the pointer, without translating the Unicode encoding.

I believe you should simply be able to change the original line to use %S instead.

Suggested change
std::wstring(Source, Source + strlen(Source)).c_str());
hlsl_test::LogCommentFmt(L"%S", Source);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%c was almost certainly wrong! Plus this would do the wrong thing if the Source contained anything that looked like a format specifier.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This suggested change didn't pick up the first line I selected, so don't take that as-is. But you can see what I was suggesting I'm sure.

}

hlsl_test::LogCommentFmt(LogFlags.str().c_str());
Expand Down
Loading
Loading