diff options
author | Brian Gesiak <modocache@gmail.com> | 2018-06-12 02:34:04 +0000 |
---|---|---|
committer | Brian Gesiak <modocache@gmail.com> | 2018-06-12 02:34:04 +0000 |
commit | b9f7f4b87c574cfe477fa480394280e86b0e3c38 (patch) | |
tree | 90897cf1facaacc8b068ef481876cbcc43caf13b /lld/include | |
parent | e6b2e06f289ba659cfad2be4cbd7b9acc4f5d641 (diff) | |
download | bcm5719-llvm-b9f7f4b87c574cfe477fa480394280e86b0e3c38.tar.gz bcm5719-llvm-b9f7f4b87c574cfe477fa480394280e86b0e3c38.zip |
[Darwin] Use errorHandler from liblldCommon
Summary:
Error handling in liblldCore and the Darwin toolchain prints to an
output stream. A TODO in the project explained that a diagnostics
interface resembling Clang's should be added.
For now, the simple diagnostics interface defined in liblldCommon seems
like an improvement. It prints colors when they're available, uses locks
for thread-safety, and abstracts away the `"error: "` and newline
literal strings that litter the Darwin toolchain code.
To use the liblldCommon error handler, a link dependency is added to
the liblldDriver library.
Test Plan:
1. check-lld
2. Invoke `ld64.lld -r` in a terminal that supports color output.
Confirm that "ld64.lld: error: -arch not specified and could not be inferred"
is output, and that the "error:" is colored red!
Reviewers: ruiu, smeenai
Reviewed By: ruiu
Subscribers: mgorny, llvm-commits
Differential Revision: https://reviews.llvm.org/D47998
llvm-svn: 334466
Diffstat (limited to 'lld/include')
-rw-r--r-- | lld/include/lld/Common/Driver.h | 2 | ||||
-rw-r--r-- | lld/include/lld/Core/LinkingContext.h | 7 | ||||
-rw-r--r-- | lld/include/lld/Core/TODO.txt | 3 | ||||
-rw-r--r-- | lld/include/lld/ReaderWriter/MachOLinkingContext.h | 2 |
4 files changed, 5 insertions, 9 deletions
diff --git a/lld/include/lld/Common/Driver.h b/lld/include/lld/Common/Driver.h index 15ec3cd44cb..f6d92933af6 100644 --- a/lld/include/lld/Common/Driver.h +++ b/lld/include/lld/Common/Driver.h @@ -30,7 +30,7 @@ bool link(llvm::ArrayRef<const char *> Args, bool CanExitEarly, } namespace mach_o { -bool link(llvm::ArrayRef<const char *> Args, +bool link(llvm::ArrayRef<const char *> Args, bool CanExitEarly, llvm::raw_ostream &Diag = llvm::errs()); } diff --git a/lld/include/lld/Core/LinkingContext.h b/lld/include/lld/Core/LinkingContext.h index 6dffdd4efe7..52ab1a2480e 100644 --- a/lld/include/lld/Core/LinkingContext.h +++ b/lld/include/lld/Core/LinkingContext.h @@ -16,7 +16,6 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/Error.h" -#include "llvm/Support/raw_ostream.h" #include <cassert> #include <cstdint> #include <memory> @@ -167,10 +166,10 @@ public: /// After all set* methods are called, the Driver calls this method /// to validate that there are no missing options or invalid combinations /// of options. If there is a problem, a description of the problem - /// is written to the supplied stream. + /// is written to the global error handler. /// /// \returns true if there is an error with the current settings. - bool validate(raw_ostream &diagnostics); + bool validate(); /// Formats symbol name for use in error messages. virtual std::string demangle(StringRef symbolName) const = 0; @@ -250,7 +249,7 @@ protected: private: /// Validate the subclass bits. Only called by validate. - virtual bool validateImpl(raw_ostream &diagnostics) = 0; + virtual bool validateImpl() = 0; }; } // end namespace lld diff --git a/lld/include/lld/Core/TODO.txt b/lld/include/lld/Core/TODO.txt index 8b523045de7..2aa61ff8612 100644 --- a/lld/include/lld/Core/TODO.txt +++ b/lld/include/lld/Core/TODO.txt @@ -6,9 +6,6 @@ include/lld/Core abstraction only works for returning low level OS errors. It does not work for describing formatting issues. -* We need to design a diagnostics interface. It would be nice to share code - with Clang_ where possible. - * We need to add more attributes to File. In particular, we need cpu and OS information (like target triples). We should also provide explicit support for `LLVM IR module flags metadata`__. diff --git a/lld/include/lld/ReaderWriter/MachOLinkingContext.h b/lld/include/lld/ReaderWriter/MachOLinkingContext.h index 5f9588d7208..fde65880c3e 100644 --- a/lld/include/lld/ReaderWriter/MachOLinkingContext.h +++ b/lld/include/lld/ReaderWriter/MachOLinkingContext.h @@ -89,7 +89,7 @@ public: bool exportDynamicSymbols); void addPasses(PassManager &pm) override; - bool validateImpl(raw_ostream &diagnostics) override; + bool validateImpl() override; std::string demangle(StringRef symbolName) const override; void createImplicitFiles(std::vector<std::unique_ptr<File>> &) override; |