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
This commit is contained in:
Rafael Espindola
2015-07-15 20:45:56 +00:00
parent 2fa118d257
commit 8d1daf644b
4 changed files with 31 additions and 2 deletions

View File

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