mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
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. llvm-svn: 242330
This commit is contained in:
parent
b7ea1783c2
commit
cb9db3a66d
@ -74,6 +74,7 @@ public:
|
||||
return Data.begin() < other.Data.begin();
|
||||
}
|
||||
|
||||
const Archive *getParent() const { return Parent; }
|
||||
Child getNext() const;
|
||||
|
||||
ErrorOr<StringRef> getName() const;
|
||||
|
@ -318,6 +318,9 @@ llvm::writeArchive(StringRef ArcName,
|
||||
MemberRef = Buffers.back()->getMemBufferRef();
|
||||
} else {
|
||||
object::Archive::child_iterator OldMember = Member.getOld();
|
||||
assert(!Thin ||
|
||||
OldMember->getParent()->isThin() &&
|
||||
"Thin archives cannot refers to member of other archives");
|
||||
ErrorOr<MemoryBufferRef> MemberBufferOrErr =
|
||||
OldMember->getMemoryBufferRef();
|
||||
if (auto EC = MemberBufferOrErr.getError())
|
||||
|
@ -34,3 +34,17 @@ RUN: llvm-ar p %t.a | FileCheck --check-prefix=NEWER %s
|
||||
|
||||
NEWER: newer
|
||||
OLDER: older
|
||||
|
||||
RUN: rm -f %t.a
|
||||
RUN: echo foo > foo
|
||||
RUN: echo bar > bar
|
||||
RUN: llvm-ar --format=gnu rcT %t.a foo
|
||||
RUN: llvm-ar --format=gnu rcT %t.a bar
|
||||
RUN: llvm-ar t %t.a | FileCheck --check-prefix=BOTH-FILES %s
|
||||
BOTH-FILES: foo
|
||||
BOTH-FILES: bar
|
||||
|
||||
RUN: rm -f %t.a
|
||||
RUN: llvm-ar --format=gnu rc %t.a foo
|
||||
RUN: not llvm-ar --format=gnu rcT %t.a bar 2>&1 | FileCheck --check-prefix=ERROR %s
|
||||
ERROR: Cannot convert a regular archive to a thin one.
|
||||
|
@ -436,9 +436,20 @@ static void performReadOperation(ArchiveOperation Operation,
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void addMember(std::vector<NewArchiveIterator> &Members, T I, StringRef Name,
|
||||
void addMember(std::vector<NewArchiveIterator> &Members, StringRef FileName,
|
||||
StringRef Name, int Pos = -1) {
|
||||
NewArchiveIterator NI(FileName, Name);
|
||||
if (Pos == -1)
|
||||
Members.push_back(NI);
|
||||
else
|
||||
Members[Pos] = NI;
|
||||
}
|
||||
|
||||
void addMember(std::vector<NewArchiveIterator> &Members,
|
||||
object::Archive::child_iterator I, StringRef Name,
|
||||
int Pos = -1) {
|
||||
if (Thin && !I->getParent()->isThin())
|
||||
fail("Cannot convert a regular archive to a thin one");
|
||||
NewArchiveIterator NI(I, Name);
|
||||
if (Pos == -1)
|
||||
Members.push_back(NI);
|
||||
|
Loading…
x
Reference in New Issue
Block a user