[llvm] r186792 - Handle replacement into a position past the original member.
Rafael Espindola
rafael.espindola at gmail.com
Sun Jul 21 05:58:08 PDT 2013
Author: rafael
Date: Sun Jul 21 07:58:07 2013
New Revision: 186792
URL: http://llvm.org/viewvc/llvm-project?rev=186792&view=rev
Log:
Handle replacement into a position past the original member.
We were incorrectly computing where to insert a member if it was replacing
a previous member that was before the insert point.
Modified:
llvm/trunk/test/Object/archive-replace-pos.test
llvm/trunk/tools/llvm-ar/llvm-ar.cpp
Modified: llvm/trunk/test/Object/archive-replace-pos.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/archive-replace-pos.test?rev=186792&r1=186791&r2=186792&view=diff
==============================================================================
--- llvm/trunk/test/Object/archive-replace-pos.test (original)
+++ llvm/trunk/test/Object/archive-replace-pos.test Sun Jul 21 07:58:07 2013
@@ -11,3 +11,16 @@ RUN: llvm-ar t %t.a | FileCheck %s
CHECK: .foo
CHECK-NEXT: .zed
CHECK-NEXT: .bar
+
+RUN: llvm-ar rc %t.a %t.foo %t.bar
+RUN: llvm-ar t %t.a | FileCheck --check-prefix=CHECK2 %s
+
+CHECK2: .zed
+CHECK2-NEXT: .foo
+CHECK2-NEXT: .bar
+
+RUN: llvm-ar rca %t.foo %t.a %t.zed
+RUN: llvm-ar t %t.a | FileCheck --check-prefix=CHECK3 %s
+CHECK3: .foo
+CHECK3-NEXT: .zed
+CHECK3-NEXT: .bar
Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=186792&r1=186791&r2=186792&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Sun Jul 21 07:58:07 2013
@@ -458,10 +458,10 @@ computeNewArchiveMembers(ArchiveOperatio
int InsertPos = -1;
StringRef PosName = sys::path::filename(RelPos);
if (OldArchive) {
- int Pos = 0;
for (object::Archive::child_iterator I = OldArchive->begin_children(),
E = OldArchive->end_children();
- I != E; ++I, ++Pos) {
+ I != E; ++I) {
+ int Pos = Ret.size();
StringRef Name;
failIfError(I->getName(Name));
if (Name == PosName) {
More information about the llvm-commits
mailing list