[PATCH] D57845: [llvm-ar] Remove leading slash when printing thin archive members

Jordan Rupprecht via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 6 13:31:18 PST 2019


rupprecht created this revision.
rupprecht added a reviewer: ruiu.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D57845

Files:
  llvm/test/tools/llvm-ar/print-thin-archive-path.test
  llvm/tools/llvm-ar/llvm-ar.cpp


Index: llvm/tools/llvm-ar/llvm-ar.cpp
===================================================================
--- llvm/tools/llvm-ar/llvm-ar.cpp
+++ llvm/tools/llvm-ar/llvm-ar.cpp
@@ -429,8 +429,9 @@
   }
 
   if (C.getParent()->isThin()) {
-    outs() << sys::path::parent_path(ArchiveName);
-    outs() << '/';
+    StringRef ParentDir = sys::path::parent_path(ArchiveName);
+    if (!ParentDir.empty())
+      outs() << ParentDir << '/';
   }
   outs() << Name << "\n";
 }
Index: llvm/test/tools/llvm-ar/print-thin-archive-path.test
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-ar/print-thin-archive-path.test
@@ -0,0 +1,10 @@
+RUN: mkdir -p %t/foo
+RUN: touch %t/foo/a.txt
+RUN: rm -f %t/foo/archive.a
+
+RUN: cd %t && llvm-ar rcST foo/archive.a foo/a.txt
+RUN: cd %t && llvm-ar t foo/archive.a | FileCheck %s --match-full-lines --check-prefix=PARENT-DIR
+RUN: cd %t/foo && llvm-ar t archive.a | FileCheck %s --match-full-lines --check-prefix=CHILD-DIR
+
+PARENT-DIR: foo/a.txt
+CHILD-DIR:  a.txt
\ No newline at end of file


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57845.185629.patch
Type: text/x-patch
Size: 1087 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190206/c91c23bf/attachment.bin>


More information about the llvm-commits mailing list