[llvm] 927da43 - Allow multiple calls to InitLLVM() (NFC)

Mehdi Amini via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 20 23:13:17 PDT 2020


Author: Mehdi Amini
Date: 2020-08-21T06:13:00Z
New Revision: 927da43ade12fffc8077c248e0243711071b2094

URL: https://github.com/llvm/llvm-project/commit/927da43ade12fffc8077c248e0243711071b2094
DIFF: https://github.com/llvm/llvm-project/commit/927da43ade12fffc8077c248e0243711071b2094.diff

LOG: Allow multiple calls to InitLLVM() (NFC)

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.

Differential Revision: https://reviews.llvm.org/D86330

Added: 
    

Modified: 
    llvm/lib/Support/ErrorHandling.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Support/ErrorHandling.cpp b/llvm/lib/Support/ErrorHandling.cpp
index f70a6921a41a..e962657730fe 100644
--- a/llvm/lib/Support/ErrorHandling.cpp
+++ b/llvm/lib/Support/ErrorHandling.cpp
@@ -192,7 +192,8 @@ static void out_of_memory_new_handler() {
 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
 


        


More information about the llvm-commits mailing list