1
1
private import swift
2
2
private import DataFlowPublic
3
3
private import DataFlowDispatch
4
+ private import codeql.swift.controlflow.CfgNodes
4
5
5
6
/** Gets the callable in which this node occurs. */
6
7
DataFlowCallable nodeGetEnclosingCallable ( NodeImpl n ) { result = n .getEnclosingCallable ( ) }
@@ -25,11 +26,19 @@ abstract class NodeImpl extends Node {
25
26
abstract string toStringImpl ( ) ;
26
27
}
27
28
29
+ private class ExprNodeImpl extends ExprNode , NodeImpl {
30
+ override Location getLocationImpl ( ) { result = expr .getLocation ( ) }
31
+
32
+ override string toStringImpl ( ) { result = expr .toString ( ) }
33
+ }
34
+
28
35
/** A collection of cached types and predicates to be evaluated in the same stage. */
29
36
cached
30
37
private module Cached {
31
38
cached
32
- newtype TNode = TODO_TNode ( )
39
+ newtype TNode =
40
+ TExprNode ( ExprCfgNode e ) or
41
+ TNormalParameterNode ( ParamDecl p )
33
42
34
43
/**
35
44
* This is the local flow predicate that is used as a building block in global
@@ -58,6 +67,20 @@ private module ParameterNodes {
58
67
abstract class ParameterNodeImpl extends NodeImpl {
59
68
predicate isParameterOf ( DataFlowCallable c , ParameterPosition pos ) { none ( ) }
60
69
}
70
+
71
+ class NormalParameterNode extends ParameterNodeImpl , TNormalParameterNode {
72
+ ParamDecl param ;
73
+
74
+ NormalParameterNode ( ) { this = TNormalParameterNode ( param ) }
75
+
76
+ override Location getLocationImpl ( ) { result = param .getLocation ( ) }
77
+
78
+ override string toStringImpl ( ) { result = param .toString ( ) }
79
+
80
+ override predicate isParameterOf ( DataFlowCallable c , ParameterPosition pos ) {
81
+ none ( ) // TODO
82
+ }
83
+ }
61
84
}
62
85
63
86
import ParameterNodes
@@ -173,7 +196,9 @@ class Unit extends TUnit {
173
196
*/
174
197
predicate isUnreachableInCall ( Node n , DataFlowCall call ) { none ( ) }
175
198
176
- newtype LambdaCallKind = TODO_TLambdaCallKind ( )
199
+ newtype LambdaCallKind =
200
+ TYieldCallKind ( ) or
201
+ TLambdaCallKind ( )
177
202
178
203
/** Holds if `creation` is an expression that creates a lambda of kind `kind` for `c`. */
179
204
predicate lambdaCreation ( Node creation , LambdaCallKind kind , DataFlowCallable c ) { none ( ) }
0 commit comments