@@ -17,10 +17,14 @@ class DataFlowCfgNode extends ControlFlowNode {
1717}
1818
1919/** A data flow node which should have an associated post-update node. */
20- abstract class PreUpdateNode extends Node { }
20+ abstract class PreUpdateNode extends Node {
21+ abstract string label ( ) ;
22+ }
2123
2224/** An argument might have its value changed as a result of a call. */
23- class ArgumentPreUpdateNode extends PreUpdateNode , ArgumentNode { }
25+ class ArgumentPreUpdateNode extends PreUpdateNode , ExplicitArgumentNode {
26+ override string label ( ) { result = "arg" }
27+ }
2428
2529/** An object might have its value changed after a store. */
2630class StorePreUpdateNode extends PreUpdateNode , CfgNode {
@@ -30,6 +34,8 @@ class StorePreUpdateNode extends PreUpdateNode, CfgNode {
3034 a .getCtx ( ) instanceof Store
3135 )
3236 }
37+
38+ override string label ( ) { result = "store" }
3339}
3440
3541/** A node marking the state change of an object after a read. */
@@ -40,6 +46,17 @@ class ReadPreUpdateNode extends PreUpdateNode, CfgNode {
4046 a .getCtx ( ) instanceof Load
4147 )
4248 }
49+
50+ override string label ( ) { result = "read" }
51+ }
52+
53+ class MallocNode extends PreUpdateNode , ImplicitSelfArgumentNode {
54+ // ObjectCreationNode() { exists(ClassValue c | this.asCfgNode() = c.getACall()) }
55+ override string toString ( ) {
56+ result = "malloc " + this .asCfgNode ( ) .( CallNode ) .getNode ( ) .( Call ) .toString ( )
57+ }
58+
59+ override string label ( ) { result = "malloc" }
4360}
4461
4562/**
@@ -61,7 +78,7 @@ class PostUpdateNode extends Node, TPostUpdateNode {
6178 /** Gets the node before the state update. */
6279 Node getPreUpdateNode ( ) { result = pre }
6380
64- override string toString ( ) { result = "[post] " + pre .toString ( ) }
81+ override string toString ( ) { result = "[post " + pre . label ( ) + " ] " + pre .toString ( ) }
6582
6683 override Scope getScope ( ) { result = pre .getScope ( ) }
6784
@@ -297,14 +314,33 @@ class SpecialCall extends DataFlowCall, TSpecialCall {
297314}
298315
299316/** A data flow node that represents a call argument. */
300- class ArgumentNode extends CfgNode {
301- ArgumentNode ( ) { exists ( DataFlowCall call , int pos | node = call .getArg ( pos ) ) }
317+ abstract class ArgumentNode extends CfgNode {
318+ /** Holds if this argument occurs at the given position in the given call. */
319+ abstract predicate argumentOf ( DataFlowCall call , int pos ) ;
320+
321+ /** Gets the call in which this node is an argument. */
322+ abstract DataFlowCall getCall ( ) ;
323+ }
324+
325+ /** A data flow node that represents a call argument. */
326+ class ExplicitArgumentNode extends ArgumentNode {
327+ ExplicitArgumentNode ( ) { exists ( DataFlowCall call , int pos | node = call .getArg ( pos ) ) }
328+
329+ /** Holds if this argument occurs at the given position in the given call. */
330+ override predicate argumentOf ( DataFlowCall call , int pos ) { node = call .getArg ( pos ) }
331+
332+ /** Gets the call in which this node is an argument. */
333+ final override DataFlowCall getCall ( ) { this .argumentOf ( result , _) }
334+ }
335+
336+ class ImplicitSelfArgumentNode extends ArgumentNode {
337+ ImplicitSelfArgumentNode ( ) { exists ( ClassValue cv | node = cv .getACall ( ) ) }
302338
303339 /** Holds if this argument occurs at the given position in the given call. */
304- predicate argumentOf ( DataFlowCall call , int pos ) { node = call . getArg ( pos ) }
340+ override predicate argumentOf ( DataFlowCall call , int pos ) { call = TCallNode ( node ) and pos = - 1 }
305341
306342 /** Gets the call in which this node is an argument. */
307- final DataFlowCall getCall ( ) { this . argumentOf ( result , _ ) }
343+ final override DataFlowCall getCall ( ) { result = TCallNode ( node ) }
308344}
309345
310346/** Gets a viable run-time target for the call `call`. */
0 commit comments