Browse Source

Fix #1307: some of the blocks made unreachable by the yield-return-transform were not deleted

This had the effect of leaving behind error comments despite the yield-return transform being successful.
pull/1317/head
Daniel Grunwald 7 years ago
parent
commit
ed631cc7d3
  1. 12
      ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs

12
ICSharpCode.Decompiler/IL/ControlFlow/YieldReturnDecompiler.cs

@ -152,16 +152,20 @@ namespace ICSharpCode.Decompiler.IL.ControlFlow
} }
context.Step("Delete unreachable blocks", function); context.Step("Delete unreachable blocks", function);
// Note: because this only deletes blocks outright, the 'stateChanges' entries remain valid
// (though some may point to now-deleted blocks)
newBody.SortBlocks(deleteUnreachableBlocks: true);
if (isCompiledWithMono) { if (isCompiledWithMono) {
// mono has try-finally inline (like async on MS); we also need to sort nested blocks: // mono has try-finally inline (like async on MS); we also need to sort nested blocks:
foreach (var nestedContainer in newBody.Blocks.SelectMany(c => c.Descendants).OfType<BlockContainer>()) { foreach (var nestedContainer in newBody.Blocks.SelectMany(c => c.Descendants).OfType<BlockContainer>()) {
nestedContainer.SortBlocks(deleteUnreachableBlocks: true); nestedContainer.SortBlocks(deleteUnreachableBlocks: true);
} }
} else { // We need to clean up nested blocks before the main block, so that edges from unreachable code
// in nested containers into the main container are removed before we clean up the main container.
}
// Note: because this only deletes blocks outright, the 'stateChanges' entries remain valid
// (though some may point to now-deleted blocks)
newBody.SortBlocks(deleteUnreachableBlocks: true);
if (!isCompiledWithMono) {
DecompileFinallyBlocks(); DecompileFinallyBlocks();
ReconstructTryFinallyBlocks(function); ReconstructTryFinallyBlocks(function);
} }

Loading…
Cancel
Save