diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2013-04-02 13:38:48 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2013-04-02 13:38:48 +0000 |
commit | ddc15c40d22718d7b7060634b782d1a3ce9184a8 (patch) | |
tree | 2aa3a40cfbc04fc38589a21619aae45f96c8a056 | |
parent | 7d1be7368ed070bf17e0d41ab8c4acef400c48d2 (diff) |
Escape # and $ in dependency files.
Fixes PR15642.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178540 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Frontend/DependencyFile.cpp | 8 | ||||
-rw-r--r-- | test/Frontend/dependency-gen-escaping.c | 17 |
2 files changed, 22 insertions, 3 deletions
diff --git a/lib/Frontend/DependencyFile.cpp b/lib/Frontend/DependencyFile.cpp index 53ea8befbc..628def68e5 100644 --- a/lib/Frontend/DependencyFile.cpp +++ b/lib/Frontend/DependencyFile.cpp @@ -151,12 +151,14 @@ void DependencyFileCallback::AddFilename(StringRef Filename) { Files.push_back(Filename); } -/// PrintFilename - GCC escapes spaces, but apparently not ' or " or other -/// scary characters. +/// PrintFilename - GCC escapes spaces, # and $, but apparently not ' or " or +/// other scary characters. static void PrintFilename(raw_ostream &OS, StringRef Filename) { for (unsigned i = 0, e = Filename.size(); i != e; ++i) { - if (Filename[i] == ' ') + if (Filename[i] == ' ' || Filename[i] == '#') OS << '\\'; + else if (Filename[i] == '$') // $ is escaped by $$. + OS << '$'; OS << Filename[i]; } } diff --git a/test/Frontend/dependency-gen-escaping.c b/test/Frontend/dependency-gen-escaping.c new file mode 100644 index 0000000000..84eb242ec3 --- /dev/null +++ b/test/Frontend/dependency-gen-escaping.c @@ -0,0 +1,17 @@ +// REQUIRES: shell +// PR15642 +// RUN: rm -rf %t.dir +// RUN: mkdir -p %t.dir +// RUN: echo > '%t.dir/ .h' +// RUN: echo > '%t.dir/$$.h' +// RUN: echo > '%t.dir/##.h' +// RUN: cd %t.dir +// RUN: %clang -MD -MF - %s -fsyntax-only -I. | FileCheck -strict-whitespace %s + +// CHECK: \ \ \ \ .h +// CHECK: $$$$.h +// CHECK: \#\#.h + +#include " .h" +#include "$$.h" +#include "##.h" |