[PATCH] D64505: [Support] Move the static initializer install_out_memory_new_handler to InitLLVM

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 10 09:10:52 PDT 2019


MaskRay created this revision.
MaskRay added reviewers: rnk, sepavloff.
Herald added subscribers: llvm-commits, kristina.
Herald added a project: LLVM.

An application linking against LLVMSupport should not get the gratuitous
set::std_new_handler call.


Repository:
  rL LLVM

https://reviews.llvm.org/D64505

Files:
  lib/Support/ErrorHandling.cpp
  lib/Support/InitLLVM.cpp


Index: lib/Support/InitLLVM.cpp
===================================================================
--- lib/Support/InitLLVM.cpp
+++ lib/Support/InitLLVM.cpp
@@ -23,6 +23,7 @@
 
 InitLLVM::InitLLVM(int &Argc, const char **&Argv) : StackPrinter(Argc, Argv) {
   sys::PrintStackTraceOnErrorSignal(Argv[0]);
+  install_out_of_memory_new_handler();
 
 #ifdef _WIN32
   // We use UTF-8 as the internal character encoding. On Windows,
Index: lib/Support/ErrorHandling.cpp
===================================================================
--- lib/Support/ErrorHandling.cpp
+++ lib/Support/ErrorHandling.cpp
@@ -196,15 +196,6 @@
     out_of_memory_new_handler_installed = true;
   }
 }
-
-// Static object that causes installation of 'out_of_memory_new_handler' before
-// execution of 'main'.
-static class NewHandlerInstaller {
-public:
-  NewHandlerInstaller() {
-    install_out_of_memory_new_handler();
-  }
-} new_handler_installer;
 #endif
 
 void llvm::llvm_unreachable_internal(const char *msg, const char *file,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64505.208981.patch
Type: text/x-patch
Size: 1016 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190710/f2943a81/attachment.bin>


More information about the llvm-commits mailing list