Browse Source

Fix #1472: Apply ExpressionTransforms after CombineExitsTransform to "canonicalize logic and/or"

pull/1476/head
Siegfried Pammer 7 years ago
parent
commit
63646b0ace
  1. 9
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.cs
  2. 5
      ICSharpCode.Decompiler/IL/Transforms/CombineExitsTransform.cs

9
ICSharpCode.Decompiler.Tests/TestCases/Pretty/DelegateConstruction.cs

@ -146,6 +146,15 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -146,6 +146,15 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
}
}
public static Func<string, string, bool> test0 = (string a, string b) => string.IsNullOrEmpty(a) || string.IsNullOrEmpty(b);
public static Func<string, string, bool> test1 = (string a, string b) => string.IsNullOrEmpty(a) || !string.IsNullOrEmpty(b);
public static Func<string, string, bool> test2 = (string a, string b) => !string.IsNullOrEmpty(a) || string.IsNullOrEmpty(b);
public static Func<string, string, bool> test3 = (string a, string b) => !string.IsNullOrEmpty(a) || !string.IsNullOrEmpty(b);
public static Func<string, string, bool> test4 = (string a, string b) => string.IsNullOrEmpty(a) && string.IsNullOrEmpty(b);
public static Func<string, string, bool> test5 = (string a, string b) => string.IsNullOrEmpty(a) && !string.IsNullOrEmpty(b);
public static Func<string, string, bool> test6 = (string a, string b) => !string.IsNullOrEmpty(a) && string.IsNullOrEmpty(b);
public static Func<string, string, bool> test7 = (string a, string b) => !string.IsNullOrEmpty(a) && !string.IsNullOrEmpty(b);
public static void Test(this string a)
{
}

5
ICSharpCode.Decompiler/IL/Transforms/CombineExitsTransform.cs

@ -24,7 +24,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -24,7 +24,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{
if (!(function.Body is BlockContainer container && container.Blocks.Count == 1))
return;
CombineExits(container.EntryPoint);
var combinedExit = CombineExits(container.EntryPoint);
if (combinedExit == null)
return;
ExpressionTransforms.RunOnSingleStatement(combinedExit, context);
}
static Leave CombineExits(Block block)

Loading…
Cancel
Save