summaryrefslogtreecommitdiff
path: root/lib/VMCore/LeakDetector.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-07-15 01:29:12 +0000
committerChris Lattner <sabre@nondot.org>2004-07-15 01:29:12 +0000
commitce36d55cf8d3239942e0e9c426c835f0c33a11e6 (patch)
tree12f0e38b5d9bbd9e755f4f77a97e82adabd72a88 /lib/VMCore/LeakDetector.cpp
parentdd68469382cafff2051289707ea2d3e0d26919b1 (diff)
downloadllvm-ce36d55cf8d3239942e0e9c426c835f0c33a11e6.tar.gz
llvm-ce36d55cf8d3239942e0e9c426c835f0c33a11e6.tar.bz2
llvm-ce36d55cf8d3239942e0e9c426c835f0c33a11e6.tar.xz
Bug fixes for PR341
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14838 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/LeakDetector.cpp')
-rw-r--r--lib/VMCore/LeakDetector.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/VMCore/LeakDetector.cpp b/lib/VMCore/LeakDetector.cpp
index 919f7a9c21..dbdb7dd70f 100644
--- a/lib/VMCore/LeakDetector.cpp
+++ b/lib/VMCore/LeakDetector.cpp
@@ -18,6 +18,16 @@
using namespace llvm;
namespace {
+ template <class T>
+ struct PrinterTrait {
+ static void print(const T* P) { std::cerr << P; }
+ };
+
+ template<>
+ struct PrinterTrait<Value> {
+ static void print(const Value* P) { std::cerr << *P; }
+ };
+
template <typename T>
struct LeakDetectorImpl {
LeakDetectorImpl(const char* const name) : Cache(0), Name(name) { }
@@ -39,7 +49,7 @@ namespace {
if (o == Cache)
Cache = 0; // Cache hit
else
- Ts.erase(o);
+ Ts.erase(o);
}
bool hasGarbage(const std::string& Message) {
@@ -49,9 +59,13 @@ namespace {
if (!Ts.empty()) {
std::cerr
- << "Leaked " << Name << " objects found: " << Message << ":\n\t";
- std::copy(Ts.begin(), Ts.end(),
- std::ostream_iterator<const T*>(std::cerr, " "));
+ << "Leaked " << Name << " objects found: " << Message << ":\n";
+ for (typename std::set<const T*>::iterator I = Ts.begin(),
+ E = Ts.end(); I != E; ++I) {
+ std::cerr << "\t";
+ PrinterTrait<T>::print(*I);
+ std::cerr << "\n";
+ }
std::cerr << '\n';
// Clear out results so we don't get duplicate warnings on