[Lldb-commits] [lldb] r374526 - [LLDB] [Driver] Use llvm::InitLLVM to do unicode argument conversion on Windows

Martin Storsjo via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 11 01:44:51 PDT 2019


Author: mstorsjo
Date: Fri Oct 11 01:44:51 2019
New Revision: 374526

URL: http://llvm.org/viewvc/llvm-project?rev=374526&view=rev
Log:
[LLDB] [Driver] Use llvm::InitLLVM to do unicode argument conversion on Windows

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

Differential Revision: https://reviews.llvm.org/D68770

Modified:
    lldb/trunk/tools/driver/Driver.cpp

Modified: lldb/trunk/tools/driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/driver/Driver.cpp?rev=374526&r1=374525&r2=374526&view=diff
==============================================================================
--- lldb/trunk/tools/driver/Driver.cpp (original)
+++ lldb/trunk/tools/driver/Driver.cpp Fri Oct 11 01:44:51 2019
@@ -19,8 +19,8 @@
 #include "lldb/API/SBStringList.h"
 
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/Format.h"
+#include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
@@ -807,23 +807,9 @@ llvm::Optional<int> InitializeReproducer
   return llvm::None;
 }
 
-int
-#ifdef _MSC_VER
-wmain(int argc, wchar_t const *wargv[])
-#else
-main(int argc, char const *argv[])
-#endif
+int main(int argc, char const *argv[])
 {
-#ifdef _MSC_VER
-  // Convert wide arguments to UTF-8
-  std::vector<std::string> argvStrings(argc);
-  std::vector<const char *> argvPointers(argc);
-  for (int i = 0; i != argc; ++i) {
-    llvm::convertWideToUTF8(wargv[i], argvStrings[i]);
-    argvPointers[i] = argvStrings[i].c_str();
-  }
-  const char **argv = argvPointers.data();
-#endif
+  llvm::InitLLVM IL(argc, argv);
 
   // Print stack trace on crash.
   llvm::StringRef ToolName = llvm::sys::path::filename(argv[0]);




More information about the lldb-commits mailing list