From ce36d55cf8d3239942e0e9c426c835f0c33a11e6 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 15 Jul 2004 01:29:12 +0000 Subject: [PATCH] Bug fixes for PR341 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14838 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ConstantRange.cpp | 2 +- lib/Support/ConstantRange.cpp | 2 +- lib/Support/LeakDetector.cpp | 22 ++++++++++++++++++---- lib/VMCore/ConstantRange.cpp | 2 +- lib/VMCore/LeakDetector.cpp | 22 ++++++++++++++++++---- 5 files changed, 39 insertions(+), 11 deletions(-) diff --git a/lib/Analysis/ConstantRange.cpp b/lib/Analysis/ConstantRange.cpp index 580ca01ac39..3b91c5bc7a0 100644 --- a/lib/Analysis/ConstantRange.cpp +++ b/lib/Analysis/ConstantRange.cpp @@ -322,7 +322,7 @@ ConstantRange ConstantRange::truncate(const Type *Ty) const { /// print - Print out the bounds to a stream... /// void ConstantRange::print(std::ostream &OS) const { - OS << "[" << Lower << "," << Upper << " )"; + OS << "[" << *Lower << "," << *Upper << " )"; } /// dump - Allow printing from a debugger easily... diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp index 580ca01ac39..3b91c5bc7a0 100644 --- a/lib/Support/ConstantRange.cpp +++ b/lib/Support/ConstantRange.cpp @@ -322,7 +322,7 @@ ConstantRange ConstantRange::truncate(const Type *Ty) const { /// print - Print out the bounds to a stream... /// void ConstantRange::print(std::ostream &OS) const { - OS << "[" << Lower << "," << Upper << " )"; + OS << "[" << *Lower << "," << *Upper << " )"; } /// dump - Allow printing from a debugger easily... diff --git a/lib/Support/LeakDetector.cpp b/lib/Support/LeakDetector.cpp index 919f7a9c213..dbdb7dd70f2 100644 --- a/lib/Support/LeakDetector.cpp +++ b/lib/Support/LeakDetector.cpp @@ -18,6 +18,16 @@ using namespace llvm; namespace { + template + struct PrinterTrait { + static void print(const T* P) { std::cerr << P; } + }; + + template<> + struct PrinterTrait { + static void print(const Value* P) { std::cerr << *P; } + }; + template 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(std::cerr, " ")); + << "Leaked " << Name << " objects found: " << Message << ":\n"; + for (typename std::set::iterator I = Ts.begin(), + E = Ts.end(); I != E; ++I) { + std::cerr << "\t"; + PrinterTrait::print(*I); + std::cerr << "\n"; + } std::cerr << '\n'; // Clear out results so we don't get duplicate warnings on diff --git a/lib/VMCore/ConstantRange.cpp b/lib/VMCore/ConstantRange.cpp index 580ca01ac39..3b91c5bc7a0 100644 --- a/lib/VMCore/ConstantRange.cpp +++ b/lib/VMCore/ConstantRange.cpp @@ -322,7 +322,7 @@ ConstantRange ConstantRange::truncate(const Type *Ty) const { /// print - Print out the bounds to a stream... /// void ConstantRange::print(std::ostream &OS) const { - OS << "[" << Lower << "," << Upper << " )"; + OS << "[" << *Lower << "," << *Upper << " )"; } /// dump - Allow printing from a debugger easily... diff --git a/lib/VMCore/LeakDetector.cpp b/lib/VMCore/LeakDetector.cpp index 919f7a9c213..dbdb7dd70f2 100644 --- a/lib/VMCore/LeakDetector.cpp +++ b/lib/VMCore/LeakDetector.cpp @@ -18,6 +18,16 @@ using namespace llvm; namespace { + template + struct PrinterTrait { + static void print(const T* P) { std::cerr << P; } + }; + + template<> + struct PrinterTrait { + static void print(const Value* P) { std::cerr << *P; } + }; + template 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(std::cerr, " ")); + << "Leaked " << Name << " objects found: " << Message << ":\n"; + for (typename std::set::iterator I = Ts.begin(), + E = Ts.end(); I != E; ++I) { + std::cerr << "\t"; + PrinterTrait::print(*I); + std::cerr << "\n"; + } std::cerr << '\n'; // Clear out results so we don't get duplicate warnings on