Skip to content

Commit

Permalink
Fix #1135: Redundant constant "&& true" added to decompiled code.
Browse files Browse the repository at this point in the history
Suppress && / || transformation, if rhs is the identity of the operator.
  • Loading branch information
siegfriedpammer committed Jun 23, 2018
1 parent 6096b7d commit 6ca3863
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ICSharpCode.Decompiler/CSharp/ExpressionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2203,11 +2203,11 @@ protected internal override TranslatedExpression VisitIfInstruction(IfInstructio
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;
Expand Down

0 comments on commit 6ca3863

Please sign in to comment.