forked from dotnet/linker
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Process also exception filters when marking unreachable blocks
Fixes dotnet#1507
- Loading branch information
1 parent
e66a8c2
commit 1c72a7a
Showing
3 changed files
with
104 additions
and
1 deletion.
There are no files selected for viewing
Submodule cecil
updated
from 75fc41 to c600e6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
test/Mono.Linker.Tests.Cases/UnreachableBlock/TryFilterBlocks.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
using Mono.Linker.Tests.Cases.Expectations.Assertions; | ||
using Mono.Linker.Tests.Cases.Expectations.Metadata; | ||
|
||
namespace Mono.Linker.Tests.Cases.UnreachableBlock | ||
{ | ||
[SetupCSharpCompilerToUse ("csc")] | ||
[SetupCompileArgument ("/optimize+")] | ||
[SetupLinkerArgument ("--enable-opt", "ipconstprop")] | ||
public class TryFilterBlocks | ||
{ | ||
public static void Main () | ||
{ | ||
TestUnreachableInsideTry (); | ||
TestUnreachableInsideFilterCondition (); | ||
} | ||
|
||
[Kept] | ||
[ExpectedInstructionSequence (new[] { | ||
"call", | ||
"brfalse.s", | ||
"call", | ||
"leave.s", | ||
"pop", | ||
"call", | ||
"ldc.i4.0", | ||
"cgt.un", | ||
"endfilter", | ||
"pop", | ||
"leave.s", | ||
"ldc.i4.2", | ||
"ret" | ||
})] | ||
[ExpectedExceptionHandlerSequence (new string[] { "filter" })] | ||
static int TestUnreachableInsideTry () | ||
{ | ||
try { | ||
if (Prop) | ||
Unreached_1 (); | ||
|
||
Reached_1 (); | ||
} catch when (Log ()) { | ||
} | ||
|
||
return 2; | ||
} | ||
|
||
[Kept] | ||
[ExpectedInstructionSequence (new[] { | ||
"call", | ||
"leave.s", | ||
"pop", | ||
"call", | ||
"brfalse.s", | ||
"ldc.i4.0", | ||
"ldc.i4.0", | ||
"cgt.un", | ||
"endfilter", | ||
"pop", | ||
"leave.s", | ||
"ldc.i4.3", | ||
"ret" | ||
})] | ||
[ExpectedExceptionHandlerSequence (new string[] { "filter" })] | ||
static int TestUnreachableInsideFilterCondition () | ||
{ | ||
try { | ||
Reached_2 (); | ||
} catch when (Log () && Unreached_2 ()) { | ||
} | ||
|
||
return 3; | ||
} | ||
|
||
[Kept] | ||
static bool Prop { | ||
[Kept] | ||
get { | ||
return false; | ||
} | ||
} | ||
|
||
[Kept] | ||
static bool Log () => false; | ||
|
||
[Kept] | ||
static void Reached_1 () | ||
{ | ||
} | ||
|
||
[Kept] | ||
static void Reached_2 () | ||
{ | ||
} | ||
|
||
static void Unreached_1 () | ||
{ | ||
} | ||
|
||
static bool Unreached_2 () => true; | ||
} | ||
} |