[llvm-commits] CVS: llvm/lib/Support/LeakDetector.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Feb 15 17:34:01 PST 2004
Changes in directory llvm/lib/Support:
LeakDetector.cpp updated: 1.7 -> 1.8
---
Log message:
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.
---
Diffs of the changes: (+10 -7)
Index: llvm/lib/Support/LeakDetector.cpp
diff -u llvm/lib/Support/LeakDetector.cpp:1.7 llvm/lib/Support/LeakDetector.cpp:1.8
--- llvm/lib/Support/LeakDetector.cpp:1.7 Sat Feb 14 17:33:39 2004
+++ llvm/lib/Support/LeakDetector.cpp Sun Feb 15 17:33:48 2004
@@ -17,7 +17,6 @@
using namespace llvm;
namespace {
-
template <typename T>
struct LeakDetectorImpl {
LeakDetectorImpl(const char* const name) : Cache(0), Name(name) { }
@@ -64,21 +63,25 @@
private:
std::set<const T*> Ts;
- const T* Cache;
- const char* const Name;
+ const T* Cache;
+ const char* const Name;
};
typedef LeakDetectorImpl<void> Objects;
typedef LeakDetectorImpl<Value> 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;
}
}
More information about the llvm-commits
mailing list