@@ -1861,21 +1861,40 @@ class TranslatedBinaryOperation extends TranslatedNonConstantExpr {
18611861 }
18621862
18631863 final override Instruction getResult ( ) {
1864- result = this .getInstruction ( BinaryOperationOperationTag ( ) )
1864+ if this .shouldHaveConversion ( )
1865+ then result = this .getInstruction ( BinaryOperationConversionTag ( ) )
1866+ else result = this .getInstruction ( BinaryOperationOperationTag ( ) )
1867+ }
1868+
1869+ private predicate shouldHaveConversion ( ) {
1870+ exists ( TranslatedElement parent , Type t |
1871+ parent = this .getParent ( ) and
1872+ parent .expectsBooleanChild ( this ) and
1873+ exists ( comparisonOpcode ( expr ) ) and
1874+ t = super .getExprType ( ) and
1875+ not t instanceof BoolType
1876+ )
18651877 }
18661878
18671879 final override predicate hasInstruction ( Opcode opcode , InstructionTag tag , CppType resultType ) {
18681880 opcode = this .getOpcode ( ) and
18691881 tag = BinaryOperationOperationTag ( ) and
18701882 resultType = this .getResultType ( )
1883+ or
1884+ this .shouldHaveConversion ( ) and
1885+ opcode instanceof Opcode:: Convert and
1886+ tag = BinaryOperationConversionTag ( ) and
1887+ resultType = getIntType ( )
18711888 }
18721889
18731890 override Instruction getFirstInstruction ( EdgeKind kind ) {
18741891 result = this .getLeftOperand ( ) .getFirstInstruction ( kind )
18751892 }
18761893
18771894 override Instruction getALastInstructionInternal ( ) {
1878- result = this .getInstruction ( BinaryOperationOperationTag ( ) )
1895+ if this .shouldHaveConversion ( )
1896+ then result = this .getInstruction ( BinaryOperationConversionTag ( ) )
1897+ else result = this .getInstruction ( BinaryOperationOperationTag ( ) )
18791898 }
18801899
18811900 final override TranslatedElement getChildInternal ( int id ) {
@@ -1900,10 +1919,23 @@ class TranslatedBinaryOperation extends TranslatedNonConstantExpr {
19001919 operandTag instanceof RightOperandTag and
19011920 result = this .getRightOperand ( ) .getResult ( )
19021921 )
1922+ or
1923+ this .shouldHaveConversion ( ) and
1924+ tag = BinaryOperationConversionTag ( ) and
1925+ operandTag instanceof UnaryOperandTag and
1926+ result = this .getInstruction ( BinaryOperationOperationTag ( ) )
19031927 }
19041928
19051929 override Instruction getInstructionSuccessorInternal ( InstructionTag tag , EdgeKind kind ) {
19061930 tag = BinaryOperationOperationTag ( ) and
1931+ if this .shouldHaveConversion ( )
1932+ then
1933+ kind instanceof GotoEdge and
1934+ result = this .getInstruction ( BinaryOperationConversionTag ( ) )
1935+ else result = this .getParent ( ) .getChildSuccessor ( this , kind )
1936+ or
1937+ this .shouldHaveConversion ( ) and
1938+ tag = BinaryOperationConversionTag ( ) and
19071939 result = this .getParent ( ) .getChildSuccessor ( this , kind )
19081940 }
19091941
0 commit comments