]> granicus.if.org Git - clang/commitdiff
Fix unquoted spaces in args in clang --verbose output
authorHans Wennborg <hans@hanshq.net>
Wed, 24 Apr 2019 09:06:03 +0000 (09:06 +0000)
committerHans Wennborg <hans@hanshq.net>
Wed, 24 Apr 2019 09:06:03 +0000 (09:06 +0000)
The behaviour of not quoting spaces appears to have been introduced by
mistake in r190620.

Patch by Brad Moody!

Differential revision: https://reviews.llvm.org/D60997

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@359077 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/Job.cpp
test/Driver/verbose-output-quoting.c [new file with mode: 0644]

index d2aeda640fc9beda00ec23aafca84539248f28bf..0a95e49694f95868e74e15ce374500934e6221e5 100644 (file)
@@ -99,7 +99,7 @@ static bool skipArgs(const char *Flag, bool HaveCrashVFS, int &SkipNum,
 }
 
 void Command::printArg(raw_ostream &OS, StringRef Arg, bool Quote) {
-  const bool Escape = Arg.find_first_of("\"\\$") != StringRef::npos;
+  const bool Escape = Arg.find_first_of(" \"\\$") != StringRef::npos;
 
   if (!Quote && !Escape) {
     OS << Arg;
diff --git a/test/Driver/verbose-output-quoting.c b/test/Driver/verbose-output-quoting.c
new file mode 100644 (file)
index 0000000..571a682
--- /dev/null
@@ -0,0 +1,9 @@
+// RUN: %clang --verbose -DSPACE="a b"  -c %s 2>&1 | FileCheck -check-prefix=SPACE     -strict-whitespace %s
+// RUN: %clang --verbose -DQUOTES=\"\"  -c %s 2>&1 | FileCheck -check-prefix=QUOTES    -strict-whitespace %s
+// RUN: %clang --verbose -DBACKSLASH=\\ -c %s 2>&1 | FileCheck -check-prefix=BACKSLASH -strict-whitespace %s
+// RUN: %clang --verbose -DDOLLAR=\$    -c %s 2>&1 | FileCheck -check-prefix=DOLLAR    -strict-whitespace %s
+
+// SPACE: -cc1 {{.*}} -D "SPACE=a b"
+// QUOTES: -cc1 {{.*}} -D "QUOTES=\"\""
+// BACKSLASH: -cc1 {{.*}} -D "BACKSLASH=\\"
+// DOLLAR: -cc1 {{.*}} -D "DOLLAR=\$"