[PATCH] D26734: [ELF] Don't replace path separators on *NIX
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 16 00:58:26 PST 2016
davide updated this revision to Diff 78144.
davide added a comment.
uh, never seen something like that in the wild.
https://reviews.llvm.org/D26734
Files:
lib/Core/Reproduce.cpp
test/ELF/reproduce-backslash.s
Index: test/ELF/reproduce-backslash.s
===================================================================
--- /dev/null
+++ test/ELF/reproduce-backslash.s
@@ -0,0 +1,13 @@
+# 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: rm -rf %t.dir
+# RUN: mkdir -p %t.dir/build
+# RUN: llvm-mc %s -o %t.dir/build/foo\\.o -filetype=obj -triple=x86_64-pc-linux
+# RUN: cd %t.dir
+# RUN: ld.lld build/foo\\.o --reproduce repro
+# RUN: cpio -t < repro.cpio | FileCheck %s
+
+# CHECK: repro/response.txt
+# CHECK: repro/{{.*}}/build/foo\.o
Index: lib/Core/Reproduce.cpp
===================================================================
--- lib/Core/Reproduce.cpp
+++ lib/Core/Reproduce.cpp
@@ -52,9 +52,11 @@
// Converts path to use unix path separators so the cpio can be extracted on
// both unix and windows.
+#ifdef LLVM_ON_WIN32
static void convertToUnixPathSeparator(SmallString<128> &Path) {
std::replace(Path.begin(), Path.end(), '\\', '/');
}
+#endif
void CpioFile::append(StringRef Path, StringRef Data) {
if (!Seen.insert(Path).second)
@@ -65,7 +67,10 @@
// (i.e. in that case we are creating baz.cpio.)
SmallString<128> Fullpath;
path::append(Fullpath, Basename, Path);
+
+#ifdef LLVM_ON_WIN32
convertToUnixPathSeparator(Fullpath);
+#endif
writeMember(*OS, Fullpath, Data);
@@ -98,7 +103,9 @@
Res = Root.substr(2);
path::append(Res, path::relative_path(Abs));
+#ifdef LLVM_ON_WIN32
convertToUnixPathSeparator(Res);
+#endif
return Res.str();
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26734.78144.patch
Type: text/x-patch
Size: 1599 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161116/72fa4387/attachment-0001.bin>
More information about the llvm-commits
mailing list