forked from OSchip/llvm-project
llvm-ar: print an error when the requested member is not found.
llvm-svn: 242156
This commit is contained in:
parent
228d149c19
commit
c3eec458ab
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue