@@ -5,23 +5,15 @@ private import DataFlowDispatch
55
66/**
77 * A data flow node that occurs as the argument of a call and is passed as-is
8- * to the callable. Instance arguments (`this` pointer) are also included.
8+ * to the callable. Instance arguments (`this` pointer) and read side effects
9+ * on parameters are also included.
910 */
10- class ArgumentNode extends Node {
11- ArgumentNode ( ) {
12- // To avoid making this class abstract, we enumerate its values here.
13- this instanceof PrimaryArgumentNode or
14- this instanceof SideEffectArgumentNode
15- }
16-
11+ abstract class ArgumentNode extends OperandNode {
1712 /**
1813 * Holds if this argument occurs at the given position in the given call.
1914 * The instance argument is considered to have index `-1`.
2015 */
21- predicate argumentOf ( DataFlowCall call , int pos ) {
22- this .( PrimaryArgumentNode ) .argumentOf ( call , pos ) or
23- this .( SideEffectArgumentNode ) .argumentOf ( call , pos )
24- }
16+ abstract predicate argumentOf ( DataFlowCall call , int pos ) ;
2517
2618 /** Gets the call in which this node is an argument. */
2719 DataFlowCall getCall ( ) { this .argumentOf ( result , _) }
@@ -31,44 +23,34 @@ class ArgumentNode extends Node {
3123 * A data flow node that occurs as the argument to a call, or an
3224 * implicit `this` pointer argument.
3325 */
34- private class PrimaryArgumentNode extends InstructionNode {
35- PrimaryArgumentNode ( ) { exists ( CallInstruction call | instr = call . getAnArgument ( ) ) }
26+ private class PrimaryArgumentNode extends ArgumentNode {
27+ override ArgumentOperand op ;
3628
37- /**
38- * Holds if this argument occurs at the given position in the given call.
39- * The instance argument is considered to have index `-1`.
40- */
41- predicate argumentOf ( DataFlowCall call , int pos ) {
42- instr = call .getPositionalArgument ( pos )
29+ PrimaryArgumentNode ( ) { exists ( CallInstruction call | op = call .getAnArgumentOperand ( ) ) }
30+
31+ override predicate argumentOf ( DataFlowCall call , int pos ) {
32+ op = call .getPositionalArgumentOperand ( pos )
4333 or
44- instr = call .getThisArgument ( ) and pos = - 1
34+ op = call .getThisArgumentOperand ( ) and pos = - 1
4535 }
4636}
4737
4838/**
4939 * A data flow node representing the read side effect of a call on a
5040 * specific parameter.
5141 */
52- private class SideEffectArgumentNode extends OperandNode {
42+ private class SideEffectArgumentNode extends ArgumentNode {
5343 override SideEffectOperand op ;
5444 ReadSideEffectInstruction read ;
5545
56- SideEffectArgumentNode ( ) {
57- exists ( CallInstruction call |
58- read .getPrimaryInstruction ( ) = call and
59- op = read .getSideEffectOperand ( )
60- )
61- }
46+ SideEffectArgumentNode ( ) { op = read .getSideEffectOperand ( ) }
6247
63- /**
64- * Holds if this argument occurs at the given position in the given call.
65- * See `getArgumentPosOfSideEffect` for a describing of how read side effects
66- * are assigned an argument position.
67- */
68- predicate argumentOf ( DataFlowCall call , int pos ) {
48+ override predicate argumentOf ( DataFlowCall call , int pos ) {
6949 read .getPrimaryInstruction ( ) = call and
7050 pos = getArgumentPosOfSideEffect ( read .getIndex ( ) )
7151 }
52+
53+ override string toString ( ) { result = "Argument " + read .getIndex ( ) + " indirection" }
7254}
7355
7456private newtype TReturnKind =
0 commit comments