Browse Source

Fix assignment of ILRanges in ExpressionTransforms.TransformCatchVariable

pull/1920/head
Siegfried Pammer 5 years ago
parent
commit
9c8df1d949
  1. 7
      ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs

7
ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs

@ -713,7 +713,6 @@ namespace ICSharpCode.Decompiler.IL.Transforms
/// </summary> /// </summary>
void TransformCatchVariable(TryCatchHandler handler, Block entryPoint, bool isCatchBlock) void TransformCatchVariable(TryCatchHandler handler, Block entryPoint, bool isCatchBlock)
{ {
List<Interval> ilOffsets = null;
if (!handler.Variable.IsSingleDefinition || handler.Variable.LoadCount != 1) if (!handler.Variable.IsSingleDefinition || handler.Variable.LoadCount != 1)
return; // handle.Variable already has non-trivial uses return; // handle.Variable already has non-trivial uses
if (!entryPoint.Instructions[0].MatchStLoc(out var exceptionVar, out var exceptionSlotLoad)) { if (!entryPoint.Instructions[0].MatchStLoc(out var exceptionVar, out var exceptionSlotLoad)) {
@ -723,7 +722,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
if (inlinedUnboxAny.Type.Equals(handler.Variable.Type)) { if (inlinedUnboxAny.Type.Equals(handler.Variable.Type)) {
context.Step("TransformCatchVariable - remove inlined UnboxAny", inlinedUnboxAny); context.Step("TransformCatchVariable - remove inlined UnboxAny", inlinedUnboxAny);
inlinedUnboxAny.ReplaceWith(inlinedUnboxAny.Argument); inlinedUnboxAny.ReplaceWith(inlinedUnboxAny.Argument);
(ilOffsets ?? (ilOffsets = new List<Interval>())).AddRange(inlinedUnboxAny.ILRanges); foreach (var range in inlinedUnboxAny.ILRanges)
handler.AddExceptionSpecifierILRange(range);
} }
} }
return; return;
@ -751,8 +751,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
exceptionVar.Type = handler.Variable.Type; exceptionVar.Type = handler.Variable.Type;
handler.Variable = exceptionVar; handler.Variable = exceptionVar;
if (isCatchBlock) { if (isCatchBlock) {
(ilOffsets ?? (ilOffsets = new List<Interval>())).AddRange(entryPoint.Instructions[0].Descendants.SelectMany(o => o.ILRanges)); foreach (var offset in entryPoint.Instructions[0].Descendants.SelectMany(o => o.ILRanges))
foreach (var offset in ilOffsets)
handler.AddExceptionSpecifierILRange(offset); handler.AddExceptionSpecifierILRange(offset);
} }
entryPoint.Instructions.RemoveAt(0); entryPoint.Instructions.RemoveAt(0);

Loading…
Cancel
Save