Browse Source

Fix failed assertion when encountering a finally block with an unreachable endpoint in ReduceNestingTransform.

pull/1880/head
Chicken-Bones 5 years ago
parent
commit
abd9af29c6
  1. 17
      ICSharpCode.Decompiler/IL/Transforms/ReduceNestingTransform.cs

17
ICSharpCode.Decompiler/IL/Transforms/ReduceNestingTransform.cs

@ -364,13 +364,18 @@ namespace ICSharpCode.Decompiler.IL @@ -364,13 +364,18 @@ namespace ICSharpCode.Decompiler.IL
ILInstruction leavingInst = leave.TargetContainer;
Debug.Assert(!leavingInst.HasFlag(InstructionFlags.EndPointUnreachable));
while (!(leavingInst.Parent is Block b) || leavingInst == b.Instructions.Last()) {
// cannot duplicate leaves from finally containers
if (leavingInst.Parent is TryFinally tryFinally && leavingInst.SlotInfo == TryFinally.FinallyBlockSlot) {
Debug.Assert(leave.TargetContainer == tryFinally.FinallyBlock); //finally cannot have control flow
return false;
}
leavingInst = leavingInst.Parent;
if (leavingInst is TryFinally tryFinally) {
if (leavingInst.SlotInfo == TryFinally.FinallyBlockSlot) { // cannot duplicate leaves from finally containers
Debug.Assert(leave.TargetContainer == tryFinally.FinallyBlock); //finally cannot have control flow
return false;
}
if (leavingInst.HasFlag(InstructionFlags.EndPointUnreachable)) { // finally block changes return value/throws an exception? Yikes. Lets leave it alone
Debug.Assert(tryFinally.FinallyBlock.HasFlag(InstructionFlags.EndPointUnreachable));
return false;
}
}
Debug.Assert(!leavingInst.HasFlag(InstructionFlags.EndPointUnreachable));
Debug.Assert(!(leavingInst is ILFunction));
}

Loading…
Cancel
Save