namespace llvm {
-void reportError(Twine Msg) {
+LLVM_ATTRIBUTE_NORETURN void reportError(Twine Msg) {
outs() << "\nError reading file: " << Msg << ".\n";
outs().flush();
exit(1);
static void dumpObject(const ObjectFile *Obj) {
StreamWriter Writer(outs());
std::unique_ptr<ObjDumper> Dumper;
- if (std::error_code EC = createDumper(Obj, Writer, Dumper)) {
+ if (std::error_code EC = createDumper(Obj, Writer, Dumper))
reportError(Obj->getFileName(), EC);
- return;
- }
outs() << '\n';
outs() << "File: " << Obj->getFileName() << "\n";
/// @brief Dumps each object file in \a Arc;
static void dumpArchive(const Archive *Arc) {
- for (const auto &Child : Arc->children()) {
+ for (auto &ErrorOrChild : Arc->children()) {
+ if (std::error_code EC = ErrorOrChild.getError())
+ reportError(Arc->getFileName(), EC.message());
+ const auto &Child = *ErrorOrChild;
ErrorOr<std::unique_ptr<Binary>> ChildOrErr = Child.getAsBinary();
if (std::error_code EC = ChildOrErr.getError()) {
// Ignore non-object files.
// Attempt to open the binary.
ErrorOr<OwningBinary<Binary>> BinaryOrErr = createBinary(File);
- if (std::error_code EC = BinaryOrErr.getError()) {
+ if (std::error_code EC = BinaryOrErr.getError())
reportError(File, EC);
- return;
- }
Binary &Binary = *BinaryOrErr.get().getBinary();
if (Archive *Arc = dyn_cast<Archive>(&Binary))