[lld] r259597 - ELF: Make link() to take an output stream to which error messages are written.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 2 14:49:32 PST 2016


Author: ruiu
Date: Tue Feb  2 16:49:32 2016
New Revision: 259597

URL: http://llvm.org/viewvc/llvm-project?rev=259597&view=rev
Log:
ELF: Make link() to take an output stream to which error messages are written.

http://reviews.llvm.org/D16668

Modified:
    lld/trunk/ELF/Driver.cpp
    lld/trunk/ELF/Driver.h
    lld/trunk/ELF/Error.cpp
    lld/trunk/ELF/Error.h
    lld/trunk/include/lld/Driver/Driver.h
    lld/trunk/lib/Driver/UniversalDriver.cpp

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=259597&r1=259596&r2=259597&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Tue Feb  2 16:49:32 2016
@@ -29,8 +29,9 @@ using namespace lld::elf2;
 Configuration *elf2::Config;
 LinkerDriver *elf2::Driver;
 
-bool elf2::link(ArrayRef<const char *> Args) {
+bool elf2::link(ArrayRef<const char *> Args, raw_ostream &Error) {
   HasError = false;
+  ErrorOS = &Error;
   Configuration C;
   LinkerDriver D;
   Config = &C;

Modified: lld/trunk/ELF/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.h?rev=259597&r1=259596&r2=259597&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.h (original)
+++ lld/trunk/ELF/Driver.h Tue Feb  2 16:49:32 2016
@@ -14,6 +14,7 @@
 #include "lld/Core/LLVM.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/raw_ostream.h"
 
 namespace lld {
 namespace elf2 {
@@ -21,7 +22,7 @@ namespace elf2 {
 extern class LinkerDriver *Driver;
 
 // Entry point of the ELF linker. Returns true on success.
-bool link(ArrayRef<const char *> Args);
+bool link(ArrayRef<const char *> Args, llvm::raw_ostream &Error = llvm::errs());
 
 class LinkerDriver {
 public:

Modified: lld/trunk/ELF/Error.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.cpp?rev=259597&r1=259596&r2=259597&view=diff
==============================================================================
--- lld/trunk/ELF/Error.cpp (original)
+++ lld/trunk/ELF/Error.cpp Tue Feb  2 16:49:32 2016
@@ -16,11 +16,12 @@ namespace lld {
 namespace elf2 {
 
 bool HasError;
+llvm::raw_ostream *ErrorOS;
 
 void warning(const Twine &Msg) { llvm::errs() << Msg << "\n"; }
 
 void error(const Twine &Msg) {
-  llvm::errs() << Msg << "\n";
+  *ErrorOS << Msg << "\n";
   HasError = true;
 }
 

Modified: lld/trunk/ELF/Error.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Error.h?rev=259597&r1=259596&r2=259597&view=diff
==============================================================================
--- lld/trunk/ELF/Error.h (original)
+++ lld/trunk/ELF/Error.h Tue Feb  2 16:49:32 2016
@@ -12,10 +12,15 @@
 
 #include "lld/Core/LLVM.h"
 
+namespace llvm {
+class raw_ostream;
+}
+
 namespace lld {
 namespace elf2 {
 
 extern bool HasError;
+extern llvm::raw_ostream *ErrorOS;
 
 void warning(const Twine &Msg);
 

Modified: lld/trunk/include/lld/Driver/Driver.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/Driver/Driver.h?rev=259597&r1=259596&r2=259597&view=diff
==============================================================================
--- lld/trunk/include/lld/Driver/Driver.h (original)
+++ lld/trunk/include/lld/Driver/Driver.h Tue Feb  2 16:49:32 2016
@@ -125,7 +125,7 @@ void link(llvm::ArrayRef<const char *> a
 }
 
 namespace elf2 {
-bool link(llvm::ArrayRef<const char *> args);
+bool link(llvm::ArrayRef<const char *> args, raw_ostream &diag = llvm::errs());
 }
 
 /// Driver for lld unit tests

Modified: lld/trunk/lib/Driver/UniversalDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/UniversalDriver.cpp?rev=259597&r1=259596&r2=259597&view=diff
==============================================================================
--- lld/trunk/lib/Driver/UniversalDriver.cpp (original)
+++ lld/trunk/lib/Driver/UniversalDriver.cpp Tue Feb  2 16:49:32 2016
@@ -205,7 +205,7 @@ bool UniversalDriver::link(llvm::Mutable
   case Flavor::old_gnu_ld:
     return GnuLdDriver::linkELF(args, diagnostics);
   case Flavor::gnu_ld:
-    return elf2::link(args);
+    return elf2::link(args, diagnostics);
   case Flavor::darwin_ld:
     return DarwinLdDriver::linkMachO(args, diagnostics);
   case Flavor::win_link:




More information about the llvm-commits mailing list