Bug fixes for PR341
authorChris Lattner <sabre@nondot.org>
Thu, 15 Jul 2004 01:29:12 +0000 (01:29 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 15 Jul 2004 01:29:12 +0000 (01:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14838 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ConstantRange.cpp
lib/Support/ConstantRange.cpp
lib/Support/LeakDetector.cpp
lib/VMCore/ConstantRange.cpp
lib/VMCore/LeakDetector.cpp

index 580ca01ac39bdf35d9fa812a888b2313c18f73f3..3b91c5bc7a06175bc4dc0036da0379964f997d3b 100644 (file)
@@ -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...
index 580ca01ac39bdf35d9fa812a888b2313c18f73f3..3b91c5bc7a06175bc4dc0036da0379964f997d3b 100644 (file)
@@ -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...
index 919f7a9c2133de7d03fadf1ddebaa0011b9341fe..dbdb7dd70f29536a7edc352327c18ef9395f0764 100644 (file)
 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
index 580ca01ac39bdf35d9fa812a888b2313c18f73f3..3b91c5bc7a06175bc4dc0036da0379964f997d3b 100644 (file)
@@ -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...
index 919f7a9c2133de7d03fadf1ddebaa0011b9341fe..dbdb7dd70f29536a7edc352327c18ef9395f0764 100644 (file)
 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