X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FVMCore%2FLeaksContext.h;h=b9e59d46b7ad62791449180931fd20aacf30017c;hb=b6777eae58392cb5e19282622996e81c72b72a3e;hp=4c45b86b5ffb39f5ee0afd21e6c53d18d4390fa1;hpb=c34ebf65af0139eaf5cb0969fabcd32c0b6e1710;p=oota-llvm.git diff --git a/lib/VMCore/LeaksContext.h b/lib/VMCore/LeaksContext.h index 4c45b86b5ff..b9e59d46b7a 100644 --- a/lib/VMCore/LeaksContext.h +++ b/lib/VMCore/LeaksContext.h @@ -1,4 +1,4 @@ -//===---------------- ----LeaksContext.h - Implementation ------*- C++ -*--===// +//===- LeaksContext.h - LeadDetector Implementation ------------*- C++ -*--===// // // The LLVM Compiler Infrastructure // @@ -13,19 +13,18 @@ //===----------------------------------------------------------------------===// #include "llvm/Value.h" -#include "llvm/Support/Streams.h" #include "llvm/ADT/SmallPtrSet.h" -using namespace llvm; +namespace llvm { template struct PrinterTrait { - static void print(const T* P) { cerr << P; } + static void print(const T* P) { errs() << P; } }; template<> struct PrinterTrait { - static void print(const Value* P) { cerr << *P; } + static void print(const Value* P) { errs() << *P; } }; template @@ -48,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; @@ -68,14 +68,14 @@ struct LeakDetectorImpl { assert(Cache == 0 && "No value should be cached anymore!"); if (!Ts.empty()) { - cerr << "Leaked " << Name << " objects found: " << Message << ":\n"; + errs() << "Leaked " << Name << " objects found: " << Message << ":\n"; for (typename SmallPtrSet::iterator I = Ts.begin(), E = Ts.end(); I != E; ++I) { - cerr << "\t"; + errs() << '\t'; PrinterTrait::print(*I); - cerr << "\n"; + errs() << '\n'; } - cerr << '\n'; + errs() << '\n'; return true; } @@ -88,3 +88,5 @@ private: const T* Cache; const char* Name; }; + +}