Driver: Fix -### to quote shell special characters, following gcc.

llvm-svn: 99053
This commit is contained in:
Daniel Dunbar 2010-03-20 08:01:53 +00:00
parent 595ecbe5c4
commit 7c4de04c30
1 changed files with 15 additions and 4 deletions

View File

@ -61,10 +61,21 @@ void Compilation::PrintJob(llvm::raw_ostream &OS, const Job &J,
OS << " \"" << C->getExecutable() << '"'; OS << " \"" << C->getExecutable() << '"';
for (ArgStringList::const_iterator it = C->getArguments().begin(), for (ArgStringList::const_iterator it = C->getArguments().begin(),
ie = C->getArguments().end(); it != ie; ++it) { ie = C->getArguments().end(); it != ie; ++it) {
if (Quote) OS << ' ';
OS << " \"" << *it << '"'; if (!Quote) {
else OS << *it;
OS << ' ' << *it; continue;
}
// Quote the argument and escape shell special characters; this isn't
// really complete but is good enough.
OS << '"';
for (const char *s = *it; *s; ++s) {
if (*s == '"' || *s == '\\' || *s == '$')
OS << '\\';
OS << *s;
}
OS << '"';
} }
OS << Terminator; OS << Terminator;
} else if (const PipedJob *PJ = dyn_cast<PipedJob>(&J)) { } else if (const PipedJob *PJ = dyn_cast<PipedJob>(&J)) {