[llvm] r256001 - Handle archives with paths in the names.

Rafael Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 18 08:07:18 PST 2015


Author: rafael
Date: Fri Dec 18 10:07:17 2015
New Revision: 256001

URL: http://llvm.org/viewvc/llvm-project?rev=256001&view=rev
Log:
Handle archives with paths in the names.

We always create archives with just he filename as the member name, but
other archives can put a more complicated path in there.

This patches handles it by computing just the filename as we do when
adding a new member.

If storing the path is important for some reason, we should probably
have an orthogonal option for doing that and do it for both old and new
members.

Fixes pr25877.

Added:
    llvm/trunk/test/Object/Inputs/pr25877.lib
    llvm/trunk/test/Object/pr25877.test
Modified:
    llvm/trunk/lib/Object/ArchiveWriter.cpp

Modified: llvm/trunk/lib/Object/ArchiveWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ArchiveWriter.cpp?rev=256001&r1=256000&r2=256001&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ArchiveWriter.cpp (original)
+++ llvm/trunk/lib/Object/ArchiveWriter.cpp Fri Dec 18 10:07:17 2015
@@ -415,8 +415,10 @@ llvm::writeArchive(StringRef ArcName,
       ErrorOr<uint32_t> Size = OldMember.getSize();
       if (std::error_code EC = Size.getError())
         return std::make_pair("", EC);
-      printMemberHeader(Out, Kind, Thin, I.getName(), StringMapIndexIter,
-                        ModTime, UID, GID, Perms, Size.get());
+      StringRef FileName = I.getName();
+      printMemberHeader(Out, Kind, Thin, sys::path::filename(FileName),
+                        StringMapIndexIter, ModTime, UID, GID, Perms,
+                        Size.get());
     }
 
     if (!Thin)

Added: llvm/trunk/test/Object/Inputs/pr25877.lib
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/Inputs/pr25877.lib?rev=256001&view=auto
==============================================================================
Binary files llvm/trunk/test/Object/Inputs/pr25877.lib (added) and llvm/trunk/test/Object/Inputs/pr25877.lib Fri Dec 18 10:07:17 2015 differ

Added: llvm/trunk/test/Object/pr25877.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/pr25877.test?rev=256001&view=auto
==============================================================================
--- llvm/trunk/test/Object/pr25877.test (added)
+++ llvm/trunk/test/Object/pr25877.test Fri Dec 18 10:07:17 2015
@@ -0,0 +1,9 @@
+; RUN: echo create %t.a > %t.mri
+; RUN: echo addlib %p/Inputs/pr25877.lib >> %t.mri
+; RUN: echo save >> %t.mri
+; RUN: echo end >> %t.mri
+
+; RUN: llvm-ar -M  < %t.mri
+; RUN: llvm-ar t %t.a | FileCheck %s
+
+; CHECK: foo.obj




More information about the llvm-commits mailing list