Browse Source

Improve control flow decompilation with some compilers

Add a ControlFlowSimplification step after SplitVariables
Enable dead code removal in some unit tests
pull/1176/head
Chicken-Bones 7 years ago
parent
commit
9937302313
  1. 7
      ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs
  2. 1
      ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

7
ICSharpCode.Decompiler.Tests/PrettyTestRunner.cs

@ -106,7 +106,8 @@ namespace ICSharpCode.Decompiler.Tests @@ -106,7 +106,8 @@ namespace ICSharpCode.Decompiler.Tests
public void ExceptionHandling([ValueSource("defaultOptions")] CSharpCompilerOptions cscOptions)
{
RunForLibrary(cscOptions: cscOptions, decompilerSettings: new DecompilerSettings {
NullPropagation = false
NullPropagation = false,
RemoveDeadCode = !cscOptions.HasFlag(CSharpCompilerOptions.UseRoslyn)
});
}
@ -161,7 +162,9 @@ namespace ICSharpCode.Decompiler.Tests @@ -161,7 +162,9 @@ namespace ICSharpCode.Decompiler.Tests
[Test]
public void Loops([ValueSource("defaultOptionsWithMcs")] CSharpCompilerOptions cscOptions)
{
RunForLibrary(cscOptions: cscOptions);
RunForLibrary(cscOptions: cscOptions, decompilerSettings: new DecompilerSettings {
RemoveDeadCode = !cscOptions.HasFlag(CSharpCompilerOptions.Optimize)
});
}
[Test]

1
ICSharpCode.Decompiler/CSharp/CSharpDecompiler.cs

@ -87,6 +87,7 @@ namespace ICSharpCode.Decompiler.CSharp @@ -87,6 +87,7 @@ namespace ICSharpCode.Decompiler.CSharp
// is already collapsed into stloc(V, ...).
new RemoveDeadVariableInit(),
new SplitVariables(), // split variables once again, because the stobj(ldloca V, ...) may open up new replacements
new ControlFlowSimplification(), //split variables may enable new branch to leave inlining
new DynamicCallSiteTransform(),
new SwitchDetection(),
new SwitchOnStringTransform(),

Loading…
Cancel
Save