[llvm] [Support] Resolve symlinks in `getMainExecutable()` on Windows (PR #76304)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 24 20:46:30 PST 2023


================
@@ -154,7 +154,10 @@ std::string getMainExecutable(const char *argv0, void *MainExecAddr) {
     return "";
 
   llvm::sys::path::make_preferred(PathNameUTF8);
-  return std::string(PathNameUTF8.data());
+
+  SmallString<256> RealPath;
+  sys::fs::real_path(PathNameUTF8, RealPath);
+  return (std::string)RealPath;
----------------
MaskRay wrote:

In this case `std::string(RealPath)` should look better.

https://github.com/llvm/llvm-project/pull/76304


More information about the llvm-commits mailing list