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.

llvm-svn: 186792
This commit is contained in:
Rafael Espindola 2013-07-21 12:58:07 +00:00
parent 5dfe843a2c
commit 9cd2435b9a
2 changed files with 15 additions and 2 deletions

View File

@ -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

View File

@ -458,10 +458,10 @@ computeNewArchiveMembers(ArchiveOperation Operation,
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) {