]> granicus.if.org Git - clang/commitdiff
Make crash diagnostics on Windows the tiniest bit more useful
authorReid Kleckner <reid@kleckner.net>
Tue, 5 Aug 2014 20:49:12 +0000 (20:49 +0000)
committerReid Kleckner <reid@kleckner.net>
Tue, 5 Aug 2014 20:49:12 +0000 (20:49 +0000)
This escapes any backslashes in the executable path and fixes an issue
with a trailing quote when the main file name had to be quoted during
printing.

It's impossible to test this without putting backslashes or quotes into
the executable path, so I didn't add automated tests.

The crash diagnostics are still only useful if you're using bash on
Windows, though.  This should probably be writing a batch file instead.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@214924 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Driver.cpp
lib/Driver/Job.cpp

index 3cdeec14d10cd594e3b2df043e4469ebf13278fd..c5e705097201b928a14c06bcca93cc96610020ca 100644 (file)
@@ -548,6 +548,8 @@ void Driver::generateCompilationDiagnostics(Compilation &C,
         StringRef NewFilename = llvm::sys::path::filename(*it);
         I = StringRef(Cmd).rfind(OldFilename);
         E = I + OldFilename.size();
+        if (E + 1 < Cmd.size() && Cmd[E] == '"')
+          ++E;  // Replace a trailing quote if present.
         I = Cmd.rfind(" ", I) + 1;
         Cmd.replace(I, E - I, NewFilename.data(), NewFilename.size());
         if (!VFS.empty()) {
index 42cc1bc2907797b170f58fbca242262640e4917e..fdf730d881b0e3d40fe04e2ae9d231f52b1021b7 100644 (file)
@@ -95,7 +95,8 @@ static void PrintArg(raw_ostream &OS, const char *Arg, bool Quote) {
 
 void Command::Print(raw_ostream &OS, const char *Terminator, bool Quote,
                     bool CrashReport) const {
-  OS << " \"" << Executable << '"';
+  // Always quote the exe.
+  PrintArg(OS, Executable, /*Quote=*/true);
 
   for (size_t i = 0, e = Arguments.size(); i < e; ++i) {
     const char *const Arg = Arguments[i];