diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index be53ed2584e..cbedcfa7456 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -140,9 +140,9 @@ Value::~Value() CallInst::destroyThis(CI); else if (CmpInst *CI = dyn_cast(this)) { - if (FCmpInst *FCI = dyn_cast(this)) + if (FCmpInst *FCI = dyn_cast(CI)) FCmpInst::destroyThis(FCI); - else if (ICmpInst *ICI = dyn_cast(this)) + else if (ICmpInst *ICI = dyn_cast(CI)) ICmpInst::destroyThis(ICI); else assert(0 && "Unknown CmpInst-inherited class in ~Value."); @@ -163,28 +163,25 @@ Value::~Value() StoreInst::destroyThis(SI); else if (TerminatorInst *TI = dyn_cast(this)) { - if (BranchInst* BI = dyn_cast(this)) + if (BranchInst* BI = dyn_cast(TI)) BranchInst::destroyThis(BI); - else if (InvokeInst* II = dyn_cast(this)) + else if (InvokeInst* II = dyn_cast(TI)) InvokeInst::destroyThis(II); - else if (ReturnInst* RI = dyn_cast(this)) + else if (ReturnInst* RI = dyn_cast(TI)) ReturnInst::destroyThis(RI); - else if (SwitchInst *SI = dyn_cast(this)) + else if (SwitchInst *SI = dyn_cast(TI)) SwitchInst::destroyThis(SI); - else if (UnreachableInst *UI = dyn_cast(this)) + else if (UnreachableInst *UI = dyn_cast(TI)) UnreachableInst::destroyThis(UI); - else if (UnwindInst *UI = dyn_cast(this)) + else if (UnwindInst *UI = dyn_cast(TI)) UnwindInst::destroyThis(UI); else assert(0 && "Unknown TerminatorInst-inherited class in ~Value."); - } - else if(UnaryInstruction* UI = dyn_cast(this)) - { - if(AllocationInst* AI = dyn_cast(this)) - { - if(AllocaInst* AI = dyn_cast(this)) + } else if(UnaryInstruction* UI = dyn_cast(this)) { + if(AllocationInst* AI = dyn_cast(UI)) { + if(AllocaInst* AI = dyn_cast(UI)) AllocaInst::destroyThis(AI); - else if(MallocInst* MI = dyn_cast(this)) + else if(MallocInst* MI = dyn_cast(UI)) MallocInst::destroyThis(MI); else assert(0 && "Unknown AllocationInst-inherited class in ~Value.");