File tree Expand file tree Collapse file tree
swift/ql/lib/codeql/swift Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1349,17 +1349,21 @@ module Exprs {
13491349 }
13501350 }
13511351
1352+ /** Control-flow for a `TapExpr`. See the QLDoc for `TapExpr` for the semantics of a `TapExpr`. */
13521353 private class TapExprTree extends AstStandardPostOrderTree {
13531354 override TapExpr ast ;
13541355
13551356 final override ControlFlowElement getChildElement ( int i ) {
1357+ // We first visit the local variable declaration.
13561358 i = 0 and
13571359 result .asAstNode ( ) = ast .getVar ( )
13581360 or
1361+ // Then we visit the expression that gives the local variable its initial value.
13591362 i = 1 and
13601363 result .asAstNode ( ) = ast .getSubExpr ( ) .getFullyConverted ( )
13611364 or
1362- // Note: The CFG for the body will skip the first element in the
1365+ // And finally, we visit the body that potentially mutates the local variable.
1366+ // Note that the CFG for the body will skip the first element in the
13631367 // body because it's guarenteed to be the variable declaration
13641368 // that we've already visited at i = 0. See the explanation
13651369 // in `BraceStmtTree` for why this is necessary.
Original file line number Diff line number Diff line change @@ -20,6 +20,14 @@ private module Cached {
2020 cached
2121 predicate defaultAdditionalTaintStep ( DataFlow:: Node nodeFrom , DataFlow:: Node nodeTo ) {
2222 // Flow through one argument of `appendLiteral` and `appendInterpolation` and to the second argument.
23+ // This is needed for string interpolation generated by the compiler. An interpolated string
24+ // like `"I am \(n) years old."` is represented as
25+ // ```
26+ // $interpolated = ""
27+ // appendLiteral(&$interpolated, "I am ")
28+ // appendInterpolation(&$interpolated, n)
29+ // appendLiteral(&$interpolated, " years old.")
30+ // ```
2331 exists ( ApplyExpr apply1 , ApplyExpr apply2 , ExprCfgNode e |
2432 nodeFrom .asExpr ( ) = [ apply1 , apply2 ] .getAnArgument ( ) .getExpr ( ) and
2533 apply1 .getFunction ( ) = apply2 and
Original file line number Diff line number Diff line change 1- // generated by codegen/codegen.py, remove this comment if you wish to edit this file
21private import codeql.swift.generated.expr.TapExpr
32
3+ /**
4+ * A `TapExpr` is an internal expression generated by the Swift compiler.
5+ *
6+ * If `e` is a `TapExpr`, the semantics of evaluating `e` is:
7+ * 1. Create a local variable `e.getVar()` and assign it the value `e.getSubExpr()`.
8+ * 2. Execute `e.getBody()` which potentially modifies the local variable.
9+ * 3. Return the value of the local variable.
10+ */
411class TapExpr extends TapExprBase { }
You can’t perform that action at this time.
0 commit comments