[llvm-commits] [llvm] r171301 - /llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
Rafael Espindola
rafael.espindola at gmail.com
Mon Dec 31 07:45:31 PST 2012
Author: rafael
Date: Mon Dec 31 09:45:31 2012
New Revision: 171301
URL: http://llvm.org/viewvc/llvm-project?rev=171301&view=rev
Log:
Check for errors. Extracted from a patch by Sami Liedes.
Modified:
llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
Modified: llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp?rev=171301&r1=171300&r2=171301&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/llvm-readobj.cpp Mon Dec 31 09:45:31 2012
@@ -69,6 +69,11 @@
return result;
}
+static void checkError(error_code ec, const char *msg) {
+ if (ec)
+ report_fatal_error(std::string(msg) + ": " + ec.message());
+}
+
static void
dumpSymbol(const SymbolRef &Sym, const ObjectFile *obj, bool IsDynamic) {
StringRef Name;
@@ -77,12 +82,13 @@
uint64_t Address;
uint64_t Size;
uint64_t FileOffset;
- Sym.getName(Name);
- Sym.getAddress(Address);
- Sym.getSize(Size);
- Sym.getFileOffset(FileOffset);
- Sym.getType(Type);
- Sym.getFlags(Flags);
+ checkError(Sym.getName(Name), "SymbolRef.getName() failed");
+ checkError(Sym.getAddress(Address), "SymbolRef.getAddress() failed");
+ checkError(Sym.getSize(Size), "SymbolRef.getSize() failed");
+ checkError(Sym.getFileOffset(FileOffset),
+ "SymbolRef.getFileOffset() failed");
+ checkError(Sym.getType(Type), "SymbolRef.getType() failed");
+ checkError(Sym.getFlags(Flags), "SymbolRef.getFlags() failed");
std::string FullName = Name;
// If this is a dynamic symbol from an ELF object, append
More information about the llvm-commits
mailing list