[PATCH] D16668: ELF: Remove fatal() and add the second parameter to the linker's entry point.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 1 16:15:19 PST 2016


ruiu updated this revision to Diff 46590.
ruiu added a comment.

- Adjust the scope of this patch.


http://reviews.llvm.org/D16668

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

Index: lib/Driver/UniversalDriver.cpp
===================================================================
--- lib/Driver/UniversalDriver.cpp
+++ lib/Driver/UniversalDriver.cpp
@@ -205,7 +205,7 @@
   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:
Index: include/lld/Driver/Driver.h
===================================================================
--- include/lld/Driver/Driver.h
+++ include/lld/Driver/Driver.h
@@ -125,7 +125,7 @@
 }
 
 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
Index: ELF/Error.h
===================================================================
--- ELF/Error.h
+++ ELF/Error.h
@@ -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);
 
Index: ELF/Error.cpp
===================================================================
--- ELF/Error.cpp
+++ ELF/Error.cpp
@@ -16,11 +16,12 @@
 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;
 }
 
Index: ELF/Driver.h
===================================================================
--- ELF/Driver.h
+++ ELF/Driver.h
@@ -14,14 +14,15 @@
 #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 {
 
 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:
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -29,8 +29,9 @@
 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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D16668.46590.patch
Type: text/x-patch
Size: 2591 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160202/d68bb4b9/attachment.bin>


More information about the llvm-commits mailing list