From b9d6ba7dff71e5e2fa3e782e8c37e293ec264430 Mon Sep 17 00:00:00 2001 From: ds5678 <49847914+ds5678@users.noreply.github.com> Date: Sat, 11 Oct 2025 21:35:04 -0700 Subject: [PATCH] Remove flags from `box` that indicate memory access and ability to throw --- ICSharpCode.Decompiler/IL/Instructions.cs | 19 ------------------- ICSharpCode.Decompiler/IL/Instructions.tt | 2 +- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/ICSharpCode.Decompiler/IL/Instructions.cs b/ICSharpCode.Decompiler/IL/Instructions.cs index 96a6bd948..490bc19db 100644 --- a/ICSharpCode.Decompiler/IL/Instructions.cs +++ b/ICSharpCode.Decompiler/IL/Instructions.cs @@ -318,7 +318,6 @@ namespace ICSharpCode.Decompiler.IL set { ValidateChild(value); SetChildInstruction(ref this.argument, value, 0); - InvalidateFlags(); } } protected sealed override int GetChildCount() @@ -4356,24 +4355,6 @@ namespace ICSharpCode.Decompiler.IL set { type = value; InvalidateFlags(); } } public override StackType ResultType { get { return StackType.O; } } - protected override InstructionFlags ComputeFlags() - { - var baseFlags = base.ComputeFlags(); - if (baseFlags == InstructionFlags.None && Type.Equals(Argument.InferType(null))) - { - return InstructionFlags.None; - } - return baseFlags | InstructionFlags.SideEffect | InstructionFlags.MayThrow; - } - public override InstructionFlags DirectFlags { - get { - if (Flags == InstructionFlags.None) - { - return InstructionFlags.None; - } - return base.DirectFlags | InstructionFlags.SideEffect | InstructionFlags.MayThrow; - } - } public override void WriteTo(ITextOutput output, ILAstWritingOptions options) { WriteILRange(output, options); diff --git a/ICSharpCode.Decompiler/IL/Instructions.tt b/ICSharpCode.Decompiler/IL/Instructions.tt index ed6081243..74963251b 100644 --- a/ICSharpCode.Decompiler/IL/Instructions.tt +++ b/ICSharpCode.Decompiler/IL/Instructions.tt @@ -266,7 +266,7 @@ CustomInvariant("CheckTargetSlot();")), new OpCode("box", "Boxes a value.", - Unary, HasTypeOperand, MemoryAccess, MayThrow, ResultType("O")), + Unary, HasTypeOperand, ResultType("O")), new OpCode("unbox", "Compute address inside box.", Unary, HasTypeOperand, MayThrow, ResultType("Ref")), new OpCode("unbox.any", "Unbox a value.",