11private import swift
22private import DataFlowPublic
33private import DataFlowDispatch
4+ private import codeql.swift.controlflow.CfgNodes
45
56/** Gets the callable in which this node occurs. */
67DataFlowCallable nodeGetEnclosingCallable ( NodeImpl n ) { result = n .getEnclosingCallable ( ) }
@@ -25,11 +26,19 @@ abstract class NodeImpl extends Node {
2526 abstract string toStringImpl ( ) ;
2627}
2728
29+ private class ExprNodeImpl extends ExprNode , NodeImpl {
30+ override Location getLocationImpl ( ) { result = expr .getLocation ( ) }
31+
32+ override string toStringImpl ( ) { result = expr .toString ( ) }
33+ }
34+
2835/** A collection of cached types and predicates to be evaluated in the same stage. */
2936cached
3037private module Cached {
3138 cached
32- newtype TNode = TODO_TNode ( )
39+ newtype TNode =
40+ TExprNode ( ExprCfgNode e ) or
41+ TNormalParameterNode ( ParamDecl p )
3342
3443 /**
3544 * This is the local flow predicate that is used as a building block in global
@@ -58,6 +67,20 @@ private module ParameterNodes {
5867 abstract class ParameterNodeImpl extends NodeImpl {
5968 predicate isParameterOf ( DataFlowCallable c , ParameterPosition pos ) { none ( ) }
6069 }
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+ }
6184}
6285
6386import ParameterNodes
@@ -173,7 +196,9 @@ class Unit extends TUnit {
173196 */
174197predicate isUnreachableInCall ( Node n , DataFlowCall call ) { none ( ) }
175198
176- newtype LambdaCallKind = TODO_TLambdaCallKind ( )
199+ newtype LambdaCallKind =
200+ TYieldCallKind ( ) or
201+ TLambdaCallKind ( )
177202
178203/** Holds if `creation` is an expression that creates a lambda of kind `kind` for `c`. */
179204predicate lambdaCreation ( Node creation , LambdaCallKind kind , DataFlowCallable c ) { none ( ) }
0 commit comments