diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:48:50 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:48:50 +0000 |
commit | 1c98619801a5705c688e683be3ef9d70169a0686 (patch) | |
tree | 8422105cd1a94c368315f2db16b9ac746cf7c000 /ELF/Error.cpp | |
parent | f4f3ce4613680903220815690ad79fc7ba0a2e26 (diff) |
Notes
Diffstat (limited to 'ELF/Error.cpp')
-rw-r--r-- | ELF/Error.cpp | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/ELF/Error.cpp b/ELF/Error.cpp index e0701f7f4cc6..59a49c17b97c 100644 --- a/ELF/Error.cpp +++ b/ELF/Error.cpp @@ -8,31 +8,58 @@ //===----------------------------------------------------------------------===// #include "Error.h" +#include "Config.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/Error.h" #include "llvm/Support/raw_ostream.h" +using namespace llvm; + namespace lld { -namespace elf2 { +namespace elf { + +bool HasError; +raw_ostream *ErrorOS; -void warning(const Twine &Msg) { llvm::errs() << Msg << "\n"; } +void log(const Twine &Msg) { + if (Config->Verbose) + outs() << Msg << "\n"; +} + +void warning(const Twine &Msg) { + if (Config->FatalWarnings) + error(Msg); + else + *ErrorOS << Msg << "\n"; +} void error(const Twine &Msg) { - llvm::errs() << Msg << "\n"; - exit(1); + *ErrorOS << Msg << "\n"; + HasError = true; } void error(std::error_code EC, const Twine &Prefix) { - if (!EC) - return; error(Prefix + ": " + EC.message()); } -void error(std::error_code EC) { - if (!EC) - return; - error(EC.message()); +void fatal(const Twine &Msg) { + *ErrorOS << Msg << "\n"; + exit(1); +} + +void fatal(const Twine &Msg, const Twine &Prefix) { + fatal(Prefix + ": " + Msg); +} + +void check(std::error_code EC) { + if (EC) + fatal(EC.message()); +} + +void check(Error Err) { + check(errorToErrorCode(std::move(Err))); } -} // namespace elf2 +} // namespace elf } // namespace lld |