This is an archive of the discontinued LLVM Phabricator instance.

Port the error functions from ELF to COFF.
ClosedPublic

Authored by rafael on Aug 5 2015, 4:08 PM.

Details

Reviewers
ruiu
Summary

This has a few advantages

  • Less C++ code (about 300 lines less).
  • Less machine code (about 14 KB of text on a linux x86_64 build).
  • More debugger friendly. Just set a breakpoint on the exit function and you get the complete lld stack trace of when the error was found.
  • It is a more robust API. The errors are handled early and we don't get a std::error_code hot potato being passed around.
  • In most cases the error function in a better position to print diagnostics (it has more context).

Diff Detail

Repository
rL LLVM

Event Timeline

rafael updated this revision to Diff 31413.Aug 5 2015, 4:08 PM
rafael retitled this revision from to Port the error functions from ELF to COFF..
rafael updated this object.
rafael added a reviewer: ruiu.
rafael set the repository for this revision to rL LLVM.
rafael added a subscriber: llvm-commits.
ruiu edited edge metadata.Aug 5 2015, 4:31 PM

Handling errors with "eist immediately when error" policy seems good to me, but it makes error codes defined in error.h useless since we no longer return errors as return values. Maybe we should remove them.

COFF/Driver.h
30–34

error() does not particularly belong to Driver, so piggy-backing it with Driver doesn't seem a good idea to me. I'd move it to Error.h.

rafael updated this revision to Diff 31448.Aug 6 2015, 7:42 AM
rafael edited edge metadata.

Move the error functions out of Driver.(h|cpp)

ruiu accepted this revision.Aug 6 2015, 7:44 AM
ruiu edited edge metadata.

LGTM

COFF/Error.cpp
28

Add a blank line.

COFF/Error.h
18–20

Add blank lines between definitions/declarations.

This revision is now accepted and ready to land.Aug 6 2015, 7:44 AM
Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in r244215.