Recommited r156374 with critical fixes in BitcodeReader/Writer:
[oota-llvm.git] / lib / VMCore / LeaksContext.h
index bd10a479ae2a0804c0d3c049eaa6f241474adbed..b9e59d46b7ad62791449180931fd20aacf30017c 100644 (file)
@@ -14,7 +14,8 @@
 
 #include "llvm/Value.h"
 #include "llvm/ADT/SmallPtrSet.h"
-using namespace llvm;
+
+namespace llvm {
 
 template <class T>
 struct PrinterTrait {
@@ -46,8 +47,9 @@ struct LeakDetectorImpl {
   // immediately, it is added to the CachedValue Value.  If it is
   // immediately removed, no set search need be performed.
   void addGarbage(const T* o) {
+    assert(Ts.count(o) == 0 && "Object already in set!");
     if (Cache) {
-      assert(Ts.count(Cache) == 0 && "Object already in set!");
+      assert(Cache != o && "Object already in set!");
       Ts.insert(Cache);
     }
     Cache = o;
@@ -86,3 +88,5 @@ private:
   const T* Cache;
   const char* Name;
 };
+
+}