From c34a36b3ec38f6995d52e1eb3094fe3d05ffc15d Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Wed, 19 Dec 2018 01:14:40 +0100 Subject: [PATCH] Fix #1326: Another case of missing ILRanges in - TryFinally/TryFault instructions - blocks, that are skipped when leaving nested containers --- ICSharpCode.Decompiler/IL/BlockBuilder.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ICSharpCode.Decompiler/IL/BlockBuilder.cs b/ICSharpCode.Decompiler/IL/BlockBuilder.cs index 4962f028e..a45781a63 100644 --- a/ICSharpCode.Decompiler/IL/BlockBuilder.cs +++ b/ICSharpCode.Decompiler/IL/BlockBuilder.cs @@ -64,9 +64,9 @@ namespace ICSharpCode.Decompiler.IL var tryBlock = new BlockContainer(); tryBlock.ILRange = tryRange; if (eh.Kind == ExceptionRegionKind.Finally) - tryInstructionList.Add(new TryFinally(tryBlock, handlerBlock)); + tryInstructionList.Add(new TryFinally(tryBlock, handlerBlock) { ILRange = tryRange }); else - tryInstructionList.Add(new TryFault(tryBlock, handlerBlock)); + tryInstructionList.Add(new TryFault(tryBlock, handlerBlock) { ILRange = tryRange }); continue; } // @@ -134,6 +134,12 @@ namespace ICSharpCode.Decompiler.IL while (start >= currentContainer.ILRange.End) { currentContainer = containerStack.Pop(); currentBlock = currentContainer.Blocks.Last(); + // this container is skipped (i.e. the loop will execute again) + // set ILRange to the last instruction offset inside the block. + if (start >= currentContainer.ILRange.End) { + Debug.Assert(currentBlock.ILRange.IsEmpty); + currentBlock.ILRange = new Interval(currentBlock.ILRange.Start, start); + } } // Enter a handler if necessary BlockContainer handlerContainer;