@@ -1342,11 +1342,15 @@ class LibraryCodeNode extends Node, TLibraryCodeNode {
13421342 Node getPredecessor ( AccessPath ap ) {
13431343 ap = sourceAp and
13441344 (
1345+ // The source is either an argument or a qualifier, for example
1346+ // `s` in `int.Parse(s)`
13451347 exists ( LibraryFlow:: LibrarySourceConfiguration x , Call call |
13461348 callCfn = call .getAControlFlowNode ( ) and
13471349 x .hasExprPath ( source .getSource ( call ) , result .( ExprNode ) .getControlFlowNode ( ) , _, callCfn )
13481350 )
13491351 or
1352+ // The source is the output of a supplied delegate argument, for
1353+ // example the output of `Foo` in `new Lazy(Foo)`
13501354 exists ( DataFlowCall call , int pos |
13511355 pos = source .( CallableFlowSourceDelegateArg ) .getArgumentIndex ( ) and
13521356 result .( ImplicitDelegateOutNode ) .isArgumentOf ( call , pos ) and
@@ -1366,15 +1370,19 @@ class LibraryCodeNode extends Node, TLibraryCodeNode {
13661370 callCfn = call .getAControlFlowNode ( ) and
13671371 x .hasExprPath ( _, callCfn , sink .getSink ( call ) , e .getControlFlowNode ( ) )
13681372 |
1373+ // The sink is an ordinary return value, for example `int.Parse(s)`
13691374 sink instanceof CallableFlowSinkReturn and
13701375 result = e
13711376 or
1377+ // The sink is a qualifier, for example `list` in `list.Add(x)`
13721378 sink instanceof CallableFlowSinkQualifier and
13731379 if sinkAp = AccessPath:: empty ( )
13741380 then result = e
13751381 else result .( ExprPostUpdateNode ) .getPreUpdateNode ( ) = e
13761382 )
13771383 or
1384+ // The sink is an `out`/`ref` argument, for example `out i` in
1385+ // `int.TryParse(s, out i)`
13781386 exists ( LibraryFlow:: LibrarySinkConfiguration x , OutRefReturnKind k |
13791387 result =
13801388 any ( ParamOutNode out |
@@ -1384,13 +1392,22 @@ class LibraryCodeNode extends Node, TLibraryCodeNode {
13841392 )
13851393 )
13861394 or
1387- exists ( DataFlowCall call , ImplicitDelegateDataFlowCall dcall , int i , int j |
1395+ // The sink is a parameter of a supplied delegate argument, for example
1396+ // the parameter of `Foo` in `list.Select(Foo)`.
1397+ //
1398+ // This is implemented using a node that represents the implicit argument
1399+ // (`ImplicitDelegateArgumentNode`) of the implicit call
1400+ // (`ImplicitDelegateDataFlowCall`) to `Foo`.
1401+ exists (
1402+ DataFlowCall call , ImplicitDelegateDataFlowCall dcall , int delegateIndex , int parameterIndex
1403+ |
13881404 sink =
13891405 any ( CallableFlowSinkDelegateArg s |
1390- i = s .getDelegateIndex ( ) and j = s .getDelegateParameterIndex ( )
1406+ delegateIndex = s .getDelegateIndex ( ) and
1407+ parameterIndex = s .getDelegateParameterIndex ( )
13911408 ) and
1392- result = TImplicitDelegateArgumentNode ( dcall .getControlFlowNode ( ) , _, j ) and
1393- dcall .isArgumentOf ( call , i ) and
1409+ result = TImplicitDelegateArgumentNode ( dcall .getControlFlowNode ( ) , _, parameterIndex ) and
1410+ dcall .isArgumentOf ( call , delegateIndex ) and
13941411 callCfn = call .getControlFlowNode ( )
13951412 )
13961413 )
0 commit comments