This is an archive of the discontinued LLVM Phabricator instance.

[LLDB] [Driver] Use llvm::InitLLVM to do unicode argument conversion on Windows
ClosedPublic

Authored by mstorsjo on Oct 10 2019, 2:42 AM.

Details

Summary

This avoids the currently MSVC specific codepath of using the wchar entry point and converting that to utf8.

In the main lldb driver, we had this MSVC specific codepath, but in other potentially important entry points (like lldb-server), there's none at all. So if this is fine, we should probably add the same InitLLVM call to other lldb entry points as well.

Diff Detail

Event Timeline

mstorsjo created this revision.Oct 10 2019, 2:42 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 10 2019, 2:42 AM
amccarth accepted this revision.Oct 10 2019, 1:06 PM

Cool. I didn't know about InitLLVM. That makes things much cleaner.

Though I do recall recently seeing another complaint about argv[0] not being preserved as typed but being replaced by an absolute path. That will definitely happen now on Windows. Is that a problem?

This revision is now accepted and ready to land.Oct 10 2019, 1:06 PM

Cool. I didn't know about InitLLVM. That makes things much cleaner.

Though I do recall recently seeing another complaint about argv[0] not being preserved as typed but being replaced by an absolute path. That will definitely happen now on Windows. Is that a problem?

I remember seeing such behaviour elsewhere (clang) as well. I don't think that InitLLVM does any such rewrite of argv[0] though, so this patch should pretty much be a plain refactoring.

On Windows, it _does_ rewrite argv[0], but it looks like it tries to not change whether it was relative/absolute, so I think this is fine.

Thanks for the clean-up!

This revision was automatically updated to reflect the committed changes.