[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:52:17 PST 2019


This revision was automatically updated to reflect the committed changes.
rupprecht marked an inline comment as done.
Closed by commit rL353347: [llvm-ar] Remove leading slash when printing thin archive members (authored by rupprecht, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57845?vs=185629&id=185638#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57845/new/

https://reviews.llvm.org/D57845

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


Index: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
===================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp
+++ llvm/trunk/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/trunk/test/tools/llvm-ar/print-thin-archive-path.test
===================================================================
--- llvm/trunk/test/tools/llvm-ar/print-thin-archive-path.test
+++ llvm/trunk/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


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


More information about the llvm-commits mailing list