This is an archive of the discontinued LLVM Phabricator instance.

[COFF] Migrate COFFObjectFile to Expected<T>
ClosedPublic

Authored by rnk on May 8 2020, 11:50 AM.

Details

Summary

I noticed that std::error_code() does one-time initialization. Avoid
that overhead with Expected<T> and llvm::Error. Also, it is consistent
with the virtual interface and ELF, and generally cleaner.

Diff Detail

Event Timeline

rnk created this revision.May 8 2020, 11:50 AM
rnk updated this revision to Diff 262931.May 8 2020, 12:26 PM
  • Also convert getSection, which is hot
MaskRay accepted this revision.May 8 2020, 12:35 PM
MaskRay added inline comments.
llvm/tools/obj2yaml/coff2yaml.cpp
142

In the binary utilities (e.g. obj2yaml), we tend to not capitalize error messages. I think the error message may be temporary, because we should propagate the error to the caller, instead of calling exit directly when something goes wrong.

This revision is now accepted and ready to land.May 8 2020, 12:35 PM
rnk marked an inline comment as done.May 8 2020, 2:01 PM
rnk added inline comments.
llvm/tools/obj2yaml/coff2yaml.cpp
142

I'll lower case it. But, seeing as this is tool code, should we really propagate the error to the caller? Shouldn't the tool just exit here?

This revision was automatically updated to reflect the committed changes.