[llvm] r254990 - [llvm-objdump/MachO] Don't cut'n'paste the same code over and over.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 7 18:45:59 PST 2015
Author: davide
Date: Mon Dec 7 20:45:59 2015
New Revision: 254990
URL: http://llvm.org/viewvc/llvm-project?rev=254990&view=rev
Log:
[llvm-objdump/MachO] Don't cut'n'paste the same code over and over.
Use the appropriate helper instead.
Modified:
llvm/trunk/tools/llvm-objdump/MachODump.cpp
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
llvm/trunk/tools/llvm-objdump/llvm-objdump.h
Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=254990&r1=254989&r2=254990&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Mon Dec 7 20:45:59 2015
@@ -1495,11 +1495,8 @@ void llvm::ParseInputMachO(StringRef Fil
printArchiveHeaders(A, !NonVerbose, ArchiveMemberOffsets);
for (Archive::child_iterator I = A->child_begin(), E = A->child_end();
I != E; ++I) {
- if (std::error_code EC = I->getError()) {
- errs() << "llvm-objdump: '" << Filename << "': " << EC.message()
- << ".\n";
- exit(1);
- }
+ if (std::error_code EC = I->getError())
+ report_error(Filename, EC);
auto &C = I->get();
ErrorOr<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
if (ChildOrErr.getError())
@@ -1549,11 +1546,8 @@ void llvm::ParseInputMachO(StringRef Fil
for (Archive::child_iterator AI = A->child_begin(),
AE = A->child_end();
AI != AE; ++AI) {
- if (std::error_code EC = AI->getError()) {
- errs() << "llvm-objdump: '" << Filename
- << "': " << EC.message() << ".\n";
- exit(1);
- }
+ if (std::error_code EC = AI->getError())
+ report_error(Filename, EC);
auto &C = AI->get();
ErrorOr<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
if (ChildOrErr.getError())
@@ -1597,11 +1591,8 @@ void llvm::ParseInputMachO(StringRef Fil
for (Archive::child_iterator AI = A->child_begin(),
AE = A->child_end();
AI != AE; ++AI) {
- if (std::error_code EC = AI->getError()) {
- errs() << "llvm-objdump: '" << Filename << "': " << EC.message()
- << ".\n";
- exit(1);
- }
+ if (std::error_code EC = AI->getError())
+ report_error(Filename, EC);
auto &C = AI->get();
ErrorOr<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
if (ChildOrErr.getError())
@@ -1639,11 +1630,8 @@ void llvm::ParseInputMachO(StringRef Fil
printArchiveHeaders(A.get(), !NonVerbose, ArchiveMemberOffsets);
for (Archive::child_iterator AI = A->child_begin(), AE = A->child_end();
AI != AE; ++AI) {
- if (std::error_code EC = AI->getError()) {
- errs() << "llvm-objdump: '" << Filename << "': " << EC.message()
- << ".\n";
- exit(1);
- }
+ if (std::error_code EC = AI->getError())
+ report_error(Filename, EC);
auto &C = AI->get();
ErrorOr<std::unique_ptr<Binary>> ChildOrErr = C.getAsBinary();
if (ChildOrErr.getError())
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=254990&r1=254989&r2=254990&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Mon Dec 7 20:45:59 2015
@@ -252,7 +252,7 @@ void llvm::error(std::error_code EC) {
exit(1);
}
-static void report_error(StringRef File, std::error_code EC) {
+void llvm::report_error(StringRef File, std::error_code EC) {
assert(EC);
errs() << ToolName << ": '" << File << "': " << EC.message() << ".\n";
exit(1);
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.h?rev=254990&r1=254989&r2=254990&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.h (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.h Mon Dec 7 20:45:59 2015
@@ -78,6 +78,7 @@ void PrintRelocations(const object::Obje
void PrintSectionHeaders(const object::ObjectFile *o);
void PrintSectionContents(const object::ObjectFile *o);
void PrintSymbolTable(const object::ObjectFile *o);
+void report_error(StringRef File, std::error_code EC);
} // end namespace llvm
More information about the llvm-commits
mailing list