]> granicus.if.org Git - clang/commitdiff
[driver] The -v option doesn't quoted the command line arguments for historical
authorChad Rosier <mcrosier@apple.com>
Wed, 5 Oct 2011 19:51:41 +0000 (19:51 +0000)
committerChad Rosier <mcrosier@apple.com>
Wed, 5 Oct 2011 19:51:41 +0000 (19:51 +0000)
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

lib/Driver/Compilation.cpp

index 85a5fc933044c306f0711ca4e4f6d7037032591e..7a62fa4b55f547ad4f88510910fce54e35a8cb94 100644 (file)
@@ -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<Command>(&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;
       }