[PATCH] D86330: Allow multiple calls to InitLLVM() (NFC)

Mehdi AMINI via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 20 21:31:46 PDT 2020


mehdi_amini created this revision.
mehdi_amini added a reviewer: MaskRay.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
mehdi_amini requested review of this revision.

In e99dee82b0, the "out_of_memory_new_handler" was changed to be
explicitly initialized instead of relying on a global static
constructor.
However before this change, install_out_of_memory_new_handler could be
called multiple times while it asserts right now.
We can be more tolerant to calling multiple time InitLLVM without
reintroducing a global constructor for this handler.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86330

Files:
  llvm/lib/Support/ErrorHandling.cpp


Index: llvm/lib/Support/ErrorHandling.cpp
===================================================================
--- llvm/lib/Support/ErrorHandling.cpp
+++ llvm/lib/Support/ErrorHandling.cpp
@@ -192,7 +192,8 @@
 void llvm::install_out_of_memory_new_handler() {
   std::new_handler old = std::set_new_handler(out_of_memory_new_handler);
   (void)old;
-  assert(old == nullptr && "new-handler already installed");
+  assert((old == nullptr || old == out_of_memory_new_handler) &&
+         "new-handler already installed");
 }
 #endif
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86330.286949.patch
Type: text/x-patch
Size: 532 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200821/ba45c50a/attachment-0001.bin>


More information about the llvm-commits mailing list