void Value::replaceAllUsesWith(Value *D) {
assert(D && "Value::replaceAllUsesWith(<null>) is invalid!");
+ assert(D != this && "V->replaceAllUsesWith(V) is NOT valid!");
while (!Uses.empty()) {
User *Use = Uses.front();
#ifndef NDEBUG
void User::replaceUsesOfWith(Value *From, Value *To) {
if (From == To) return; // Duh what?
- for (unsigned OpNum = 0; Value *D = getOperand(OpNum); ++OpNum) {
- if (D == From) { // Okay, this operand is pointing to our fake def.
+ for (unsigned i = 0, E = getNumOperands(); i != E; ++i)
+ if (getOperand(i) == From) { // Is This operand is pointing to oldval?
// The side effects of this setOperand call include linking to
// "To", adding "this" to the uses list of To, and
// most importantly, removing "this" from the use list of "From".
- setOperand(OpNum, To); // Fix it now...
+ setOperand(i, To); // Fix it now...
}
- }
}
// Instantiate Templates - This ugliness is the price we have to pay
// for having a ValueHolderImpl.h file seperate from ValueHolder.h! :(
//
-template class ValueHolder<ConstPoolVal, SymTabValue>;
+template class ValueHolder<ConstPoolVal, SymTabValue, SymTabValue>;
-SymTabValue::SymTabValue(const Type *Ty, ValueTy dty, const string &name = "")
- : Value(Ty, dty, name), ConstPool(this) {
+SymTabValue::SymTabValue(Value *p) : ConstPool(this), ValueParent(p) {
+ assert(ValueParent && "SymTavValue without parent!?!");
ParentSymTab = SymTab = 0;
}