[PATCH] D27217: Only computeRelativePath() on new members

Mark Santaniello via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 30 08:10:21 PST 2016


marksantaniello updated this revision to Diff 79741.
marksantaniello added a comment.

Previous diff was a mistake.  Got the revisions mixed up.  Here I add the final newline to the new test.


https://reviews.llvm.org/D27217

Files:
  include/llvm/Object/ArchiveWriter.h
  lib/Object/ArchiveWriter.cpp
  test/Object/archive-thin-create.test


Index: test/Object/archive-thin-create.test
===================================================================
--- /dev/null
+++ test/Object/archive-thin-create.test
@@ -0,0 +1,14 @@
+RUN: mkdir -p %t
+RUN: cd %t
+RUN: mkdir -p foo
+RUN: touch foo/test1.o
+RUN: touch foo/test2.o
+RUN: llvm-ar qcT foo/libtest.a foo/test1.o
+RUN: llvm-ar qcT foo/libtest.a foo/test1.o
+RUN: llvm-ar qcT foo/libtest.a foo/test2.o
+RUN: llvm-ar t foo/libtest.a | FileCheck %s
+
+CHECK: test1.o
+CHECK: test1.o
+CHECK: test2.o
+
Index: lib/Object/ArchiveWriter.cpp
===================================================================
--- lib/Object/ArchiveWriter.cpp
+++ lib/Object/ArchiveWriter.cpp
@@ -45,6 +45,7 @@
     return BufOrErr.takeError();
 
   NewArchiveMember M;
+  assert(M.IsNew == false);
   M.Buf = MemoryBuffer::getMemBuffer(*BufOrErr, false);
   if (!Deterministic) {
     auto ModTimeOrErr = OldMember.getLastModified();
@@ -93,6 +94,7 @@
     return errorCodeToError(std::error_code(errno, std::generic_category()));
 
   NewArchiveMember M;
+  M.IsNew = true;
   M.Buf = std::move(*MemberBufferOrErr);
   if (!Deterministic) {
     M.ModTime = std::chrono::time_point_cast<std::chrono::seconds>(
@@ -231,9 +233,12 @@
     }
     StringMapIndexes.push_back(Out.tell() - StartOffset);
 
-    if (Thin)
-      Out << computeRelativePath(ArcName, Path);
-    else
+    if (Thin) {
+      if (M.IsNew)
+        Out << computeRelativePath(ArcName, Path);
+      else
+        Out << M.Buf->getBufferIdentifier();
+    } else
       Out << Name;
 
     Out << "/\n";
Index: include/llvm/Object/ArchiveWriter.h
===================================================================
--- include/llvm/Object/ArchiveWriter.h
+++ include/llvm/Object/ArchiveWriter.h
@@ -25,6 +25,7 @@
   sys::TimePoint<std::chrono::seconds> ModTime;
   unsigned UID = 0, GID = 0, Perms = 0644;
 
+  bool IsNew = false;
   NewArchiveMember() = default;
   NewArchiveMember(MemoryBufferRef BufRef);
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27217.79741.patch
Type: text/x-patch
Size: 1970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161130/79c401ba/attachment.bin>


More information about the llvm-commits mailing list