summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/DependencyFile.cpp
diff options
context:
space:
mode:
authorDavid Bolvansky <david.bolvansky@gmail.com>2018-09-13 14:27:32 +0000
committerDavid Bolvansky <david.bolvansky@gmail.com>2018-09-13 14:27:32 +0000
commitc96cb25a8ba7baac5ad03545c5823032dbfa9ba4 (patch)
tree04426b5f03425eea3b80913c284f3b533c228f82 /clang/lib/Frontend/DependencyFile.cpp
parente6dd0806c731841812cd5332774ca12931fca0df (diff)
downloadbcm5719-llvm-c96cb25a8ba7baac5ad03545c5823032dbfa9ba4.tar.gz
bcm5719-llvm-c96cb25a8ba7baac5ad03545c5823032dbfa9ba4.zip
Print correctly dependency paths on Windows
Summary: Before: main.o: main.c ../include/lib\test.h After: main.o: main.c ../include/lib/test.h Fixes PR38877 Reviewers: zturner Subscribers: xbolva00, cfe-commits Differential Revision: https://reviews.llvm.org/D51847 llvm-svn: 342139
Diffstat (limited to 'clang/lib/Frontend/DependencyFile.cpp')
-rw-r--r--clang/lib/Frontend/DependencyFile.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/clang/lib/Frontend/DependencyFile.cpp b/clang/lib/Frontend/DependencyFile.cpp
index e6e07190e1f..a3f34792091 100644
--- a/clang/lib/Frontend/DependencyFile.cpp
+++ b/clang/lib/Frontend/DependencyFile.cpp
@@ -386,28 +386,32 @@ bool DFGImpl::AddFilename(StringRef Filename) {
/// for Windows file-naming info.
static void PrintFilename(raw_ostream &OS, StringRef Filename,
DependencyOutputFormat OutputFormat) {
+ // Convert filename to platform native path
+ llvm::SmallString<256> NativePath;
+ llvm::sys::path::native(Filename.str(), NativePath);
+
if (OutputFormat == DependencyOutputFormat::NMake) {
// Add quotes if needed. These are the characters listed as "special" to
// NMake, that are legal in a Windows filespec, and that could cause
// misinterpretation of the dependency string.
- if (Filename.find_first_of(" #${}^!") != StringRef::npos)
- OS << '\"' << Filename << '\"';
+ if (NativePath.find_first_of(" #${}^!") != StringRef::npos)
+ OS << '\"' << NativePath << '\"';
else
- OS << Filename;
+ OS << NativePath;
return;
}
assert(OutputFormat == DependencyOutputFormat::Make);
- for (unsigned i = 0, e = Filename.size(); i != e; ++i) {
- if (Filename[i] == '#') // Handle '#' the broken gcc way.
+ for (unsigned i = 0, e = NativePath.size(); i != e; ++i) {
+ if (NativePath[i] == '#') // Handle '#' the broken gcc way.
OS << '\\';
- else if (Filename[i] == ' ') { // Handle space correctly.
+ else if (NativePath[i] == ' ') { // Handle space correctly.
OS << '\\';
unsigned j = i;
- while (j > 0 && Filename[--j] == '\\')
+ while (j > 0 && NativePath[--j] == '\\')
OS << '\\';
- } else if (Filename[i] == '$') // $ is escaped by $$.
+ } else if (NativePath[i] == '$') // $ is escaped by $$.
OS << '$';
- OS << Filename[i];
+ OS << NativePath[i];
}
}
OpenPOWER on IntegriCloud