@@ -1042,6 +1042,51 @@ class RawIndirectInstruction extends Node, TRawIndirectInstruction {
1042
1042
}
1043
1043
}
1044
1044
1045
+ private module GetConvertedResultExpression {
1046
+ private import semmle.code.cpp.ir.implementation.raw.internal.TranslatedExpr
1047
+ private import semmle.code.cpp.ir.implementation.raw.internal.InstructionTag
1048
+
1049
+ /**
1050
+ * Gets the expression that should be returned as the result expression from `instr`.
1051
+ *
1052
+ * Note that this predicate may return multiple results in cases where a conversion belond to a
1053
+ * different AST element than its operand.
1054
+ */
1055
+ Expr getConvertedResultExpression ( Instruction instr ) {
1056
+ // Only fully converted instructions has a result for `asConvertedExpr`
1057
+ not conversionFlow ( unique( | | getAUse ( instr ) ) , _, false , false ) and
1058
+ result = getConvertedResultExpressionImpl ( instr )
1059
+ or
1060
+ // If the conversion also has a result then we return multiple results
1061
+ exists ( Operand operand | conversionFlow ( operand , instr , false , false ) |
1062
+ result = getConvertedResultExpressionImpl ( operand .getDef ( ) )
1063
+ or
1064
+ result = getConvertedResultExpression ( operand .getDef ( ) )
1065
+ )
1066
+ }
1067
+
1068
+ private Expr getConvertedResultExpressionImpl0 ( Instruction instr ) {
1069
+ exists ( TranslatedAssignOperation tao |
1070
+ result = tao .getExpr ( ) and
1071
+ instr = tao .getInstruction ( any ( AssignmentStoreTag tag ) )
1072
+ )
1073
+ or
1074
+ exists ( TranslatedCrementOperation tco |
1075
+ result = tco .getExpr ( ) and
1076
+ instr = tco .getInstruction ( any ( CrementStoreTag tag ) )
1077
+ )
1078
+ }
1079
+
1080
+ private Expr getConvertedResultExpressionImpl ( Instruction instr ) {
1081
+ result = getConvertedResultExpressionImpl0 ( instr )
1082
+ or
1083
+ not exists ( getConvertedResultExpressionImpl0 ( instr ) ) and
1084
+ result = instr .getConvertedResultExpression ( )
1085
+ }
1086
+ }
1087
+
1088
+ private import GetConvertedResultExpression
1089
+
1045
1090
/** Holds if `node` is an `OperandNode` that should map `node.asExpr()` to `e`. */
1046
1091
predicate exprNodeShouldBeOperand ( OperandNode node , Expr e ) {
1047
1092
exists ( Instruction def |
0 commit comments