Stylistic tweak.
[oota-llvm.git] / lib / VMCore / LeaksContext.h
index b0c3a14fe84aa25787d5f1cd01122b97734b571c..faf3e952c854cb0455230b9109b43b9131eff97c 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/Value.h"
 #include "llvm/ADT/SmallPtrSet.h"
-#include "llvm/Support/raw_ostream.h"
-using namespace llvm;
+#include "llvm/Value.h"
+
+namespace llvm {
 
 template <class T>
 struct PrinterTrait {
@@ -47,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;
@@ -87,3 +88,5 @@ private:
   const T* Cache;
   const char* Name;
 };
+
+}