This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Move ELF.h to Expected<T>
ClosedPublic

Authored by davide on Nov 15 2016, 10:18 AM.

Details

Summary

The tests still need to be updated. Before doing that, I would like to get another pair of eyes on the new error messages, in order to avoid to change them many times. Other than that, the transition is complete.

Diff Detail

Event Timeline

davide updated this revision to Diff 78025.Nov 15 2016, 10:18 AM
davide retitled this revision from to [ELF] Move ELF.h to Expected<T>.
davide updated this object.
davide added reviewers: rafael, lhames, pcc.
davide added a reviewer: Bigcheese.
davide added a subscriber: llvm-commits.
rafael accepted this revision.Nov 15 2016, 2:35 PM
rafael edited edge metadata.

This enables quite a few followup cleanups, so LGTM with just a few nits.

include/llvm/Object/ELF.h
172

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.

387

You don't need this comment anymore.

tools/llvm-objdump/llvm-objdump.cpp
621

This is in tools, I wonder why it doesn't just fail fast. In any case, that is for another patch.

tools/llvm-readobj/ARMEHABIPrinter.h
354

Don't we have an error that takes an Error so that you don't have to call errorToErrorCode?

This revision is now accepted and ready to land.Nov 15 2016, 2:35 PM
Bigcheese accepted this revision.Nov 15 2016, 3:57 PM
Bigcheese edited edge metadata.

Looks fine with the following wording changes and what rafael requested.

include/llvm/Object/ELF.h
267

invalid section offset

414

invalid section offset

432

invalid sh_type for string table, expected SHT_STRTAB

494

invalid sh_type for symbol table, expected SHT_SYMTAB or SHT_DYNSYM

521

invalid string offset

davide added inline comments.Nov 15 2016, 7:51 PM
include/llvm/Object/ELF.h
172

I thought the same (about using parse_failed everywhere, but wanted to do in a follow-up). Anyway, it's a good idea so I did it now.

267

Thanks for auditing the message, Spency

387

Done.

tools/llvm-objdump/llvm-objdump.cpp
621

I agree. Not quite fond of llvm-objdump, I'll open a bug.

tools/llvm-readobj/ARMEHABIPrinter.h
354

Yes, we do. In fact, I used it 10 lines below, but I forgot here =)

davide closed this revision.Nov 15 2016, 9:24 PM

Committed upstream. I find amusing that I found a thread where we discussed this more than one year ago (I completely forgot about it) =)
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20150810/293003.html