[PATCH] D26681: [ELF] Move ELF.h to Expected<T>
Rafael Ávila de Espíndola via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 15 14:35:16 PST 2016
rafael accepted this revision.
rafael added a comment.
This revision is now accepted and ready to land.
This enables quite a few followup cleanups, so LGTM with just a few nits.
================
Comment at: include/llvm/Object/ELF.h:172
+ return make_error<StringError>("invalid section index",
+ object_error::invalid_section_index);
return &Sections[Index];
----------------
At some point this should all be inconvertibleErrorCode. For now, can you always use object_error::parse_failed? With the string we don't need the various enums.
How about for now just adding a helper function:
static StringError createError(StringRef Err) {
return make_error<StringError>(Err, object_error::parse_failed);
}
That way we only have to update one place in a followup patch.
================
Comment at: include/llvm/Object/ELF.h:387
// Section table goes past end of file!
if (SectionTableOffset + SectionTableSize > FileSize)
----------------
You don't need this comment anymore.
================
Comment at: tools/llvm-objdump/llvm-objdump.cpp:621
SymTab->sh_type == ELF::SHT_DYNSYM);
- ErrorOr<const Elf_Shdr *> StrTabSec = EF.getSection(SymTab->sh_link);
- if (std::error_code EC = StrTabSec.getError())
- return EC;
- ErrorOr<StringRef> StrTabOrErr = EF.getStringTable(*StrTabSec);
- if (std::error_code EC = StrTabOrErr.getError())
- return EC;
+ auto StrTabSec = EF.getSection(SymTab->sh_link);
+ if (!StrTabSec)
----------------
This is in tools, I wonder why it doesn't just fail fast. In any case, that is for another patch.
================
Comment at: tools/llvm-readobj/ARMEHABIPrinter.h:354
+ if (!StrTableOrErr)
+ error(errorToErrorCode(StrTableOrErr.takeError()));
StringRef StrTable = *StrTableOrErr;
----------------
Don't we have an error that takes an Error so that you don't have to call errorToErrorCode?
https://reviews.llvm.org/D26681
More information about the llvm-commits
mailing list