Page MenuHomePhabricator

[COFF] Migrate COFFObjectFile to Expected<T>
ClosedPublic

Authored by rnk on Fri, May 8, 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.Fri, May 8, 11:50 AM
Herald added a reviewer: MaskRay. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
rnk updated this revision to Diff 262931.Fri, May 8, 12:26 PM
  • Also convert getSection, which is hot
MaskRay accepted this revision.Fri, May 8, 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.Fri, May 8, 12:35 PM
rnk marked an inline comment as done.Fri, May 8, 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.