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
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()) {
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];