@@ -1861,21 +1861,40 @@ class TranslatedBinaryOperation extends TranslatedNonConstantExpr {
1861
1861
}
1862
1862
1863
1863
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
+ )
1865
1877
}
1866
1878
1867
1879
final override predicate hasInstruction ( Opcode opcode , InstructionTag tag , CppType resultType ) {
1868
1880
opcode = this .getOpcode ( ) and
1869
1881
tag = BinaryOperationOperationTag ( ) and
1870
1882
resultType = this .getResultType ( )
1883
+ or
1884
+ this .shouldHaveConversion ( ) and
1885
+ opcode instanceof Opcode:: Convert and
1886
+ tag = BinaryOperationConversionTag ( ) and
1887
+ resultType = getIntType ( )
1871
1888
}
1872
1889
1873
1890
override Instruction getFirstInstruction ( EdgeKind kind ) {
1874
1891
result = this .getLeftOperand ( ) .getFirstInstruction ( kind )
1875
1892
}
1876
1893
1877
1894
override Instruction getALastInstructionInternal ( ) {
1878
- result = this .getInstruction ( BinaryOperationOperationTag ( ) )
1895
+ if this .shouldHaveConversion ( )
1896
+ then result = this .getInstruction ( BinaryOperationConversionTag ( ) )
1897
+ else result = this .getInstruction ( BinaryOperationOperationTag ( ) )
1879
1898
}
1880
1899
1881
1900
final override TranslatedElement getChildInternal ( int id ) {
@@ -1900,10 +1919,23 @@ class TranslatedBinaryOperation extends TranslatedNonConstantExpr {
1900
1919
operandTag instanceof RightOperandTag and
1901
1920
result = this .getRightOperand ( ) .getResult ( )
1902
1921
)
1922
+ or
1923
+ this .shouldHaveConversion ( ) and
1924
+ tag = BinaryOperationConversionTag ( ) and
1925
+ operandTag instanceof UnaryOperandTag and
1926
+ result = this .getInstruction ( BinaryOperationOperationTag ( ) )
1903
1927
}
1904
1928
1905
1929
override Instruction getInstructionSuccessorInternal ( InstructionTag tag , EdgeKind kind ) {
1906
1930
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
1907
1939
result = this .getParent ( ) .getChildSuccessor ( this , kind )
1908
1940
}
1909
1941
0 commit comments