Browse Source

Fix #1135: Redundant constant "&& true" added to decompiled code.

Suppress && / || transformation, if rhs is the identity of the operator.
pull/1213/head
Siegfried Pammer 7 years ago
parent
commit
6ca3863c63
  1. 4
      ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

4
ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs

@ -2203,11 +2203,11 @@ namespace ICSharpCode.Decompiler.CSharp @@ -2203,11 +2203,11 @@ namespace ICSharpCode.Decompiler.CSharp
BinaryOperatorType op = BinaryOperatorType.Any;
TranslatedExpression rhs = default(TranslatedExpression);
if (inst.MatchLogicAnd(out var lhsInst, out var rhsInst)) {
if (inst.MatchLogicAnd(out var lhsInst, out var rhsInst) && !rhsInst.MatchLdcI4(1)) {
op = BinaryOperatorType.ConditionalAnd;
Debug.Assert(rhsInst == inst.TrueInst);
rhs = trueBranch;
} else if (inst.MatchLogicOr(out lhsInst, out rhsInst)) {
} else if (inst.MatchLogicOr(out lhsInst, out rhsInst) && !rhsInst.MatchLdcI4(0)) {
op = BinaryOperatorType.ConditionalOr;
Debug.Assert(rhsInst == inst.FalseInst);
rhs = falseBranch;

Loading…
Cancel
Save