@@ -318,14 +318,10 @@ newtype TDataFlowCallable =
318
318
* class instantiations, and (in the future) special methods.
319
319
*/
320
320
TFunction ( Function func ) {
321
- // For generators/list-comprehensions we create a synthetic function. In the
322
- // points-to call-graph these were not considered callable, and instead we added
323
- // data-flow steps (read/write) for these. As an easy solution for now, we do the
324
- // same to keep things easy to reason about (and therefore exclude things that do
325
- // not have a definition)
321
+ // Functions with an explicit definition
326
322
exists ( func .getDefinition ( ) )
327
323
or
328
- // ...scratch that, variable capture requires a callable
324
+ // For generators/list-comprehensions we create a synthetic function.
329
325
exists ( Comp c | c .getFunction ( ) = func )
330
326
} or
331
327
/** see QLDoc for `DataFlowModuleScope` for why we need this. */
@@ -1389,6 +1385,7 @@ private predicate sameEnclosingCallable(Node node1, Node node2) {
1389
1385
// =============================================================================
1390
1386
newtype TDataFlowCall =
1391
1387
TNormalCall ( CallNode call , Function target , CallType type ) { resolveCall ( call , target , type ) } or
1388
+ /** A call to the generated function inside a comprhension */
1392
1389
TComprehensionCall ( Comp c ) or
1393
1390
TPotentialLibraryCall ( CallNode call ) or
1394
1391
/** A synthesized call inside a summarized callable */
@@ -1476,6 +1473,7 @@ class NormalCall extends ExtractedDataFlowCall, TNormalCall {
1476
1473
CallType getCallType ( ) { result = type }
1477
1474
}
1478
1475
1476
+ /** A call to the generated function inside a comprhension */
1479
1477
class ComprehensionCall extends ExtractedDataFlowCall , TComprehensionCall {
1480
1478
Comp c ;
1481
1479
Function target ;
@@ -1733,23 +1731,10 @@ class CapturedVariablesArgumentNode extends CfgNode, ArgumentNode {
1733
1731
}
1734
1732
}
1735
1733
1736
- class ComprehensionCapturedVariablesArgumentNode extends Node , ArgumentNode {
1737
- Comp comp ;
1738
-
1739
- ComprehensionCapturedVariablesArgumentNode ( ) {
1740
- this = TSynthCompCapturedVariablesArgumentNode ( comp ) and
1741
- exists ( Function target | target = comp .getFunction ( ) |
1742
- target = any ( VariableCapture:: CapturedVariable v ) .getACapturingScope ( )
1743
- )
1744
- }
1745
-
1746
- override predicate argumentOf ( DataFlowCall call , ArgumentPosition pos ) {
1747
- call .( ComprehensionCall ) .getComprehension ( ) = comp and
1748
- pos .isLambdaSelf ( )
1749
- }
1750
- }
1751
-
1752
- class SynthCompCapturedVariablesArgumentNode extends Node , TSynthCompCapturedVariablesArgumentNode {
1734
+ /** A synthetic node representing the values of variables captured by a comprehension. */
1735
+ class SynthCompCapturedVariablesArgumentNode extends Node , TSynthCompCapturedVariablesArgumentNode ,
1736
+ ArgumentNode
1737
+ {
1753
1738
Comp comp ;
1754
1739
1755
1740
SynthCompCapturedVariablesArgumentNode ( ) { this = TSynthCompCapturedVariablesArgumentNode ( comp ) }
@@ -1761,8 +1746,14 @@ class SynthCompCapturedVariablesArgumentNode extends Node, TSynthCompCapturedVar
1761
1746
override Location getLocation ( ) { result = comp .getLocation ( ) }
1762
1747
1763
1748
Comp getComprehension ( ) { result = comp }
1749
+
1750
+ override predicate argumentOf ( DataFlowCall call , ArgumentPosition pos ) {
1751
+ call .( ComprehensionCall ) .getComprehension ( ) = comp and
1752
+ pos .isLambdaSelf ( )
1753
+ }
1764
1754
}
1765
1755
1756
+ /** A synthetic node representing the values of variables captured by a comprehension after the output has been computed. */
1766
1757
class SynthCompCapturedVariablesArgumentPostUpdateNode extends PostUpdateNodeImpl ,
1767
1758
TSynthCompCapturedVariablesArgumentPostUpdateNode
1768
1759
{
0 commit comments