Lgtm<br><div class="gmail_quote"><div dir="ltr">On Wed, Sep 12, 2018 at 3:23 AM Dávid Bolvanský via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">xbolva00 updated this revision to Diff 165052.<br>
xbolva00 added a comment.<br>
<br>
- Fixed failing test<br>
<br>
<br>
<a href="https://reviews.llvm.org/D51847" rel="noreferrer" target="_blank">https://reviews.llvm.org/D51847</a><br>
<br>
Files:<br>
lib/Frontend/DependencyFile.cpp<br>
test/Frontend/dependency-gen-escaping.c<br>
<br>
<br>
Index: test/Frontend/dependency-gen-escaping.c<br>
===================================================================<br>
--- test/Frontend/dependency-gen-escaping.c<br>
+++ test/Frontend/dependency-gen-escaping.c<br>
@@ -21,7 +21,7 @@<br>
// Backslash followed by # or space should escape both characters, because<br>
// that's what GNU Make wants. GCC does the right thing with space, but not<br>
// #, so Clang does too. (There should be 3 backslashes before the #.)<br>
-// SEP2F: a\b\\#c\\\ d.h<br>
+// SEP2F: a{{[/\\]}}b{{[/\\]}}\#c{{/|\\\\}}\ d.h<br>
// With -fms-compatibility, Backslashes in #include are treated as path separators.<br>
// Backslashes are given in the emission for special characters, like 0x20 or 0x23.<br>
// SEP5C: a{{[/\\]}}b{{[/\\]}}\#c{{/|\\\\}}\ d.h<br>
Index: lib/Frontend/DependencyFile.cpp<br>
===================================================================<br>
--- lib/Frontend/DependencyFile.cpp<br>
+++ lib/Frontend/DependencyFile.cpp<br>
@@ -386,28 +386,32 @@<br>
/// for Windows file-naming info.<br>
static void PrintFilename(raw_ostream &OS, StringRef Filename,<br>
DependencyOutputFormat OutputFormat) {<br>
+ // Convert filename to platform native path<br>
+ llvm::SmallString<256> NativePath;<br>
+ llvm::sys::path::native(Filename.str(), NativePath);<br>
+<br>
if (OutputFormat == DependencyOutputFormat::NMake) {<br>
// Add quotes if needed. These are the characters listed as "special" to<br>
// NMake, that are legal in a Windows filespec, and that could cause<br>
// misinterpretation of the dependency string.<br>
- if (Filename.find_first_of(" #${}^!") != StringRef::npos)<br>
- OS << '\"' << Filename << '\"';<br>
+ if (NativePath.find_first_of(" #${}^!") != StringRef::npos)<br>
+ OS << '\"' << NativePath << '\"';<br>
else<br>
- OS << Filename;<br>
+ OS << NativePath;<br>
return;<br>
}<br>
assert(OutputFormat == DependencyOutputFormat::Make);<br>
- for (unsigned i = 0, e = Filename.size(); i != e; ++i) {<br>
- if (Filename[i] == '#') // Handle '#' the broken gcc way.<br>
+ for (unsigned i = 0, e = NativePath.size(); i != e; ++i) {<br>
+ if (NativePath[i] == '#') // Handle '#' the broken gcc way.<br>
OS << '\\';<br>
- else if (Filename[i] == ' ') { // Handle space correctly.<br>
+ else if (NativePath[i] == ' ') { // Handle space correctly.<br>
OS << '\\';<br>
unsigned j = i;<br>
- while (j > 0 && Filename[--j] == '\\')<br>
+ while (j > 0 && NativePath[--j] == '\\')<br>
OS << '\\';<br>
- } else if (Filename[i] == '$') // $ is escaped by $$.<br>
+ } else if (NativePath[i] == '$') // $ is escaped by $$.<br>
OS << '$';<br>
- OS << Filename[i];<br>
+ OS << NativePath[i];<br>
}<br>
}<br>
<br>
<br>
<br>
</blockquote></div>