@@ -1359,6 +1359,15 @@ class TranslatedNotExpr extends TranslatedNonConstantExpr {
1359
1359
1360
1360
override Type getExprType ( ) { result instanceof BoolType }
1361
1361
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
+
1362
1371
private Type getOperandType ( ) { result = this .getOperand ( ) .getExprType ( ) .getUnspecifiedType ( ) }
1363
1372
1364
1373
predicate shouldGenerateEq ( ) { not this .getOperandType ( ) instanceof BoolType }
@@ -1386,10 +1395,24 @@ class TranslatedNotExpr extends TranslatedNonConstantExpr {
1386
1395
if this .shouldGenerateEq ( )
1387
1396
then opcode instanceof Opcode:: CompareEQ
1388
1397
else opcode instanceof Opcode:: LogicalNot
1398
+ or
1399
+ this .shouldHaveConversion ( ) and
1400
+ tag = NotExprConversionTag ( ) and
1401
+ opcode instanceof Opcode:: Convert and
1402
+ resultType = getIntType ( )
1389
1403
}
1390
1404
1391
1405
final override Instruction getInstructionSuccessorInternal ( InstructionTag tag , EdgeKind kind ) {
1406
+ this .shouldHaveConversion ( ) and
1392
1407
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
1393
1416
result = this .getParent ( ) .getChildSuccessor ( this , kind )
1394
1417
or
1395
1418
tag = NotExprConstantTag ( ) and
@@ -1418,13 +1441,22 @@ class TranslatedNotExpr extends TranslatedNonConstantExpr {
1418
1441
operandTag instanceof UnaryOperandTag and
1419
1442
result = this .getOperand ( ) .getResult ( )
1420
1443
)
1444
+ or
1445
+ this .shouldHaveConversion ( ) and
1446
+ tag = NotExprConversionTag ( ) and
1447
+ operandTag instanceof UnaryOperandTag and
1448
+ result = this .getInstruction ( NotExprOperationTag ( ) )
1421
1449
}
1422
1450
1423
1451
private TranslatedExpr getOperand ( ) {
1424
1452
result = getTranslatedExpr ( expr .getOperand ( ) .getFullyConverted ( ) )
1425
1453
}
1426
1454
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
+ }
1428
1460
1429
1461
override string getInstructionConstantValue ( InstructionTag tag ) {
1430
1462
this .shouldGenerateEq ( ) and
0 commit comments