[PATCH] D47578: Do not enforce absolute path argv0 in windows

Rui Ueyama via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 6 14:36:49 PDT 2018


ruiu added a comment.

It seems you converted the same string back and forth between UTF-8 and UTF-16 to call Windows functions and LLVM functions. That's not only a waste of time (which is not a big problem) but complicates the code.

I'd define `std::error GetExecutableName(std::string &Result)` which returns a filename (fully expanded but not a fullpath) of the current executable in UTF-8. Then, add something like this at the *end* of `GetCommandLineArguments()`:

  SmallVector<char> Arg0(Args[0], strlen(Args[0]);
  sys::path::remove_filename(Arg0);
  GetExecutableName(Filename);
  sys::path::append(Arg0, Filename);
  Args[0] = AllocateString(Arg0, Alloc);


https://reviews.llvm.org/D47578





More information about the cfe-commits mailing list