r214924 - Make crash diagnostics on Windows the tiniest bit more useful
Reid Kleckner
reid at kleckner.net
Tue Aug 5 13:49:12 PDT 2014
Author: rnk
Date: Tue Aug 5 15:49:12 2014
New Revision: 214924
URL: http://llvm.org/viewvc/llvm-project?rev=214924&view=rev
Log:
Make crash diagnostics on Windows the tiniest bit more useful
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.
Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/Job.cpp
Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=214924&r1=214923&r2=214924&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue Aug 5 15:49:12 2014
@@ -548,6 +548,8 @@ void Driver::generateCompilationDiagnost
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()) {
Modified: cfe/trunk/lib/Driver/Job.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Job.cpp?rev=214924&r1=214923&r2=214924&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Job.cpp (original)
+++ cfe/trunk/lib/Driver/Job.cpp Tue Aug 5 15:49:12 2014
@@ -95,7 +95,8 @@ static void PrintArg(raw_ostream &OS, co
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];
More information about the cfe-commits
mailing list