summaryrefslogtreecommitdiff
path: root/ELF/Error.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ELF/Error.cpp')
-rw-r--r--ELF/Error.cpp49
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