[llvm-commits] CVS: llvm/lib/Support/ConstantRange.cpp LeakDetector.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Jul 14 18:29:22 PDT 2004
Changes in directory llvm/lib/Support:
ConstantRange.cpp updated: 1.12 -> 1.13
LeakDetector.cpp updated: 1.9 -> 1.10
---
Log message:
Bug fixes for PR341: http://llvm.cs.uiuc.edu/PR341
---
Diffs of the changes: (+19 -5)
Index: llvm/lib/Support/ConstantRange.cpp
diff -u llvm/lib/Support/ConstantRange.cpp:1.12 llvm/lib/Support/ConstantRange.cpp:1.13
--- llvm/lib/Support/ConstantRange.cpp:1.12 Sun Jul 4 07:19:56 2004
+++ llvm/lib/Support/ConstantRange.cpp Wed Jul 14 20:29:12 2004
@@ -322,7 +322,7 @@
/// 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...
Index: llvm/lib/Support/LeakDetector.cpp
diff -u llvm/lib/Support/LeakDetector.cpp:1.9 llvm/lib/Support/LeakDetector.cpp:1.10
--- llvm/lib/Support/LeakDetector.cpp:1.9 Sun Jul 4 07:19:56 2004
+++ llvm/lib/Support/LeakDetector.cpp Wed Jul 14 20:29:12 2004
@@ -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 @@
if (o == Cache)
Cache = 0; // Cache hit
else
- Ts.erase(o);
+ Ts.erase(o);
}
bool hasGarbage(const std::string& Message) {
@@ -49,9 +59,13 @@
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
More information about the llvm-commits
mailing list