Start using make() in COFF (with a smaller change.)
authorRui Ueyama <ruiu@google.com>
Thu, 8 Dec 2016 19:10:28 +0000 (19:10 +0000)
committerRui Ueyama <ruiu@google.com>
Thu, 8 Dec 2016 19:10:28 +0000 (19:10 +0000)
llvm-svn: 289089

lld/COFF/Driver.cpp
lld/COFF/Error.cpp

index fbdb2d0..8719c0f 100644 (file)
@@ -15,6 +15,7 @@
 #include "Symbols.h"
 #include "Writer.h"
 #include "lld/Driver/Driver.h"
+#include "lld/Support/Memory.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/LibDriver/LibDriver.h"
@@ -43,10 +44,8 @@ Configuration *Config;
 LinkerDriver *Driver;
 
 bool link(llvm::ArrayRef<const char *> Args) {
-  Configuration C;
-  LinkerDriver D;
-  Config = &C;
-  Driver = &D;
+  Config = make<Configuration>();
+  Driver = make<LinkerDriver>();
   Driver->link(Args);
   return true;
 }
index 80ca842..b2bd557 100644 (file)
 #include "llvm/Support/Process.h"
 #include "llvm/Support/raw_ostream.h"
 
+#if !defined(_MSC_VER) && !defined(__MINGW32__)
+#include <unistd.h>
+#endif
+
 using namespace llvm;
 
 namespace lld {
@@ -27,9 +31,11 @@ void fatal(const Twine &Msg) {
   } else {
     errs() << "error: ";
   }
-
   errs() << Msg << "\n";
-  exit(1);
+
+  outs().flush();
+  errs().flush();
+  _exit(1);
 }
 
 void fatal(std::error_code EC, const Twine &Msg) {