summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp
diff options
context:
space:
mode:
authorKevin Enderby <enderby@apple.com>2016-04-20 21:24:34 +0000
committerKevin Enderby <enderby@apple.com>2016-04-20 21:24:34 +0000
commit81e8b7d9496688476c6bb601cce2575c3f2811ed (patch)
treedf826623cc6e8219f57929601c58be265328102f /llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp
parent64d4e2bc0d1e3eaec2f20a198b6362287031b931 (diff)
downloadbcm5719-llvm-81e8b7d9496688476c6bb601cce2575c3f2811ed.tar.gz
bcm5719-llvm-81e8b7d9496688476c6bb601cce2575c3f2811ed.zip
Thread Expected<...> up from libObject’s getName() for symbols to allow llvm-objdump to produce a good error message.
Produce another specific error message for a malformed Mach-O file when a symbol’s string index is past the end of the string table. The existing test case in test/Object/macho-invalid.test for macho-invalid-symbol-name-past-eof now reports the error with the message indicating that a symbol at a specific index has a bad sting index and that bad string index value. Again converting interfaces to Expected<> from ErrorOr<> does involve touching a number of places. Where the existing code reported the error with a string message or an error code it was converted to do the same. There is some code for this that could be factored into a routine but I would like to leave that for the code owners post-commit to do as they want for handling an llvm::Error. An example of how this could be done is shown in the diff in lib/ExecutionEngine/RuntimeDyld/RuntimeDyldImpl.h which had a Check() routine already for std::error_code so I added one like it for llvm::Error . Also there some were bugs in the existing code that did not deal with the old ErrorOr<> return values.  So now with Expected<> since they must be checked and the error handled, I added a TODO and a comment: “// TODO: Actually report errors helpfully” and a call something like consumeError(NameOrErr.takeError()) so the buggy code will not crash since needed to deal with the Error. Note there fixes needed to lld that goes along with this that I will commit right after this. So expect lld not to built after this commit and before the next one. llvm-svn: 266919
Diffstat (limited to 'llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp')
-rw-r--r--llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp b/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp
index 5048987865f..dc1cc23c232 100644
--- a/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp
+++ b/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp
@@ -79,8 +79,8 @@ static void collectRelocatedSymbols(const ObjectFile *Obj,
const object::symbol_iterator RelocSymI = Reloc.getSymbol();
if (RelocSymI == Obj->symbol_end())
continue;
- ErrorOr<StringRef> RelocSymName = RelocSymI->getName();
- error(RelocSymName.getError());
+ Expected<StringRef> RelocSymName = RelocSymI->getName();
+ error(errorToErrorCode(RelocSymName.takeError()));
uint64_t Offset = Reloc.getOffset();
if (Offset >= SymOffset && Offset < SymEnd) {
*I = *RelocSymName;
@@ -101,8 +101,8 @@ static void collectRelocationOffsets(
const object::symbol_iterator RelocSymI = Reloc.getSymbol();
if (RelocSymI == Obj->symbol_end())
continue;
- ErrorOr<StringRef> RelocSymName = RelocSymI->getName();
- error(RelocSymName.getError());
+ Expected<StringRef> RelocSymName = RelocSymI->getName();
+ error(errorToErrorCode(RelocSymName.takeError()));
uint64_t Offset = Reloc.getOffset();
if (Offset >= SymOffset && Offset < SymEnd)
Collection[std::make_pair(SymName, Offset - SymOffset)] = *RelocSymName;
@@ -175,8 +175,8 @@ static void dumpCXXData(const ObjectFile *Obj) {
for (auto &P : SymAddr) {
object::SymbolRef Sym = P.first;
uint64_t SymSize = P.second;
- ErrorOr<StringRef> SymNameOrErr = Sym.getName();
- error(SymNameOrErr.getError());
+ Expected<StringRef> SymNameOrErr = Sym.getName();
+ error(errorToErrorCode(SymNameOrErr.takeError()));
StringRef SymName = *SymNameOrErr;
ErrorOr<object::section_iterator> SecIOrErr = Sym.getSection();
error(SecIOrErr.getError());
OpenPOWER on IntegriCloud