#include "llvm/InstrTypes.h"
#include "llvm/SymbolTable.h"
#include "llvm/DerivedTypes.h"
+#include "Support/LeakDetector.h"
#include <algorithm>
//===----------------------------------------------------------------------===//
return Ty;
}
-Value::Value(const Type *ty, ValueTy vty, const std::string &name = "")
+Value::Value(const Type *ty, ValueTy vty, const std::string &name)
: Name(name), Ty(checkType(ty), this) {
VTy = vty;
}
//
if (Uses.begin() != Uses.end()) {
std::cerr << "While deleting: " << Ty << "%" << Name << "\n";
- for (use_const_iterator I = Uses.begin(); I != Uses.end(); ++I) {
- std::cerr << "Use still stuck around after Def is destroyed:";
- (*I)->dump();
- std::cerr << "\n";
- }
+ for (use_const_iterator I = Uses.begin(); I != Uses.end(); ++I)
+ std::cerr << "Use still stuck around after Def is destroyed:"
+ << **I << "\n";
}
#endif
assert(Uses.begin() == Uses.end());
+
+ // There should be no uses of this object anymore, remove it.
+ LeakDetector::removeGarbageObject(this);
}
void Value::replaceAllUsesWith(Value *D) {
Use->replaceUsesOfWith(this, D);
#ifndef NDEBUG // only in -g mode...
- if (Uses.size() == NumUses) {
- std::cerr << "Use: ";
- Use->dump();
- std::cerr << "replace with: ";
- D->dump();
- }
+ if (Uses.size() == NumUses)
+ std::cerr << "Use: " << *Use << "replace with: " << *D;
#endif
assert(Uses.size() != NumUses && "Didn't remove definition!");
}
// change Ty to point to the right type. :)
//
void Value::refineAbstractType(const DerivedType *OldTy, const Type *NewTy) {
- assert(Ty.get() == OldTy &&"Can't refine anything but my type!");
+ assert(Ty.get() == OldTy && "Can't refine anything but my type!");
if (OldTy == NewTy && !OldTy->isAbstract())
Ty.removeUserFromConcrete();
Ty = NewTy;