[PATCH] [clang][Driver] Nativize paths when emitting crash diagnostics.

Michael Spencer bigcheesegs at gmail.com
Wed Mar 13 13:50:29 PDT 2013


Replaces / with \ on Windows. nop on other platforms.

http://llvm-reviews.chandlerc.com/D540

Files:
  lib/Driver/Driver.cpp

Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -456,10 +456,12 @@
     ArgStringList Files = C.getTempFiles();
     for (ArgStringList::const_iterator it = Files.begin(), ie = Files.end();
          it != ie; ++it) {
-      Diag(clang::diag::note_drv_command_failed_diag_msg) << *it;
+      SmallString<128> NativePath;
+      llvm::sys::path::native(*it, NativePath);
+      Diag(clang::diag::note_drv_command_failed_diag_msg) << NativePath;
 
       std::string Err;
-      std::string Script = StringRef(*it).rsplit('.').first;
+      std::string Script = StringRef(NativePath).rsplit('.').first;
       Script += ".sh";
       llvm::raw_fd_ostream ScriptOS(Script.c_str(), Err,
                                     llvm::raw_fd_ostream::F_Excl |
@@ -476,7 +478,7 @@
         E = Cmd.find(" ", I);
         assert (E != std::string::npos && "-main-file-name missing argument?");
         StringRef OldFilename = StringRef(Cmd).slice(I, E);
-        StringRef NewFilename = llvm::sys::path::filename(*it);
+        StringRef NewFilename = llvm::sys::path::filename(NativePath);
         I = StringRef(Cmd).rfind(OldFilename);
         E = I + OldFilename.size();
         I = Cmd.rfind(" ", I) + 1;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D540.1.patch
Type: text/x-patch
Size: 1306 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130313/dabd871a/attachment.bin>


More information about the cfe-commits mailing list