@@ -32,25 +32,34 @@ DataFlow::Node callInput(CallInstruction call, FunctionInput input) {
3232}
3333
3434/**
35- * Gets the instruction that holds the `output` for `call`.
35+ * Gets the node that represents the output of `call` with kind `output` at
36+ * indirection index `indirectionIndex`.
3637 */
37- Node callOutput ( CallInstruction call , FunctionOutput output ) {
38+ private Node callOutputWithIndirectionIndex (
39+ CallInstruction call , FunctionOutput output , int indirectionIndex
40+ ) {
3841 // The return value
3942 simpleOutNode ( result , call ) and
40- output .isReturnValue ( )
43+ output .isReturnValue ( ) and
44+ indirectionIndex = 0
4145 or
4246 // The side effect of a call on the value pointed to by an argument or qualifier
43- exists ( int index , int indirectionIndex |
47+ exists ( int index |
4448 result .( IndirectArgumentOutNode ) .getArgumentIndex ( ) = index and
45- result .( IndirectArgumentOutNode ) .getIndirectionIndex ( ) = indirectionIndex and
49+ result .( IndirectArgumentOutNode ) .getIndirectionIndex ( ) = indirectionIndex - 1 and
4650 result .( IndirectArgumentOutNode ) .getCallInstruction ( ) = call and
47- output .isParameterDerefOrQualifierObject ( index , indirectionIndex )
51+ output .isParameterDerefOrQualifierObject ( index , indirectionIndex - 1 )
4852 )
4953 or
50- exists ( int ind |
51- result = getIndirectReturnOutNode ( call , ind ) and
52- output .isReturnValueDeref ( ind )
53- )
54+ result = getIndirectReturnOutNode ( call , indirectionIndex ) and
55+ output .isReturnValueDeref ( indirectionIndex )
56+ }
57+
58+ /**
59+ * Gets the instruction that holds the `output` for `call`.
60+ */
61+ Node callOutput ( CallInstruction call , FunctionOutput output ) {
62+ result = callOutputWithIndirectionIndex ( call , output , _)
5463}
5564
5665DataFlow:: Node callInput ( CallInstruction call , FunctionInput input , int d ) {
@@ -76,19 +85,16 @@ private IndirectReturnOutNode getIndirectReturnOutNode(CallInstruction call, int
7685 */
7786bindingset [ d]
7887Node callOutput ( CallInstruction call , FunctionOutput output , int d ) {
79- exists ( DataFlow:: Node n | n = callOutput ( call , output ) and d > 0 |
88+ exists ( DataFlow:: Node n , int indirectionIndex |
89+ n = callOutputWithIndirectionIndex ( call , output , indirectionIndex ) and d > 0
90+ |
8091 // The return value
81- result = getIndirectReturnOutNode ( n . asInstruction ( ) , d )
92+ result = callOutputWithIndirectionIndex ( call , output , indirectionIndex + d )
8293 or
94+ n = callOutputWithIndirectionIndex ( call , output , indirectionIndex ) and
8395 // If there isn't an indirect out node for the call with indirection `d` then
8496 // we conflate this with the underlying `CallInstruction`.
85- not exists ( getIndirectReturnOutNode ( call , d ) ) and
97+ not exists ( getIndirectReturnOutNode ( call , indirectionIndex + d ) ) and
8698 n = result
87- or
88- // The side effect of a call on the value pointed to by an argument or qualifier
89- exists ( Operand operand , int indirectionIndex |
90- Ssa:: outNodeHasAddressAndIndex ( n , operand , indirectionIndex ) and
91- Ssa:: outNodeHasAddressAndIndex ( result , operand , indirectionIndex + d )
92- )
9399 )
94100}
0 commit comments