Browse Source

Fix #2390: Extend variable splitting to treat stobj as immediate address use.

pull/2426/head
Siegfried Pammer 4 years ago
parent
commit
c22977e1be
  1. 15
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs
  2. 2
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ValueTypes.cs
  3. 3
      ICSharpCode.Decompiler/IL/Transforms/SplitVariables.cs

15
ICSharpCode.Decompiler.Tests/TestCases/Pretty/InitializerTests.cs

@ -233,6 +233,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests @@ -233,6 +233,9 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
}
#endregion
private S s1;
private S s2;
#region Field initializer tests
private static V3f[] Issue1336_rg0 = new V3f[3] {
new V3f(1f, 1f, 1f),
@ -905,6 +908,18 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests @@ -905,6 +908,18 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty.InitializerTests
});
}
public void InliningOfStFldTarget()
{
s1 = new S {
A = 24,
B = 42
};
s2 = new S {
A = 42,
B = 24
};
}
public static void NotAStructInitializer_ExplicitConstructor()
{
StructData structData = new StructData(0);

2
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ValueTypes.cs

@ -282,7 +282,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty @@ -282,7 +282,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
return ulong.MaxValue.ToString();
}
public static void M4()
public static void InliningDefaultValue()
{
Test(default(DateTime).GetType());
Test(default(DateTime).ToString());

3
ICSharpCode.Decompiler/IL/Transforms/SplitVariables.cs

@ -103,7 +103,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -103,7 +103,8 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{
switch (addressLoadingInstruction.Parent)
{
case LdObj ldobj:
case LdObj _:
case StObj stobj when stobj.Target == addressLoadingInstruction:
return AddressUse.Immediate;
case LdFlda ldflda:
return DetermineAddressUse(ldflda, targetVar);

Loading…
Cancel
Save