The COFF linker and the ELF linker have long had similar but separate
Error.h and Error.cpp files to implement error handling. This change
introduces new error handling code in Common/ErrorHandler.h, changes the
COFF and ELF linkers to use it, and removes the old, separate
implementations.
Details
Diff Detail
- Build Status
Buildable 11448 Build 11448: arc lint + arc unit
Event Timeline
Summary of the changes:
- Instead of #include "Error.h", #include "lld/Common/ErrorHandler.h".
- Instead of ColorDiagnostics, ErrorLimit, and FatalWarnings being properties of the Config object, they are now set on the ErrorHandler object.
- Removed the fatal() variants that take Error or std::error_code. This was previously done for ELF, so I've done it here for COFF too.
- Instead of ErrorCount as a global variable, the value is now retrieved by calling the errorCount() function.
I chose ErrorHandler instead of Error as the name of the header file, because there is already an Error.h in lld/Core, and also in LLVM.
lld/include/lld/Common/ErrorHandler.h | ||
---|---|---|
50–54 | The default ctor delegates to it. I suppose I could just only have a default ctor. |
lld/include/lld/Common/ErrorHandler.h | ||
---|---|---|
50–54 | Yeah, and initializing a member with an ELF-ish default value seems a bit odd if you move this file to Common directory. |
lld/include/lld/Common/ErrorHandler.h | ||
---|---|---|
50–54 | Yeah. The thinking is basically that this is the common case, with the Windows variant being the odd one out, but I'm happy to do it a different way if you have suggestions. I wasn't able to think of a way I really like better. |
- Removed ErrorHandler parameter to handleColorDiagnostics.
- Cut number of constructors for ErrorHandler down to one.
- Initialize all fields in their definition instead of in the contructor.
- Replaced default ErrorLimitExceededMsg with something more generic.
- clang-format
clang-format?