@@ -2,6 +2,7 @@ private import unified
22private import AllDataFlow
33private import codeql.unified.internal.ExprPositions
44private import codeql.unified.internal.LocalNameBinding
5+ private import codeql.unified.internal.ParameterEx
56private import codeql.util.Boolean
67
78private predicate hasIncomingValueAtCfgNode ( Expr expr , ControlFlowNode cfgNode ) {
@@ -122,15 +123,7 @@ newtype TDataFlowNode =
122123 not exists ( callable .asSummarizedCallable ( ) ) // represented by TSummaryNode
123124 } or
124125 TCallableNode ( DataFlowCallable callable ) or
125- TImplicitParameterNode ( DataFlowCallable callable , ParameterPosition pos ) {
126- not exists ( callable .asSummarizedCallable ( ) ) and // represented by TSummaryNode
127- (
128- pos instanceof ImplicitParameterPosition
129- or
130- pos .asPositional ( ) =
131- [ 0 .. callable .asSourceCallable ( ) .( FunctionExpr ) .getNumberOfImplicitParameters ( ) - 1 ]
132- )
133- } or
126+ TParameterExNode ( ParameterEx p ) { exists ( toDataFlowCallable ( p .getCallable ( ) ) ) } or
134127 TImplicitArgumentNode ( DataFlowCall call , ImplicitArgumentPosition pos , Boolean isPost ) {
135128 not call .isSummaryCall ( _, _) // represented by TSummaryNode
136129 } or
@@ -140,7 +133,7 @@ newtype TDataFlowNode =
140133
141134class TDataFlowNodeStage1 =
142135 TValueNode or TStrictlyIncomingValue or TExprPostUpdateNode or TLocalVariableRefNode or
143- TReturnNode or TCallableNode or TImplicitParameterNode or TImplicitArgumentNode ;
136+ TReturnNode or TCallableNode or TParameterExNode or TImplicitArgumentNode ;
144137
145138class TDataFlowNodeStage2 = TDataFlowNodeStage1 or TLocalSsaNode ;
146139
@@ -214,26 +207,14 @@ class BuilderNode extends TDataFlowNodeStage1 {
214207 */
215208 predicate isReturnNodeEx ( DataFlowCallable callable ) { this = TReturnNode ( callable ) }
216209
217- /** Holds if this node represents an implicit parameter of `callable`. */
218- predicate isImplicitParameter ( DataFlowCallable callable , ParameterPosition pos ) {
219- this = TImplicitParameterNode ( callable , pos )
220- }
210+ /** Gets the `ParameterEx` associated with this node, if any. */
211+ ParameterEx asParameterEx ( ) { this = TParameterExNode ( result ) }
221212
222213 /** Holds if this node represents an implicit argument to `call` (or its post-update). */
223214 predicate isImplicitArgument ( DataFlowCall call , ImplicitArgumentPosition pos , boolean isPost ) {
224215 this = TImplicitArgumentNode ( call , pos , isPost )
225216 }
226217
227- /**
228- * Holds if this represents the receiver passed to the given callable.
229- *
230- * Note that for non-methods and closures that capture the receiver from the enclosing method,
231- * this node still exists but will typically not flow anywhere.
232- */
233- predicate isReceiverParameter ( Callable callable ) {
234- this .isImplicitParameter ( toDataFlowCallable ( callable ) , any ( ParameterPosition p | p .isReceiver ( ) ) )
235- }
236-
237218 /** Holds if this node represents the receiver argument passed to `call`. */
238219 predicate isReceiverArgumentEx ( DataFlowCall call ) {
239220 this .isImplicitArgument ( call , any ( ArgumentPosition p | p .isReceiver ( ) ) , false )
@@ -318,12 +299,12 @@ class BuilderNode extends TDataFlowNodeStage1 {
318299 result = "[variable " + kind + "] " + v .toString ( )
319300 )
320301 or
302+ exists ( ParameterEx p |
303+ this = TParameterExNode ( p ) and
304+ result = p .toString ( )
305+ )
306+ or
321307 exists ( DataFlowCallable callable |
322- exists ( ParameterPosition pos |
323- this .isImplicitParameter ( callable , pos ) and
324- result = "[" + pos + " param] " + callable .toString ( )
325- )
326- or
327308 this .isCallableEx ( callable ) and
328309 result = "[callable] " + callable .toString ( )
329310 )
@@ -351,11 +332,13 @@ class BuilderNode extends TDataFlowNodeStage1 {
351332 result = repr .getLocation ( )
352333 )
353334 or
335+ exists ( ParameterEx p |
336+ this = TParameterExNode ( p ) and
337+ result = p .getLocation ( )
338+ )
339+ or
354340 exists ( DataFlowCallable callable |
355- this .isImplicitParameter ( callable , _)
356- or
357- this .isCallableEx ( callable )
358- |
341+ this .isCallableEx ( callable ) and
359342 result = callable .getLocation ( )
360343 )
361344 or
@@ -394,10 +377,9 @@ class BuilderNode extends TDataFlowNodeStage1 {
394377 performsVariableAccess ( repr , var , kind , cfgNode )
395378 )
396379 or
380+ cfgNode = this .asParameterEx ( ) .getControlFlowNode ( )
381+ or
397382 exists ( DataFlowCallable callable |
398- this .isImplicitParameter ( callable , _) and
399- cfgNode .( ControlFlow:: EntryNode ) .getEnclosingCallable ( ) = callable .asSourceCallable ( )
400- or
401383 this .isCallableEx ( callable ) and
402384 cfgNode .injects ( callable .asSourceCallable ( ) )
403385 )
@@ -504,7 +486,7 @@ class Node extends TDataFlowNode {
504486 * this node still exists but will typically not flow anywhere.
505487 */
506488 predicate isReceiverParameter ( Callable callable ) {
507- this .( BuilderNode ) .isReceiverParameter ( callable )
489+ this .( BuilderNode ) .asParameterEx ( ) . isImplicitReceiverParameter ( callable )
508490 }
509491
510492 /** Holds if this node represents the receiver argument passed to `call`. */
@@ -575,7 +557,7 @@ class Node extends TDataFlowNode {
575557 result .asSourceCallable ( ) = node .getEnclosingCallable ( )
576558 )
577559 or
578- this .( BuilderNode ) .isImplicitParameter ( result , _ )
560+ result . asSourceCallable ( ) = this .( BuilderNode ) .asParameterEx ( ) . getCallable ( )
579561 or
580562 exists ( DataFlowCall call |
581563 this .( BuilderNode ) .isImplicitArgument ( call , _, _) and
0 commit comments