mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
[Object] Revert r275316, Archive::child_iterator changes, while I update lld.
Should fix the bots broken by r275316. llvm-svn: 275353
This commit is contained in:
parent
774e517b3f
commit
40892552d6
@ -106,20 +106,21 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class child_iterator {
|
class child_iterator {
|
||||||
Child C;
|
ErrorOr<Child> child;
|
||||||
Error *E;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
child_iterator() : C(Child(nullptr, nullptr, nullptr)), E(nullptr) {}
|
child_iterator() : child(Child(nullptr, nullptr, nullptr)) {}
|
||||||
child_iterator(const Child &C, Error *E) : C(C), E(E) {}
|
child_iterator(const Child &c) : child(c) {}
|
||||||
const Child *operator->() const { return &C; }
|
child_iterator(std::error_code EC) : child(EC) {}
|
||||||
const Child &operator*() const { return C; }
|
const ErrorOr<Child> *operator->() const { return &child; }
|
||||||
|
const ErrorOr<Child> &operator*() const { return child; }
|
||||||
|
|
||||||
bool operator==(const child_iterator &other) const {
|
bool operator==(const child_iterator &other) const {
|
||||||
// Ignore errors here: If an error occurred during increment then getNext
|
// We ignore error states so that comparisions with end() work, which
|
||||||
// will have been set to child_end(), and the following comparison should
|
// allows range loops.
|
||||||
// do the right thing.
|
if (child.getError() || other.child.getError())
|
||||||
return C == other.C;
|
return false;
|
||||||
|
return *child == *other.child;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const child_iterator &other) const {
|
bool operator!=(const child_iterator &other) const {
|
||||||
@ -129,15 +130,8 @@ public:
|
|||||||
// Code in loops with child_iterators must check for errors on each loop
|
// Code in loops with child_iterators must check for errors on each loop
|
||||||
// iteration. And if there is an error break out of the loop.
|
// iteration. And if there is an error break out of the loop.
|
||||||
child_iterator &operator++() { // Preincrement
|
child_iterator &operator++() { // Preincrement
|
||||||
assert(E && "Can't increment iterator with no Error attached");
|
assert(child && "Can't increment iterator with error");
|
||||||
if (auto ChildOrErr = C.getNext())
|
child = child->getNext();
|
||||||
C = *ChildOrErr;
|
|
||||||
else {
|
|
||||||
ErrorAsOutParameter ErrAsOutParam(*E);
|
|
||||||
C = C.getParent()->child_end().C;
|
|
||||||
*E = errorCodeToError(ChildOrErr.getError());
|
|
||||||
E = nullptr;
|
|
||||||
}
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -196,11 +190,10 @@ public:
|
|||||||
Kind kind() const { return (Kind)Format; }
|
Kind kind() const { return (Kind)Format; }
|
||||||
bool isThin() const { return IsThin; }
|
bool isThin() const { return IsThin; }
|
||||||
|
|
||||||
child_iterator child_begin(Error &Err, bool SkipInternal = true) const;
|
child_iterator child_begin(bool SkipInternal = true) const;
|
||||||
child_iterator child_end() const;
|
child_iterator child_end() const;
|
||||||
iterator_range<child_iterator> children(Error &Err,
|
iterator_range<child_iterator> children(bool SkipInternal = true) const {
|
||||||
bool SkipInternal = true) const {
|
return make_range(child_begin(SkipInternal), child_end());
|
||||||
return make_range(child_begin(Err, SkipInternal), child_end());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
symbol_iterator symbol_begin() const;
|
symbol_iterator symbol_begin() const;
|
||||||
@ -215,7 +208,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// check if a symbol is in the archive
|
// check if a symbol is in the archive
|
||||||
child_iterator findSym(Error &Err, StringRef name) const;
|
child_iterator findSym(StringRef name) const;
|
||||||
|
|
||||||
bool hasSymbolTable() const;
|
bool hasSymbolTable() const;
|
||||||
StringRef getSymbolTable() const { return SymbolTable; }
|
StringRef getSymbolTable() const { return SymbolTable; }
|
||||||
|
@ -940,11 +940,6 @@ private:
|
|||||||
std::function<int(const Error &)> GetExitCode;
|
std::function<int(const Error &)> GetExitCode;
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Report a serious error, calling any installed error handler. See
|
|
||||||
/// ErrorHandling.h.
|
|
||||||
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err,
|
|
||||||
bool gen_crash_diag = true);
|
|
||||||
|
|
||||||
} // namespace llvm
|
} // namespace llvm
|
||||||
|
|
||||||
#endif // LLVM_SUPPORT_ERROR_H
|
#endif // LLVM_SUPPORT_ERROR_H
|
||||||
|
@ -327,14 +327,13 @@ RuntimeDyld::SymbolInfo MCJIT::findSymbol(const std::string &Name,
|
|||||||
for (object::OwningBinary<object::Archive> &OB : Archives) {
|
for (object::OwningBinary<object::Archive> &OB : Archives) {
|
||||||
object::Archive *A = OB.getBinary();
|
object::Archive *A = OB.getBinary();
|
||||||
// Look for our symbols in each Archive
|
// Look for our symbols in each Archive
|
||||||
Error Err;
|
object::Archive::child_iterator ChildIt = A->findSym(Name);
|
||||||
object::Archive::child_iterator ChildIt = A->findSym(Err, Name);
|
if (std::error_code EC = ChildIt->getError())
|
||||||
if (Err)
|
report_fatal_error(EC.message());
|
||||||
report_fatal_error(std::move(Err));
|
|
||||||
if (ChildIt != A->child_end()) {
|
if (ChildIt != A->child_end()) {
|
||||||
// FIXME: Support nested archives?
|
// FIXME: Support nested archives?
|
||||||
Expected<std::unique_ptr<object::Binary>> ChildBinOrErr =
|
Expected<std::unique_ptr<object::Binary>> ChildBinOrErr =
|
||||||
ChildIt->getAsBinary();
|
(*ChildIt)->getAsBinary();
|
||||||
if (!ChildBinOrErr) {
|
if (!ChildBinOrErr) {
|
||||||
// TODO: Actually report errors helpfully.
|
// TODO: Actually report errors helpfully.
|
||||||
consumeError(ChildBinOrErr.takeError());
|
consumeError(ChildBinOrErr.takeError());
|
||||||
|
@ -258,14 +258,13 @@ private:
|
|||||||
for (object::OwningBinary<object::Archive> &OB : Archives) {
|
for (object::OwningBinary<object::Archive> &OB : Archives) {
|
||||||
object::Archive *A = OB.getBinary();
|
object::Archive *A = OB.getBinary();
|
||||||
// Look for our symbols in each Archive
|
// Look for our symbols in each Archive
|
||||||
Error Err;
|
object::Archive::child_iterator ChildIt = A->findSym(Name);
|
||||||
object::Archive::child_iterator ChildIt = A->findSym(Err, Name);
|
if (std::error_code EC = ChildIt->getError())
|
||||||
if (Err)
|
report_fatal_error(EC.message());
|
||||||
report_fatal_error(std::move(Err));
|
|
||||||
if (ChildIt != A->child_end()) {
|
if (ChildIt != A->child_end()) {
|
||||||
// FIXME: Support nested archives?
|
// FIXME: Support nested archives?
|
||||||
Expected<std::unique_ptr<object::Binary>> ChildBinOrErr =
|
Expected<std::unique_ptr<object::Binary>> ChildBinOrErr =
|
||||||
ChildIt->getAsBinary();
|
(*ChildIt)->getAsBinary();
|
||||||
if (!ChildBinOrErr) {
|
if (!ChildBinOrErr) {
|
||||||
// TODO: Actually report errors helpfully.
|
// TODO: Actually report errors helpfully.
|
||||||
consumeError(ChildBinOrErr.takeError());
|
consumeError(ChildBinOrErr.takeError());
|
||||||
|
@ -298,9 +298,12 @@ Archive::Archive(MemoryBufferRef Source, Error &Err)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the special members.
|
// Get the special members.
|
||||||
child_iterator I = child_begin(Err, false);
|
child_iterator I = child_begin(false);
|
||||||
if (Err)
|
std::error_code ec;
|
||||||
|
if ((ec = I->getError())) {
|
||||||
|
Err = errorCodeToError(ec);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
child_iterator E = child_end();
|
child_iterator E = child_end();
|
||||||
|
|
||||||
// This is at least a valid empty archive. Since an empty archive is the
|
// This is at least a valid empty archive. Since an empty archive is the
|
||||||
@ -312,13 +315,13 @@ Archive::Archive(MemoryBufferRef Source, Error &Err)
|
|||||||
Err = Error::success();
|
Err = Error::success();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const Child *C = &*I;
|
const Child *C = &**I;
|
||||||
|
|
||||||
auto Increment = [&]() {
|
auto Increment = [&]() {
|
||||||
++I;
|
++I;
|
||||||
if (Err)
|
if ((Err = errorCodeToError(I->getError())))
|
||||||
return true;
|
return true;
|
||||||
C = &*I;
|
C = &**I;
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -363,7 +366,8 @@ Archive::Archive(MemoryBufferRef Source, Error &Err)
|
|||||||
Format = K_BSD;
|
Format = K_BSD;
|
||||||
// We know this is BSD, so getName will work since there is no string table.
|
// We know this is BSD, so getName will work since there is no string table.
|
||||||
ErrorOr<StringRef> NameOrErr = C->getName();
|
ErrorOr<StringRef> NameOrErr = C->getName();
|
||||||
if (auto ec = NameOrErr.getError()) {
|
ec = NameOrErr.getError();
|
||||||
|
if (ec) {
|
||||||
Err = errorCodeToError(ec);
|
Err = errorCodeToError(ec);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -461,29 +465,23 @@ Archive::Archive(MemoryBufferRef Source, Error &Err)
|
|||||||
Err = Error::success();
|
Err = Error::success();
|
||||||
}
|
}
|
||||||
|
|
||||||
Archive::child_iterator Archive::child_begin(Error &Err,
|
Archive::child_iterator Archive::child_begin(bool SkipInternal) const {
|
||||||
bool SkipInternal) const {
|
|
||||||
if (Data.getBufferSize() == 8) // empty archive.
|
if (Data.getBufferSize() == 8) // empty archive.
|
||||||
return child_end();
|
return child_end();
|
||||||
|
|
||||||
if (SkipInternal)
|
if (SkipInternal)
|
||||||
return child_iterator(Child(this, FirstRegularData,
|
return Child(this, FirstRegularData, FirstRegularStartOfFile);
|
||||||
FirstRegularStartOfFile),
|
|
||||||
&Err);
|
|
||||||
|
|
||||||
const char *Loc = Data.getBufferStart() + strlen(Magic);
|
const char *Loc = Data.getBufferStart() + strlen(Magic);
|
||||||
std::error_code EC;
|
std::error_code EC;
|
||||||
Child C(this, Loc, &EC);
|
Child c(this, Loc, &EC);
|
||||||
if (EC) {
|
if (EC)
|
||||||
ErrorAsOutParameter ErrAsOutParam(Err);
|
return child_iterator(EC);
|
||||||
Err = errorCodeToError(EC);
|
return child_iterator(c);
|
||||||
return child_end();
|
|
||||||
}
|
|
||||||
return child_iterator(C, &Err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Archive::child_iterator Archive::child_end() const {
|
Archive::child_iterator Archive::child_end() const {
|
||||||
return child_iterator(Child(this, nullptr, nullptr), nullptr);
|
return Child(this, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringRef Archive::Symbol::getName() const {
|
StringRef Archive::Symbol::getName() const {
|
||||||
@ -667,20 +665,18 @@ uint32_t Archive::getNumberOfSymbols() const {
|
|||||||
return read32le(buf);
|
return read32le(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
Archive::child_iterator Archive::findSym(Error &Err, StringRef name) const {
|
Archive::child_iterator Archive::findSym(StringRef name) const {
|
||||||
Archive::symbol_iterator bs = symbol_begin();
|
Archive::symbol_iterator bs = symbol_begin();
|
||||||
Archive::symbol_iterator es = symbol_end();
|
Archive::symbol_iterator es = symbol_end();
|
||||||
|
|
||||||
for (; bs != es; ++bs) {
|
for (; bs != es; ++bs) {
|
||||||
StringRef SymName = bs->getName();
|
StringRef SymName = bs->getName();
|
||||||
if (SymName == name) {
|
if (SymName == name) {
|
||||||
if (auto MemberOrErr = bs->getMember()) {
|
ErrorOr<Archive::child_iterator> ResultOrErr = bs->getMember();
|
||||||
return child_iterator(*MemberOrErr, &Err);
|
// FIXME: Should we really eat the error?
|
||||||
} else {
|
if (ResultOrErr.getError())
|
||||||
ErrorAsOutParameter ErrAsOutParam(Err);
|
|
||||||
Err = errorCodeToError(MemberOrErr.getError());
|
|
||||||
return child_end();
|
return child_end();
|
||||||
}
|
return ResultOrErr.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return child_end();
|
return child_end();
|
||||||
|
@ -64,7 +64,6 @@ void logAllUnhandledErrors(Error E, raw_ostream &OS, Twine ErrorBanner) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::error_code ErrorList::convertToErrorCode() const {
|
std::error_code ErrorList::convertToErrorCode() const {
|
||||||
return std::error_code(static_cast<int>(ErrorErrorCode::MultipleErrors),
|
return std::error_code(static_cast<int>(ErrorErrorCode::MultipleErrors),
|
||||||
*ErrorErrorCat);
|
*ErrorErrorCat);
|
||||||
@ -100,14 +99,4 @@ std::error_code StringError::convertToErrorCode() const {
|
|||||||
return EC;
|
return EC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void report_fatal_error(Error Err, bool GenCrashDiag) {
|
|
||||||
assert(Err && "report_fatal_error called with success value");
|
|
||||||
std::string ErrMsg;
|
|
||||||
{
|
|
||||||
raw_string_ostream ErrStream(ErrMsg);
|
|
||||||
logAllUnhandledErrors(std::move(Err), ErrStream, "");
|
|
||||||
}
|
|
||||||
report_fatal_error(ErrMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -102,8 +102,10 @@ BinaryHolder::GetArchiveMemberBuffers(StringRef Filename,
|
|||||||
Buffers.reserve(CurrentArchives.size());
|
Buffers.reserve(CurrentArchives.size());
|
||||||
|
|
||||||
for (const auto &CurrentArchive : CurrentArchives) {
|
for (const auto &CurrentArchive : CurrentArchives) {
|
||||||
Error Err;
|
for (auto ChildOrErr : CurrentArchive->children()) {
|
||||||
for (auto Child : CurrentArchive->children(Err)) {
|
if (std::error_code Err = ChildOrErr.getError())
|
||||||
|
return Err;
|
||||||
|
const auto &Child = *ChildOrErr;
|
||||||
if (auto NameOrErr = Child.getName()) {
|
if (auto NameOrErr = Child.getName()) {
|
||||||
if (*NameOrErr == Filename) {
|
if (*NameOrErr == Filename) {
|
||||||
if (Timestamp != sys::TimeValue::PosixZeroTime() &&
|
if (Timestamp != sys::TimeValue::PosixZeroTime() &&
|
||||||
@ -121,8 +123,6 @@ BinaryHolder::GetArchiveMemberBuffers(StringRef Filename,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Err)
|
|
||||||
return errorToErrorCode(std::move(Err));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Buffers.empty())
|
if (Buffers.empty())
|
||||||
|
@ -405,37 +405,35 @@ static void performReadOperation(ArchiveOperation Operation,
|
|||||||
fail("extracting from a thin archive is not supported");
|
fail("extracting from a thin archive is not supported");
|
||||||
|
|
||||||
bool Filter = !Members.empty();
|
bool Filter = !Members.empty();
|
||||||
{
|
for (auto &ChildOrErr : OldArchive->children()) {
|
||||||
Error Err;
|
failIfError(ChildOrErr.getError());
|
||||||
for (auto &C : OldArchive->children(Err)) {
|
const object::Archive::Child &C = *ChildOrErr;
|
||||||
ErrorOr<StringRef> NameOrErr = C.getName();
|
|
||||||
failIfError(NameOrErr.getError());
|
|
||||||
StringRef Name = NameOrErr.get();
|
|
||||||
|
|
||||||
if (Filter) {
|
ErrorOr<StringRef> NameOrErr = C.getName();
|
||||||
auto I = std::find(Members.begin(), Members.end(), Name);
|
failIfError(NameOrErr.getError());
|
||||||
if (I == Members.end())
|
StringRef Name = NameOrErr.get();
|
||||||
continue;
|
|
||||||
Members.erase(I);
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (Operation) {
|
if (Filter) {
|
||||||
default:
|
auto I = std::find(Members.begin(), Members.end(), Name);
|
||||||
llvm_unreachable("Not a read operation");
|
if (I == Members.end())
|
||||||
case Print:
|
continue;
|
||||||
doPrint(Name, C);
|
Members.erase(I);
|
||||||
break;
|
|
||||||
case DisplayTable:
|
|
||||||
doDisplayTable(Name, C);
|
|
||||||
break;
|
|
||||||
case Extract:
|
|
||||||
doExtract(Name, C);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
failIfError(std::move(Err));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
switch (Operation) {
|
||||||
|
default:
|
||||||
|
llvm_unreachable("Not a read operation");
|
||||||
|
case Print:
|
||||||
|
doPrint(Name, C);
|
||||||
|
break;
|
||||||
|
case DisplayTable:
|
||||||
|
doDisplayTable(Name, C);
|
||||||
|
break;
|
||||||
|
case Extract:
|
||||||
|
doExtract(Name, C);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (Members.empty())
|
if (Members.empty())
|
||||||
return;
|
return;
|
||||||
for (StringRef Name : Members)
|
for (StringRef Name : Members)
|
||||||
@ -533,8 +531,9 @@ computeNewArchiveMembers(ArchiveOperation Operation,
|
|||||||
int InsertPos = -1;
|
int InsertPos = -1;
|
||||||
StringRef PosName = sys::path::filename(RelPos);
|
StringRef PosName = sys::path::filename(RelPos);
|
||||||
if (OldArchive) {
|
if (OldArchive) {
|
||||||
Error Err;
|
for (auto &ChildOrErr : OldArchive->children()) {
|
||||||
for (auto &Child : OldArchive->children(Err)) {
|
failIfError(ChildOrErr.getError());
|
||||||
|
auto &Child = ChildOrErr.get();
|
||||||
int Pos = Ret.size();
|
int Pos = Ret.size();
|
||||||
ErrorOr<StringRef> NameOrErr = Child.getName();
|
ErrorOr<StringRef> NameOrErr = Child.getName();
|
||||||
failIfError(NameOrErr.getError());
|
failIfError(NameOrErr.getError());
|
||||||
@ -569,7 +568,6 @@ computeNewArchiveMembers(ArchiveOperation Operation,
|
|||||||
if (MemberI != Members.end())
|
if (MemberI != Members.end())
|
||||||
Members.erase(MemberI);
|
Members.erase(MemberI);
|
||||||
}
|
}
|
||||||
failIfError(std::move(Err));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Operation == Delete)
|
if (Operation == Delete)
|
||||||
@ -766,11 +764,9 @@ static void runMRIScript() {
|
|||||||
"Could not parse library");
|
"Could not parse library");
|
||||||
Archives.push_back(std::move(*LibOrErr));
|
Archives.push_back(std::move(*LibOrErr));
|
||||||
object::Archive &Lib = *Archives.back();
|
object::Archive &Lib = *Archives.back();
|
||||||
{
|
for (auto &MemberOrErr : Lib.children()) {
|
||||||
Error Err;
|
failIfError(MemberOrErr.getError());
|
||||||
for (auto &Member : Lib.children(Err))
|
addMember(NewMembers, *MemberOrErr);
|
||||||
addMember(NewMembers, Member);
|
|
||||||
failIfError(std::move(Err));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -50,14 +50,6 @@ static void error(std::error_code EC) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void error(Error Err) {
|
|
||||||
if (Err) {
|
|
||||||
logAllUnhandledErrors(std::move(Err), outs(), "Error reading file: ");
|
|
||||||
outs().flush();
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace llvm
|
} // namespace llvm
|
||||||
|
|
||||||
static void reportError(StringRef Input, StringRef Message) {
|
static void reportError(StringRef Input, StringRef Message) {
|
||||||
@ -490,8 +482,9 @@ static void dumpCXXData(const ObjectFile *Obj) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void dumpArchive(const Archive *Arc) {
|
static void dumpArchive(const Archive *Arc) {
|
||||||
Error Err;
|
for (auto &ErrorOrChild : Arc->children()) {
|
||||||
for (auto &ArcC : Arc->children(Err)) {
|
error(ErrorOrChild.getError());
|
||||||
|
const Archive::Child &ArcC = *ErrorOrChild;
|
||||||
Expected<std::unique_ptr<Binary>> ChildOrErr = ArcC.getAsBinary();
|
Expected<std::unique_ptr<Binary>> ChildOrErr = ArcC.getAsBinary();
|
||||||
if (!ChildOrErr) {
|
if (!ChildOrErr) {
|
||||||
// Ignore non-object files.
|
// Ignore non-object files.
|
||||||
@ -511,7 +504,6 @@ static void dumpArchive(const Archive *Arc) {
|
|||||||
else
|
else
|
||||||
reportError(Arc->getFileName(), cxxdump_error::unrecognized_file_format);
|
reportError(Arc->getFileName(), cxxdump_error::unrecognized_file_format);
|
||||||
}
|
}
|
||||||
error(std::move(Err));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void dumpInput(StringRef File) {
|
static void dumpInput(StringRef File) {
|
||||||
|
@ -1109,31 +1109,30 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
for (Archive::child_iterator I = A->child_begin(), E = A->child_end();
|
||||||
Error Err;
|
I != E; ++I) {
|
||||||
for (auto &C : A->children(Err)) {
|
if (error(I->getError()))
|
||||||
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary(&Context);
|
return;
|
||||||
if (!ChildOrErr) {
|
auto &C = I->get();
|
||||||
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
|
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary(&Context);
|
||||||
error(std::move(E), Filename, C);
|
if (!ChildOrErr) {
|
||||||
continue;
|
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
|
||||||
}
|
error(std::move(E), Filename, C);
|
||||||
if (SymbolicFile *O = dyn_cast<SymbolicFile>(&*ChildOrErr.get())) {
|
continue;
|
||||||
if (!checkMachOAndArchFlags(O, Filename))
|
}
|
||||||
return;
|
if (SymbolicFile *O = dyn_cast<SymbolicFile>(&*ChildOrErr.get())) {
|
||||||
if (!PrintFileName) {
|
if (!checkMachOAndArchFlags(O, Filename))
|
||||||
outs() << "\n";
|
return;
|
||||||
if (isa<MachOObjectFile>(O)) {
|
if (!PrintFileName) {
|
||||||
outs() << Filename << "(" << O->getFileName() << ")";
|
outs() << "\n";
|
||||||
} else
|
if (isa<MachOObjectFile>(O)) {
|
||||||
outs() << O->getFileName();
|
outs() << Filename << "(" << O->getFileName() << ")";
|
||||||
outs() << ":\n";
|
} else
|
||||||
}
|
outs() << O->getFileName();
|
||||||
dumpSymbolNamesFromObject(*O, false, Filename);
|
outs() << ":\n";
|
||||||
}
|
}
|
||||||
|
dumpSymbolNamesFromObject(*O, false, Filename);
|
||||||
}
|
}
|
||||||
if (Err)
|
|
||||||
error(std::move(Err), A->getFileName());
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1175,8 +1174,12 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
|||||||
} else if (Expected<std::unique_ptr<Archive>> AOrErr =
|
} else if (Expected<std::unique_ptr<Archive>> AOrErr =
|
||||||
I->getAsArchive()) {
|
I->getAsArchive()) {
|
||||||
std::unique_ptr<Archive> &A = *AOrErr;
|
std::unique_ptr<Archive> &A = *AOrErr;
|
||||||
Error Err;
|
for (Archive::child_iterator AI = A->child_begin(),
|
||||||
for (auto &C : A->children(Err)) {
|
AE = A->child_end();
|
||||||
|
AI != AE; ++AI) {
|
||||||
|
if (error(AI->getError()))
|
||||||
|
return;
|
||||||
|
auto &C = AI->get();
|
||||||
Expected<std::unique_ptr<Binary>> ChildOrErr =
|
Expected<std::unique_ptr<Binary>> ChildOrErr =
|
||||||
C.getAsBinary(&Context);
|
C.getAsBinary(&Context);
|
||||||
if (!ChildOrErr) {
|
if (!ChildOrErr) {
|
||||||
@ -1206,8 +1209,6 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
|||||||
ArchitectureName);
|
ArchitectureName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Err)
|
|
||||||
error(std::move(Err), A->getFileName());
|
|
||||||
} else {
|
} else {
|
||||||
consumeError(AOrErr.takeError());
|
consumeError(AOrErr.takeError());
|
||||||
error(Filename + " for architecture " +
|
error(Filename + " for architecture " +
|
||||||
@ -1246,8 +1247,12 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
|||||||
} else if (Expected<std::unique_ptr<Archive>> AOrErr =
|
} else if (Expected<std::unique_ptr<Archive>> AOrErr =
|
||||||
I->getAsArchive()) {
|
I->getAsArchive()) {
|
||||||
std::unique_ptr<Archive> &A = *AOrErr;
|
std::unique_ptr<Archive> &A = *AOrErr;
|
||||||
Error Err;
|
for (Archive::child_iterator AI = A->child_begin(),
|
||||||
for (auto &C : A->children(Err)) {
|
AE = A->child_end();
|
||||||
|
AI != AE; ++AI) {
|
||||||
|
if (error(AI->getError()))
|
||||||
|
return;
|
||||||
|
auto &C = AI->get();
|
||||||
Expected<std::unique_ptr<Binary>> ChildOrErr =
|
Expected<std::unique_ptr<Binary>> ChildOrErr =
|
||||||
C.getAsBinary(&Context);
|
C.getAsBinary(&Context);
|
||||||
if (!ChildOrErr) {
|
if (!ChildOrErr) {
|
||||||
@ -1267,8 +1272,6 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
|||||||
dumpSymbolNamesFromObject(*O, false, ArchiveName);
|
dumpSymbolNamesFromObject(*O, false, ArchiveName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Err)
|
|
||||||
error(std::move(Err), A->getFileName());
|
|
||||||
} else {
|
} else {
|
||||||
consumeError(AOrErr.takeError());
|
consumeError(AOrErr.takeError());
|
||||||
error(Filename + " for architecture " +
|
error(Filename + " for architecture " +
|
||||||
@ -1313,8 +1316,11 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
|||||||
} else if (Expected<std::unique_ptr<Archive>> AOrErr =
|
} else if (Expected<std::unique_ptr<Archive>> AOrErr =
|
||||||
I->getAsArchive()) {
|
I->getAsArchive()) {
|
||||||
std::unique_ptr<Archive> &A = *AOrErr;
|
std::unique_ptr<Archive> &A = *AOrErr;
|
||||||
Error Err;
|
for (Archive::child_iterator AI = A->child_begin(), AE = A->child_end();
|
||||||
for (auto &C : A->children(Err)) {
|
AI != AE; ++AI) {
|
||||||
|
if (error(AI->getError()))
|
||||||
|
return;
|
||||||
|
auto &C = AI->get();
|
||||||
Expected<std::unique_ptr<Binary>> ChildOrErr =
|
Expected<std::unique_ptr<Binary>> ChildOrErr =
|
||||||
C.getAsBinary(&Context);
|
C.getAsBinary(&Context);
|
||||||
if (!ChildOrErr) {
|
if (!ChildOrErr) {
|
||||||
@ -1343,8 +1349,6 @@ static void dumpSymbolNamesFromFile(std::string &Filename) {
|
|||||||
dumpSymbolNamesFromObject(*O, false, ArchiveName, ArchitectureName);
|
dumpSymbolNamesFromObject(*O, false, ArchiveName, ArchitectureName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Err)
|
|
||||||
error(std::move(Err), A->getFileName());
|
|
||||||
} else {
|
} else {
|
||||||
consumeError(AOrErr.takeError());
|
consumeError(AOrErr.takeError());
|
||||||
error(Filename + " for architecture " +
|
error(Filename + " for architecture " +
|
||||||
|
@ -1535,11 +1535,13 @@ static void printArchiveChild(const Archive::Child &C, bool verbose,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void printArchiveHeaders(Archive *A, bool verbose, bool print_offset) {
|
static void printArchiveHeaders(Archive *A, bool verbose, bool print_offset) {
|
||||||
Error Err;
|
for (Archive::child_iterator I = A->child_begin(false), E = A->child_end();
|
||||||
for (const auto &C : A->children(Err, false))
|
I != E; ++I) {
|
||||||
|
if (std::error_code EC = I->getError())
|
||||||
|
report_fatal_error(EC.message());
|
||||||
|
const Archive::Child &C = **I;
|
||||||
printArchiveChild(C, verbose, print_offset);
|
printArchiveChild(C, verbose, print_offset);
|
||||||
if (Err)
|
}
|
||||||
report_fatal_error(std::move(Err));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseInputMachO() parses the named Mach-O file in Filename and handles the
|
// ParseInputMachO() parses the named Mach-O file in Filename and handles the
|
||||||
@ -1570,8 +1572,11 @@ void llvm::ParseInputMachO(StringRef Filename) {
|
|||||||
outs() << "Archive : " << Filename << "\n";
|
outs() << "Archive : " << Filename << "\n";
|
||||||
if (ArchiveHeaders)
|
if (ArchiveHeaders)
|
||||||
printArchiveHeaders(A, !NonVerbose, ArchiveMemberOffsets);
|
printArchiveHeaders(A, !NonVerbose, ArchiveMemberOffsets);
|
||||||
Error Err;
|
for (Archive::child_iterator I = A->child_begin(), E = A->child_end();
|
||||||
for (auto &C : A->children(Err)) {
|
I != E; ++I) {
|
||||||
|
if (std::error_code EC = I->getError())
|
||||||
|
report_error(Filename, EC);
|
||||||
|
auto &C = I->get();
|
||||||
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
|
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
|
||||||
if (!ChildOrErr) {
|
if (!ChildOrErr) {
|
||||||
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
|
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
|
||||||
@ -1584,8 +1589,6 @@ void llvm::ParseInputMachO(StringRef Filename) {
|
|||||||
ProcessMachO(Filename, O, O->getFileName());
|
ProcessMachO(Filename, O, O->getFileName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Err)
|
|
||||||
report_error(Filename, std::move(Err));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (UniversalHeaders) {
|
if (UniversalHeaders) {
|
||||||
@ -1627,8 +1630,12 @@ void llvm::ParseInputMachO(StringRef Filename) {
|
|||||||
outs() << "\n";
|
outs() << "\n";
|
||||||
if (ArchiveHeaders)
|
if (ArchiveHeaders)
|
||||||
printArchiveHeaders(A.get(), !NonVerbose, ArchiveMemberOffsets);
|
printArchiveHeaders(A.get(), !NonVerbose, ArchiveMemberOffsets);
|
||||||
Error Err;
|
for (Archive::child_iterator AI = A->child_begin(),
|
||||||
for (auto &C : A->children(Err)) {
|
AE = A->child_end();
|
||||||
|
AI != AE; ++AI) {
|
||||||
|
if (std::error_code EC = AI->getError())
|
||||||
|
report_error(Filename, EC);
|
||||||
|
auto &C = AI->get();
|
||||||
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
|
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
|
||||||
if (!ChildOrErr) {
|
if (!ChildOrErr) {
|
||||||
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
|
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
|
||||||
@ -1639,8 +1646,6 @@ void llvm::ParseInputMachO(StringRef Filename) {
|
|||||||
dyn_cast<MachOObjectFile>(&*ChildOrErr.get()))
|
dyn_cast<MachOObjectFile>(&*ChildOrErr.get()))
|
||||||
ProcessMachO(Filename, O, O->getFileName(), ArchitectureName);
|
ProcessMachO(Filename, O, O->getFileName(), ArchitectureName);
|
||||||
}
|
}
|
||||||
if (Err)
|
|
||||||
report_error(Filename, std::move(Err));
|
|
||||||
} else {
|
} else {
|
||||||
consumeError(AOrErr.takeError());
|
consumeError(AOrErr.takeError());
|
||||||
error("Mach-O universal file: " + Filename + " for " +
|
error("Mach-O universal file: " + Filename + " for " +
|
||||||
@ -1682,8 +1687,12 @@ void llvm::ParseInputMachO(StringRef Filename) {
|
|||||||
outs() << "Archive : " << Filename << "\n";
|
outs() << "Archive : " << Filename << "\n";
|
||||||
if (ArchiveHeaders)
|
if (ArchiveHeaders)
|
||||||
printArchiveHeaders(A.get(), !NonVerbose, ArchiveMemberOffsets);
|
printArchiveHeaders(A.get(), !NonVerbose, ArchiveMemberOffsets);
|
||||||
Error Err;
|
for (Archive::child_iterator AI = A->child_begin(),
|
||||||
for (auto &C : A->children(Err)) {
|
AE = A->child_end();
|
||||||
|
AI != AE; ++AI) {
|
||||||
|
if (std::error_code EC = AI->getError())
|
||||||
|
report_error(Filename, EC);
|
||||||
|
auto &C = AI->get();
|
||||||
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
|
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
|
||||||
if (!ChildOrErr) {
|
if (!ChildOrErr) {
|
||||||
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
|
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
|
||||||
@ -1694,8 +1703,6 @@ void llvm::ParseInputMachO(StringRef Filename) {
|
|||||||
dyn_cast<MachOObjectFile>(&*ChildOrErr.get()))
|
dyn_cast<MachOObjectFile>(&*ChildOrErr.get()))
|
||||||
ProcessMachO(Filename, O, O->getFileName());
|
ProcessMachO(Filename, O, O->getFileName());
|
||||||
}
|
}
|
||||||
if (Err)
|
|
||||||
report_error(Filename, std::move(Err));
|
|
||||||
} else {
|
} else {
|
||||||
consumeError(AOrErr.takeError());
|
consumeError(AOrErr.takeError());
|
||||||
error("Mach-O universal file: " + Filename + " for architecture " +
|
error("Mach-O universal file: " + Filename + " for architecture " +
|
||||||
@ -1733,8 +1740,11 @@ void llvm::ParseInputMachO(StringRef Filename) {
|
|||||||
outs() << "\n";
|
outs() << "\n";
|
||||||
if (ArchiveHeaders)
|
if (ArchiveHeaders)
|
||||||
printArchiveHeaders(A.get(), !NonVerbose, ArchiveMemberOffsets);
|
printArchiveHeaders(A.get(), !NonVerbose, ArchiveMemberOffsets);
|
||||||
Error Err;
|
for (Archive::child_iterator AI = A->child_begin(), AE = A->child_end();
|
||||||
for (auto &C : A->children(Err)) {
|
AI != AE; ++AI) {
|
||||||
|
if (std::error_code EC = AI->getError())
|
||||||
|
report_error(Filename, EC);
|
||||||
|
auto &C = AI->get();
|
||||||
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
|
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
|
||||||
if (!ChildOrErr) {
|
if (!ChildOrErr) {
|
||||||
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
|
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
|
||||||
@ -1748,8 +1758,6 @@ void llvm::ParseInputMachO(StringRef Filename) {
|
|||||||
ArchitectureName);
|
ArchitectureName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Err)
|
|
||||||
report_error(Filename, std::move(Err));
|
|
||||||
} else {
|
} else {
|
||||||
consumeError(AOrErr.takeError());
|
consumeError(AOrErr.takeError());
|
||||||
error("Mach-O universal file: " + Filename + " for architecture " +
|
error("Mach-O universal file: " + Filename + " for architecture " +
|
||||||
|
@ -1702,8 +1702,10 @@ static void DumpObject(const ObjectFile *o, const Archive *a = nullptr) {
|
|||||||
|
|
||||||
/// @brief Dump each object file in \a a;
|
/// @brief Dump each object file in \a a;
|
||||||
static void DumpArchive(const Archive *a) {
|
static void DumpArchive(const Archive *a) {
|
||||||
Error Err;
|
for (auto &ErrorOrChild : a->children()) {
|
||||||
for (auto &C : a->children(Err)) {
|
if (std::error_code EC = ErrorOrChild.getError())
|
||||||
|
report_error(a->getFileName(), EC);
|
||||||
|
const Archive::Child &C = *ErrorOrChild;
|
||||||
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
|
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
|
||||||
if (!ChildOrErr) {
|
if (!ChildOrErr) {
|
||||||
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
|
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
|
||||||
@ -1715,8 +1717,6 @@ static void DumpArchive(const Archive *a) {
|
|||||||
else
|
else
|
||||||
report_error(a->getFileName(), object_error::invalid_file_type);
|
report_error(a->getFileName(), object_error::invalid_file_type);
|
||||||
}
|
}
|
||||||
if (Err)
|
|
||||||
report_error(a->getFileName(), std::move(Err));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Open file and figure out how to dump it.
|
/// @brief Open file and figure out how to dump it.
|
||||||
|
@ -295,17 +295,6 @@ static void reportError(StringRef Input, StringRef Message) {
|
|||||||
reportError(Twine(Input) + ": " + Message);
|
reportError(Twine(Input) + ": " + Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reportError(StringRef Input, Error Err) {
|
|
||||||
if (Input == "-")
|
|
||||||
Input = "<stdin>";
|
|
||||||
std::string ErrMsg;
|
|
||||||
{
|
|
||||||
raw_string_ostream ErrStream(ErrMsg);
|
|
||||||
logAllUnhandledErrors(std::move(Err), ErrStream, Input + ": ");
|
|
||||||
}
|
|
||||||
reportError(ErrMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool isMipsArch(unsigned Arch) {
|
static bool isMipsArch(unsigned Arch) {
|
||||||
switch (Arch) {
|
switch (Arch) {
|
||||||
case llvm::Triple::mips:
|
case llvm::Triple::mips:
|
||||||
@ -435,8 +424,10 @@ static void dumpObject(const ObjectFile *Obj) {
|
|||||||
|
|
||||||
/// @brief Dumps each object file in \a Arc;
|
/// @brief Dumps each object file in \a Arc;
|
||||||
static void dumpArchive(const Archive *Arc) {
|
static void dumpArchive(const Archive *Arc) {
|
||||||
Error Err;
|
for (auto &ErrorOrChild : Arc->children()) {
|
||||||
for (auto &Child : Arc->children(Err)) {
|
if (std::error_code EC = ErrorOrChild.getError())
|
||||||
|
reportError(Arc->getFileName(), EC.message());
|
||||||
|
const auto &Child = *ErrorOrChild;
|
||||||
Expected<std::unique_ptr<Binary>> ChildOrErr = Child.getAsBinary();
|
Expected<std::unique_ptr<Binary>> ChildOrErr = Child.getAsBinary();
|
||||||
if (!ChildOrErr) {
|
if (!ChildOrErr) {
|
||||||
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) {
|
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) {
|
||||||
@ -453,8 +444,6 @@ static void dumpArchive(const Archive *Arc) {
|
|||||||
else
|
else
|
||||||
reportError(Arc->getFileName(), readobj_error::unrecognized_file_format);
|
reportError(Arc->getFileName(), readobj_error::unrecognized_file_format);
|
||||||
}
|
}
|
||||||
if (Err)
|
|
||||||
reportError(Arc->getFileName(), std::move(Err));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Dumps each object file in \a MachO Universal Binary;
|
/// @brief Dumps each object file in \a MachO Universal Binary;
|
||||||
|
@ -527,12 +527,15 @@ static void printFileSectionSizes(StringRef file) {
|
|||||||
|
|
||||||
if (Archive *a = dyn_cast<Archive>(&Bin)) {
|
if (Archive *a = dyn_cast<Archive>(&Bin)) {
|
||||||
// This is an archive. Iterate over each member and display its sizes.
|
// This is an archive. Iterate over each member and display its sizes.
|
||||||
Error Err;
|
for (object::Archive::child_iterator i = a->child_begin(),
|
||||||
for (auto &C : a->children(Err)) {
|
e = a->child_end();
|
||||||
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
|
i != e; ++i) {
|
||||||
|
if (error(i->getError()))
|
||||||
|
exit(1);
|
||||||
|
Expected<std::unique_ptr<Binary>> ChildOrErr = i->get().getAsBinary();
|
||||||
if (!ChildOrErr) {
|
if (!ChildOrErr) {
|
||||||
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
|
if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError()))
|
||||||
error(std::move(E), a->getFileName(), C);
|
error(std::move(E), a->getFileName(), i->get());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get())) {
|
if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get())) {
|
||||||
@ -552,8 +555,6 @@ static void printFileSectionSizes(StringRef file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Err)
|
|
||||||
error(std::move(Err), a->getFileName());
|
|
||||||
} else if (MachOUniversalBinary *UB =
|
} else if (MachOUniversalBinary *UB =
|
||||||
dyn_cast<MachOUniversalBinary>(&Bin)) {
|
dyn_cast<MachOUniversalBinary>(&Bin)) {
|
||||||
// If we have a list of architecture flags specified dump only those.
|
// If we have a list of architecture flags specified dump only those.
|
||||||
@ -596,13 +597,17 @@ static void printFileSectionSizes(StringRef file) {
|
|||||||
std::unique_ptr<Archive> &UA = *AOrErr;
|
std::unique_ptr<Archive> &UA = *AOrErr;
|
||||||
// This is an archive. Iterate over each member and display its
|
// This is an archive. Iterate over each member and display its
|
||||||
// sizes.
|
// sizes.
|
||||||
Error Err;
|
for (object::Archive::child_iterator i = UA->child_begin(),
|
||||||
for (auto &C : UA->children(Err)) {
|
e = UA->child_end();
|
||||||
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
|
i != e; ++i) {
|
||||||
|
if (error(i->getError()))
|
||||||
|
exit(1);
|
||||||
|
Expected<std::unique_ptr<Binary>> ChildOrErr =
|
||||||
|
i->get().getAsBinary();
|
||||||
if (!ChildOrErr) {
|
if (!ChildOrErr) {
|
||||||
if (auto E = isNotObjectErrorInvalidFileType(
|
if (auto E = isNotObjectErrorInvalidFileType(
|
||||||
ChildOrErr.takeError()))
|
ChildOrErr.takeError()))
|
||||||
error(std::move(E), UA->getFileName(), C,
|
error(std::move(E), UA->getFileName(), i->get(),
|
||||||
ArchFlags.size() > 1 ?
|
ArchFlags.size() > 1 ?
|
||||||
StringRef(I->getArchTypeName()) : StringRef());
|
StringRef(I->getArchTypeName()) : StringRef());
|
||||||
continue;
|
continue;
|
||||||
@ -632,8 +637,6 @@ static void printFileSectionSizes(StringRef file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Err)
|
|
||||||
error(std::move(Err), UA->getFileName());
|
|
||||||
} else {
|
} else {
|
||||||
consumeError(AOrErr.takeError());
|
consumeError(AOrErr.takeError());
|
||||||
error("Mach-O universal file: " + file + " for architecture " +
|
error("Mach-O universal file: " + file + " for architecture " +
|
||||||
@ -685,13 +688,17 @@ static void printFileSectionSizes(StringRef file) {
|
|||||||
std::unique_ptr<Archive> &UA = *AOrErr;
|
std::unique_ptr<Archive> &UA = *AOrErr;
|
||||||
// This is an archive. Iterate over each member and display its
|
// This is an archive. Iterate over each member and display its
|
||||||
// sizes.
|
// sizes.
|
||||||
Error Err;
|
for (object::Archive::child_iterator i = UA->child_begin(),
|
||||||
for (auto &C : UA->children(Err)) {
|
e = UA->child_end();
|
||||||
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
|
i != e; ++i) {
|
||||||
|
if (error(i->getError()))
|
||||||
|
exit(1);
|
||||||
|
Expected<std::unique_ptr<Binary>> ChildOrErr =
|
||||||
|
i->get().getAsBinary();
|
||||||
if (!ChildOrErr) {
|
if (!ChildOrErr) {
|
||||||
if (auto E = isNotObjectErrorInvalidFileType(
|
if (auto E = isNotObjectErrorInvalidFileType(
|
||||||
ChildOrErr.takeError()))
|
ChildOrErr.takeError()))
|
||||||
error(std::move(E), UA->getFileName(), C);
|
error(std::move(E), UA->getFileName(), i->get());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get())) {
|
if (ObjectFile *o = dyn_cast<ObjectFile>(&*ChildOrErr.get())) {
|
||||||
@ -714,8 +721,6 @@ static void printFileSectionSizes(StringRef file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Err)
|
|
||||||
error(std::move(Err), UA->getFileName());
|
|
||||||
} else {
|
} else {
|
||||||
consumeError(AOrErr.takeError());
|
consumeError(AOrErr.takeError());
|
||||||
error("Mach-O universal file: " + file + " for architecture " +
|
error("Mach-O universal file: " + file + " for architecture " +
|
||||||
@ -760,13 +765,16 @@ static void printFileSectionSizes(StringRef file) {
|
|||||||
I->getAsArchive()) {
|
I->getAsArchive()) {
|
||||||
std::unique_ptr<Archive> &UA = *AOrErr;
|
std::unique_ptr<Archive> &UA = *AOrErr;
|
||||||
// This is an archive. Iterate over each member and display its sizes.
|
// This is an archive. Iterate over each member and display its sizes.
|
||||||
Error Err;
|
for (object::Archive::child_iterator i = UA->child_begin(),
|
||||||
for (auto &C : UA->children(Err)) {
|
e = UA->child_end();
|
||||||
Expected<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
|
i != e; ++i) {
|
||||||
|
if (error(i->getError()))
|
||||||
|
exit(1);
|
||||||
|
Expected<std::unique_ptr<Binary>> ChildOrErr = i->get().getAsBinary();
|
||||||
if (!ChildOrErr) {
|
if (!ChildOrErr) {
|
||||||
if (auto E = isNotObjectErrorInvalidFileType(
|
if (auto E = isNotObjectErrorInvalidFileType(
|
||||||
ChildOrErr.takeError()))
|
ChildOrErr.takeError()))
|
||||||
error(std::move(E), UA->getFileName(), C, MoreThanOneArch ?
|
error(std::move(E), UA->getFileName(), i->get(), MoreThanOneArch ?
|
||||||
StringRef(I->getArchTypeName()) : StringRef());
|
StringRef(I->getArchTypeName()) : StringRef());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -790,8 +798,6 @@ static void printFileSectionSizes(StringRef file) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Err)
|
|
||||||
error(std::move(Err), UA->getFileName());
|
|
||||||
} else {
|
} else {
|
||||||
consumeError(AOrErr.takeError());
|
consumeError(AOrErr.takeError());
|
||||||
error("Mach-O universal file: " + file + " for architecture " +
|
error("Mach-O universal file: " + file + " for architecture " +
|
||||||
|
@ -135,15 +135,10 @@ template <typename T> static void FailIfError(const ErrorOr<T> &E) {
|
|||||||
FailIfError(E.getError());
|
FailIfError(E.getError());
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FailIfError(Error Err) {
|
|
||||||
if (Err) {
|
|
||||||
logAllUnhandledErrors(std::move(Err), errs(), "Error: ");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T> static void FailIfError(Expected<T> &E) {
|
template <typename T> static void FailIfError(Expected<T> &E) {
|
||||||
FailIfError(E.takeError());
|
if (E)
|
||||||
|
return;
|
||||||
|
logAllUnhandledErrors(E.takeError(), errs(), "Error: ");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FailIfNotEmpty(const llvm::Twine &E) {
|
static void FailIfNotEmpty(const llvm::Twine &E) {
|
||||||
@ -422,8 +417,9 @@ static void getObjectCoveragePoints(const object::ObjectFile &O,
|
|||||||
static void
|
static void
|
||||||
visitObjectFiles(const object::Archive &A,
|
visitObjectFiles(const object::Archive &A,
|
||||||
function_ref<void(const object::ObjectFile &)> Fn) {
|
function_ref<void(const object::ObjectFile &)> Fn) {
|
||||||
Error Err;
|
for (auto &ErrorOrChild : A.children()) {
|
||||||
for (auto &C : A.children(Err)) {
|
FailIfError(ErrorOrChild);
|
||||||
|
const object::Archive::Child &C = *ErrorOrChild;
|
||||||
Expected<std::unique_ptr<object::Binary>> ChildOrErr = C.getAsBinary();
|
Expected<std::unique_ptr<object::Binary>> ChildOrErr = C.getAsBinary();
|
||||||
FailIfError(errorToErrorCode(ChildOrErr.takeError()));
|
FailIfError(errorToErrorCode(ChildOrErr.takeError()));
|
||||||
if (auto *O = dyn_cast<object::ObjectFile>(&*ChildOrErr.get()))
|
if (auto *O = dyn_cast<object::ObjectFile>(&*ChildOrErr.get()))
|
||||||
@ -431,7 +427,6 @@ visitObjectFiles(const object::Archive &A,
|
|||||||
else
|
else
|
||||||
FailIfError(object::object_error::invalid_file_type);
|
FailIfError(object::object_error::invalid_file_type);
|
||||||
}
|
}
|
||||||
FailIfError(std::move(Err));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user