From: Chad Rosier Date: Wed, 5 Oct 2011 19:51:41 +0000 (+0000) Subject: [driver] The -v option doesn't quoted the command line arguments for historical X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a2dd7d08a3665ba75d3d17b06a0dcc11570c9575;p=clang [driver] The -v option doesn't quoted the command line arguments for historical reasons. However, it does seems practical to quote strings that need it. rdar://10221951 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141202 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Compilation.cpp b/lib/Driver/Compilation.cpp index 85a5fc9330..7a62fa4b55 100644 --- a/lib/Driver/Compilation.cpp +++ b/lib/Driver/Compilation.cpp @@ -70,6 +70,13 @@ const DerivedArgList &Compilation::getArgsForToolChain(const ToolChain *TC, return *Entry; } +static bool needsQuote(const char *s) { + for (const char *c = s; *c; ++c) + if (*c == ' ') + return true; + return false; +} + void Compilation::PrintJob(raw_ostream &OS, const Job &J, const char *Terminator, bool Quote) const { if (const Command *C = dyn_cast(&J)) { @@ -77,7 +84,7 @@ void Compilation::PrintJob(raw_ostream &OS, const Job &J, for (ArgStringList::const_iterator it = C->getArguments().begin(), ie = C->getArguments().end(); it != ie; ++it) { OS << ' '; - if (!Quote) { + if (!Quote && !needsQuote(*it)) { OS << *it; continue; }