[PATCH] D16641: ELF: Rename error -> fatal and redefine error as a non-noreturn function.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 27 11:12:27 PST 2016


ruiu created this revision.
ruiu added a reviewer: rafael.
ruiu added a subscriber: llvm-commits.

In many situations, we don't want to exit at the first error even in the
process model. For example, it is better to report all undefined symbols
rather than reporting the first one that the linker picked up randomly.

In order to handle such errors, we don't need to wrap everything with
ErrorOr (thanks for David Blaikie for pointing this out!) Instead, we
can set a flag to record the fact that we found an error and keep it
going until it reaches a reasonable checkpoint.

This idea should be applicable to other places. For example, we can
ignore broken relocations and check for errors after visiting all relocs.

In this patch, I rename error to fatal, and introduce another version of
error which do not call exit. That function instead set HasError to true.
Once HasError becomes true, it stays true, so that we know that there
was an error if it is true.

I think introducing a non-noreturn error reporting function is by itself
a good idea, and it looks to me that this also provides a gradual path
towards lld-as-a-library (or at least embed-lld-to-your-program) without
sacrificing code readability with lots of ErrorOr's.

http://reviews.llvm.org/D16641

Files:
  ELF/Driver.cpp
  ELF/Driver.h
  ELF/DriverUtils.cpp
  ELF/Error.cpp
  ELF/Error.h
  ELF/InputFiles.cpp
  ELF/InputSection.cpp
  ELF/LinkerScript.cpp
  ELF/OutputSections.cpp
  ELF/SymbolTable.cpp
  ELF/Target.cpp
  ELF/Writer.cpp
  include/lld/Driver/Driver.h
  lib/Driver/UniversalDriver.cpp
  test/ELF/undef.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16641.46158.patch
Type: text/x-patch
Size: 35696 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160127/b1c11457/attachment-0001.bin>


More information about the llvm-commits mailing list