@@ -1359,6 +1359,15 @@ class TranslatedNotExpr extends TranslatedNonConstantExpr {
13591359
13601360 override Type getExprType ( ) { result instanceof BoolType }
13611361
1362+ private predicate shouldHaveConversion ( ) {
1363+ exists ( TranslatedElement parent , Type t |
1364+ parent = this .getParent ( ) and
1365+ parent .expectsBooleanChild ( this ) and
1366+ t = super .getExprType ( ) and
1367+ not t instanceof BoolType
1368+ )
1369+ }
1370+
13621371 private Type getOperandType ( ) { result = this .getOperand ( ) .getExprType ( ) .getUnspecifiedType ( ) }
13631372
13641373 predicate shouldGenerateEq ( ) { not this .getOperandType ( ) instanceof BoolType }
@@ -1386,10 +1395,24 @@ class TranslatedNotExpr extends TranslatedNonConstantExpr {
13861395 if this .shouldGenerateEq ( )
13871396 then opcode instanceof Opcode:: CompareEQ
13881397 else opcode instanceof Opcode:: LogicalNot
1398+ or
1399+ this .shouldHaveConversion ( ) and
1400+ tag = NotExprConversionTag ( ) and
1401+ opcode instanceof Opcode:: Convert and
1402+ resultType = getIntType ( )
13891403 }
13901404
13911405 final override Instruction getInstructionSuccessorInternal ( InstructionTag tag , EdgeKind kind ) {
1406+ this .shouldHaveConversion ( ) and
13921407 tag = NotExprOperationTag ( ) and
1408+ kind instanceof GotoEdge and
1409+ result = this .getInstruction ( NotExprConversionTag ( ) )
1410+ or
1411+ (
1412+ if this .shouldHaveConversion ( )
1413+ then tag = NotExprConversionTag ( )
1414+ else tag = NotExprOperationTag ( )
1415+ ) and
13931416 result = this .getParent ( ) .getChildSuccessor ( this , kind )
13941417 or
13951418 tag = NotExprConstantTag ( ) and
@@ -1418,13 +1441,22 @@ class TranslatedNotExpr extends TranslatedNonConstantExpr {
14181441 operandTag instanceof UnaryOperandTag and
14191442 result = this .getOperand ( ) .getResult ( )
14201443 )
1444+ or
1445+ this .shouldHaveConversion ( ) and
1446+ tag = NotExprConversionTag ( ) and
1447+ operandTag instanceof UnaryOperandTag and
1448+ result = this .getInstruction ( NotExprOperationTag ( ) )
14211449 }
14221450
14231451 private TranslatedExpr getOperand ( ) {
14241452 result = getTranslatedExpr ( expr .getOperand ( ) .getFullyConverted ( ) )
14251453 }
14261454
1427- final override Instruction getResult ( ) { result = this .getInstruction ( NotExprOperationTag ( ) ) }
1455+ final override Instruction getResult ( ) {
1456+ if this .shouldHaveConversion ( )
1457+ then result = this .getInstruction ( NotExprConversionTag ( ) )
1458+ else result = this .getInstruction ( NotExprOperationTag ( ) )
1459+ }
14281460
14291461 override string getInstructionConstantValue ( InstructionTag tag ) {
14301462 this .shouldGenerateEq ( ) and
0 commit comments