[lld] r287143 - [ELF] Don't replace path separators on *NIX.

Davide Italiano via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 16 11:35:36 PST 2016


Author: davide
Date: Wed Nov 16 13:35:36 2016
New Revision: 287143

URL: http://llvm.org/viewvc/llvm-project?rev=287143&view=rev
Log:
[ELF] Don't replace path separators on *NIX.

Apparently this is wrong because it's legal to have a filename
on UNIX which contains a backslash.

Differential Revision:  https://reviews.llvm.org/D26734

Added:
    lld/trunk/test/ELF/reproduce-backslash.s
Modified:
    lld/trunk/lib/Core/Reproduce.cpp

Modified: lld/trunk/lib/Core/Reproduce.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Core/Reproduce.cpp?rev=287143&r1=287142&r2=287143&view=diff
==============================================================================
--- lld/trunk/lib/Core/Reproduce.cpp (original)
+++ lld/trunk/lib/Core/Reproduce.cpp Wed Nov 16 13:35:36 2016
@@ -53,7 +53,9 @@ static void writeMember(raw_fd_ostream &
 // Converts path to use unix path separators so the cpio can be extracted on
 // both unix and windows.
 static void convertToUnixPathSeparator(SmallString<128> &Path) {
+#ifdef LLVM_ON_WIN32
   std::replace(Path.begin(), Path.end(), '\\', '/');
+#endif
 }
 
 void CpioFile::append(StringRef Path, StringRef Data) {

Added: lld/trunk/test/ELF/reproduce-backslash.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/reproduce-backslash.s?rev=287143&view=auto
==============================================================================
--- lld/trunk/test/ELF/reproduce-backslash.s (added)
+++ lld/trunk/test/ELF/reproduce-backslash.s Wed Nov 16 13:35:36 2016
@@ -0,0 +1,9 @@
+# REQUIRES: x86, cpio, shell
+
+# Test that we don't erroneously replace \ with / on UNIX, as it's
+# legal for a filename to contain backslashes.
+# RUN: llvm-mc %s -o foo\\.o -filetype=obj -triple=x86_64-pc-linux
+# RUN: ld.lld foo\\.o --reproduce repro
+# RUN: cpio -t < repro.cpio | FileCheck %s
+
+# CHECK: repro/{{.*}}/foo\.o




More information about the llvm-commits mailing list