From f4586039f6c620864227f50917d3c488ec95e6be Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Fri, 29 Jul 2016 17:44:13 +0000 Subject: The next step along the way to getting good error messages for bad archives. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As mentioned in commit log for r276686 this next step is adding a new method in the ArchiveMemberHeader class to get the full name that does proper error checking, and can be use for error messages. To do this the name of ArchiveMemberHeader::getName() is changed to ArchiveMemberHeader::getRawName() to be consistent with Archive::Child::getRawName(). Then the “new” method is the addition of a new implementation of ArchiveMemberHeader::getName() which gets the full name and provides proper error checking. Which is mostly a rewrite of what was Archive::Child::getName() and cleaning up incorrect uses of llvm_unreachable() in the code which were actually just cases of errors in the input Archives. Then Archive::Child::getName() is changed to return Expected<> and use the new implementation of ArchiveMemberHeader::getName() . Also needed to change Archive::getMemoryBufferRef() with these changes to return Expected<> as well to propagate Errors up. As well as changing Archive::isThinMember() to return Expected<> . llvm-svn: 277177 --- llvm/tools/llvm-ar/llvm-ar.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'llvm/tools/llvm-ar/llvm-ar.cpp') diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp index dc1755de7d6..f52f9c376c1 100644 --- a/llvm/tools/llvm-ar/llvm-ar.cpp +++ b/llvm/tools/llvm-ar/llvm-ar.cpp @@ -409,8 +409,8 @@ static void performReadOperation(ArchiveOperation Operation, { Error Err; for (auto &C : OldArchive->children(Err)) { - ErrorOr NameOrErr = C.getName(); - failIfError(NameOrErr.getError()); + Expected NameOrErr = C.getName(); + failIfError(NameOrErr.takeError()); StringRef Name = NameOrErr.get(); if (Filter) { @@ -537,8 +537,8 @@ computeNewArchiveMembers(ArchiveOperation Operation, Error Err; for (auto &Child : OldArchive->children(Err)) { int Pos = Ret.size(); - ErrorOr NameOrErr = Child.getName(); - failIfError(NameOrErr.getError()); + Expected NameOrErr = Child.getName(); + failIfError(NameOrErr.takeError()); StringRef Name = NameOrErr.get(); if (Name == PosName) { assert(AddAfter || AddBefore); -- cgit v1.2.3