From 8709927af8095c58cf2147d6d83fed9b7821a508 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 15 Feb 2004 23:33:48 +0000 Subject: Fix a bug in the recent rewrite of the leakdetector that caused all of the nightly tests to be really messed up. The problem was that the new leakdetector was depending on undefined behavior: the order of destruction of static objects. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11488 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/LeakDetector.cpp | 17 ++++++++++------- lib/VMCore/LeakDetector.cpp | 17 ++++++++++------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/Support/LeakDetector.cpp b/lib/Support/LeakDetector.cpp index a6d96df..d4e829f 100644 --- a/lib/Support/LeakDetector.cpp +++ b/lib/Support/LeakDetector.cpp @@ -17,7 +17,6 @@ using namespace llvm; namespace { - template struct LeakDetectorImpl { LeakDetectorImpl(const char* const name) : Cache(0), Name(name) { } @@ -64,21 +63,25 @@ namespace { private: std::set Ts; - const T* Cache; - const char* const Name; + const T* Cache; + const char* const Name; }; typedef LeakDetectorImpl Objects; typedef LeakDetectorImpl LLVMObjects; Objects& getObjects() { - static Objects o("GENERIC"); - return o; + static Objects *o = 0; + if (o == 0) + o = new Objects("GENERIC"); + return *o; } LLVMObjects& getLLVMObjects() { - static LLVMObjects o("LLVM"); - return o; + static LLVMObjects *o = 0; + if (o == 0) + o = new LLVMObjects("LLVM"); + return *o; } } diff --git a/lib/VMCore/LeakDetector.cpp b/lib/VMCore/LeakDetector.cpp index a6d96df..d4e829f 100644 --- a/lib/VMCore/LeakDetector.cpp +++ b/lib/VMCore/LeakDetector.cpp @@ -17,7 +17,6 @@ using namespace llvm; namespace { - template struct LeakDetectorImpl { LeakDetectorImpl(const char* const name) : Cache(0), Name(name) { } @@ -64,21 +63,25 @@ namespace { private: std::set Ts; - const T* Cache; - const char* const Name; + const T* Cache; + const char* const Name; }; typedef LeakDetectorImpl Objects; typedef LeakDetectorImpl LLVMObjects; Objects& getObjects() { - static Objects o("GENERIC"); - return o; + static Objects *o = 0; + if (o == 0) + o = new Objects("GENERIC"); + return *o; } LLVMObjects& getLLVMObjects() { - static LLVMObjects o("LLVM"); - return o; + static LLVMObjects *o = 0; + if (o == 0) + o = new LLVMObjects("LLVM"); + return *o; } } -- cgit v1.1