llvm-ar: print an error when the requested member is not found.

llvm-svn: 242156
This commit is contained in:
Rafael Espindola 2015-07-14 16:02:40 +00:00
parent 228d149c19
commit c3eec458ab
2 changed files with 16 additions and 3 deletions

View File

@ -41,3 +41,7 @@
; RUN: env TZ=GMT llvm-ar tv %t.a | FileCheck %s
CHECK: 1465 2004-11-19 03:01:31.000000000 very_long_bytecode_file_name.bc
RUN: not llvm-ar x %p/Inputs/GNU.a foo.o 2>&1 | FileCheck --check-prefix=NOTFOUND %s
NOTFOUND: foo.o was not found

View File

@ -391,14 +391,18 @@ static bool shouldCreateArchive(ArchiveOperation Op) {
static void performReadOperation(ArchiveOperation Operation,
object::Archive *OldArchive) {
bool Filter = !Members.empty();
for (const object::Archive::Child &C : OldArchive->children()) {
ErrorOr<StringRef> NameOrErr = C.getName();
failIfError(NameOrErr.getError());
StringRef Name = NameOrErr.get();
if (!Members.empty() &&
std::find(Members.begin(), Members.end(), Name) == Members.end())
continue;
if (Filter) {
auto I = std::find(Members.begin(), Members.end(), Name);
if (I == Members.end())
continue;
Members.erase(I);
}
switch (Operation) {
default:
@ -414,6 +418,11 @@ static void performReadOperation(ArchiveOperation Operation,
break;
}
}
if (Members.empty())
return;
for (StringRef Name : Members)
errs() << Name << " was not found\n";
std::exit(1);
}
template <typename T>