[PATCH] D51847: Print corrent dependency path on Windows

Dávid Bolvanský via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 10 00:23:59 PDT 2018


xbolva00 created this revision.
xbolva00 added a reviewer: zturner.
Herald added a subscriber: cfe-commits.

Before:
main.o: main.c ../include/lib\test.h

After:
main.o: main.c ../include/lib/test.h


Repository:
  rC Clang

https://reviews.llvm.org/D51847

Files:
  lib/Frontend/DependencyFile.cpp


Index: lib/Frontend/DependencyFile.cpp
===================================================================
--- lib/Frontend/DependencyFile.cpp
+++ lib/Frontend/DependencyFile.cpp
@@ -386,28 +386,29 @@
 /// for Windows file-naming info.
 static void PrintFilename(raw_ostream &OS, StringRef Filename,
                           DependencyOutputFormat OutputFormat) {
+  std::string &NativePath = llvm::sys::path::convert_to_slash(Filename);	
   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];
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51847.164619.patch
Type: text/x-patch
Size: 1794 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180910/01dc88ee/attachment.bin>


More information about the cfe-commits mailing list