llvm.org GIT mirror llvm / 8d1daf6
Handle the error of trying to convert a regular archive to a thin one. While at it, test that we can add to a thin archive. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242330 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 4 years ago
4 changed file(s) with 31 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
7373 return Data.begin() < other.Data.begin();
7474 }
7575
76 const Archive *getParent() const { return Parent; }
7677 Child getNext() const;
7778
7879 ErrorOr getName() const;
317317 MemberRef = Buffers.back()->getMemBufferRef();
318318 } else {
319319 object::Archive::child_iterator OldMember = Member.getOld();
320 assert(!Thin ||
321 OldMember->getParent()->isThin() &&
322 "Thin archives cannot refers to member of other archives");
320323 ErrorOr MemberBufferOrErr =
321324 OldMember->getMemoryBufferRef();
322325 if (auto EC = MemberBufferOrErr.getError())
3333
3434 NEWER: newer
3535 OLDER: older
36
37 RUN: rm -f %t.a
38 RUN: echo foo > foo
39 RUN: echo bar > bar
40 RUN: llvm-ar --format=gnu rcT %t.a foo
41 RUN: llvm-ar --format=gnu rcT %t.a bar
42 RUN: llvm-ar t %t.a | FileCheck --check-prefix=BOTH-FILES %s
43 BOTH-FILES: foo
44 BOTH-FILES: bar
45
46 RUN: rm -f %t.a
47 RUN: llvm-ar --format=gnu rc %t.a foo
48 RUN: not llvm-ar --format=gnu rcT %t.a bar 2>&1 | FileCheck --check-prefix=ERROR %s
49 ERROR: Cannot convert a regular archive to a thin one.
435435 std::exit(1);
436436 }
437437
438 template
439 void addMember(std::vector &Members, T I, StringRef Name,
438 void addMember(std::vector &Members, StringRef FileName,
439 StringRef Name, int Pos = -1) {
440 NewArchiveIterator NI(FileName, Name);
441 if (Pos == -1)
442 Members.push_back(NI);
443 else
444 Members[Pos] = NI;
445 }
446
447 void addMember(std::vector &Members,
448 object::Archive::child_iterator I, StringRef Name,
440449 int Pos = -1) {
450 if (Thin && !I->getParent()->isThin())
451 fail("Cannot convert a regular archive to a thin one");
441452 NewArchiveIterator NI(I, Name);
442453 if (Pos == -1)
443454 Members.push_back(NI);