mirror of
https://github.com/github/codeql.git
synced 2026-04-28 10:15:14 +02:00
Swift: use ExitNode as CFG for InoutReturnNode
This commit is contained in:
@@ -62,11 +62,7 @@ private module Cached {
|
||||
newtype TNode =
|
||||
TExprNode(ExprCfgNode e) or
|
||||
TSsaDefinitionNode(Ssa::Definition def) or
|
||||
TInoutReturnNode(ParamDecl param, ControlFlowNode exit) {
|
||||
param.isInout() and
|
||||
exit.getScope() = param.getDeclaringFunction() and
|
||||
exit.getNode().asAstNode() instanceof ReturnStmt
|
||||
} or
|
||||
TInoutReturnNode(ParamDecl param) { param.isInout() } or
|
||||
TInOutUpdateNode(ParamDecl param, CallExpr call) {
|
||||
param.isInout() and
|
||||
call.getStaticTarget() = param.getDeclaringFunction()
|
||||
@@ -216,7 +212,11 @@ private module ReturnNodes {
|
||||
ParamDecl param;
|
||||
ControlFlowNode exit;
|
||||
|
||||
InoutReturnNodeImpl() { this = TInoutReturnNode(param, exit) }
|
||||
InoutReturnNodeImpl() {
|
||||
this = TInoutReturnNode(param) and
|
||||
exit instanceof ExitNode and
|
||||
exit.getScope() = param.getDeclaringFunction()
|
||||
}
|
||||
|
||||
override ReturnKind getKind() { result.(ParamReturnKind).getIndex() = param.getIndex() }
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
private import swift
|
||||
private import codeql.swift.controlflow.BasicBlocks as BasicBlocks
|
||||
private import codeql.swift.controlflow.ControlFlowGraph
|
||||
private import codeql.swift.controlflow.CfgNodes
|
||||
|
||||
class BasicBlock = BasicBlocks::BasicBlock;
|
||||
|
||||
@@ -51,8 +52,8 @@ predicate variableRead(BasicBlock bb, int i, SourceVariable v, boolean certain)
|
||||
certain = true
|
||||
)
|
||||
or
|
||||
exists(ReturnStmt return, AbstractFunctionDecl func |
|
||||
bb.getNode(i).getNode().asAstNode() = return and
|
||||
exists(ExitNode exit, AbstractFunctionDecl func |
|
||||
bb.getNode(i) = exit and
|
||||
v.(ParamDecl).isInout() and
|
||||
func.getAParam() = v and
|
||||
bb.getScope() = func and
|
||||
|
||||
@@ -12,18 +12,22 @@ edges
|
||||
| test.swift:29:26:29:29 | y : | test.swift:31:15:31:15 | y |
|
||||
| test.swift:35:12:35:19 | call to source : | test.swift:39:15:39:29 | call to callee_source |
|
||||
| test.swift:43:19:43:26 | call to source : | test.swift:50:15:50:15 | t |
|
||||
| test.swift:54:11:54:18 | call to source : | test.swift:55:5:55:5 | arg[return] : |
|
||||
| test.swift:55:5:55:5 | arg[return] : | test.swift:61:5:61:24 | arg : |
|
||||
| test.swift:53:1:56:1 | arg[return] : | test.swift:61:5:61:24 | arg : |
|
||||
| test.swift:54:11:54:18 | call to source : | test.swift:53:1:56:1 | arg[return] : |
|
||||
| test.swift:61:5:61:24 | arg : | test.swift:62:15:62:15 | x |
|
||||
| test.swift:65:16:65:28 | WriteDef : | test.swift:69:5:69:5 | arg2[return] : |
|
||||
| test.swift:65:16:65:28 | arg1 : | test.swift:69:5:69:5 | arg2[return] : |
|
||||
| test.swift:65:16:65:28 | WriteDef : | test.swift:65:1:70:1 | arg2[return] : |
|
||||
| test.swift:65:16:65:28 | arg1 : | test.swift:65:1:70:1 | arg2[return] : |
|
||||
| test.swift:73:18:73:25 | call to source : | test.swift:75:21:75:22 | &... : |
|
||||
| test.swift:75:5:75:33 | arg2 : | test.swift:77:15:77:15 | y |
|
||||
| test.swift:75:21:75:22 | &... : | test.swift:65:16:65:28 | WriteDef : |
|
||||
| test.swift:75:21:75:22 | &... : | test.swift:65:16:65:28 | arg1 : |
|
||||
| test.swift:75:21:75:22 | &... : | test.swift:75:5:75:33 | arg2 : |
|
||||
| test.swift:86:15:86:22 | call to source : | test.swift:87:9:87:9 | arg[return] : |
|
||||
| test.swift:87:9:87:9 | arg[return] : | test.swift:104:9:104:54 | arg : |
|
||||
| test.swift:80:1:82:1 | arg[return] : | test.swift:97:9:97:41 | arg : |
|
||||
| test.swift:81:11:81:18 | call to source : | test.swift:80:1:82:1 | arg[return] : |
|
||||
| test.swift:84:1:91:1 | arg[return] : | test.swift:104:9:104:54 | arg : |
|
||||
| test.swift:86:15:86:22 | call to source : | test.swift:84:1:91:1 | arg[return] : |
|
||||
| test.swift:89:15:89:22 | call to source : | test.swift:84:1:91:1 | arg[return] : |
|
||||
| test.swift:97:9:97:41 | arg : | test.swift:98:19:98:19 | x |
|
||||
| test.swift:104:9:104:54 | arg : | test.swift:105:19:105:19 | x |
|
||||
nodes
|
||||
| test.swift:6:19:6:26 | call to source : | semmle.label | call to source : |
|
||||
@@ -46,26 +50,31 @@ nodes
|
||||
| test.swift:39:15:39:29 | call to callee_source | semmle.label | call to callee_source |
|
||||
| test.swift:43:19:43:26 | call to source : | semmle.label | call to source : |
|
||||
| test.swift:50:15:50:15 | t | semmle.label | t |
|
||||
| test.swift:53:1:56:1 | arg[return] : | semmle.label | arg[return] : |
|
||||
| test.swift:54:11:54:18 | call to source : | semmle.label | call to source : |
|
||||
| test.swift:55:5:55:5 | arg[return] : | semmle.label | arg[return] : |
|
||||
| test.swift:61:5:61:24 | arg : | semmle.label | arg : |
|
||||
| test.swift:62:15:62:15 | x | semmle.label | x |
|
||||
| test.swift:65:1:70:1 | arg2[return] : | semmle.label | arg2[return] : |
|
||||
| test.swift:65:16:65:28 | WriteDef : | semmle.label | WriteDef : |
|
||||
| test.swift:65:16:65:28 | WriteDef : | semmle.label | arg1 : |
|
||||
| test.swift:65:16:65:28 | arg1 : | semmle.label | WriteDef : |
|
||||
| test.swift:65:16:65:28 | arg1 : | semmle.label | arg1 : |
|
||||
| test.swift:69:5:69:5 | arg2[return] : | semmle.label | arg2[return] : |
|
||||
| test.swift:73:18:73:25 | call to source : | semmle.label | call to source : |
|
||||
| test.swift:75:5:75:33 | arg2 : | semmle.label | arg2 : |
|
||||
| test.swift:75:21:75:22 | &... : | semmle.label | &... : |
|
||||
| test.swift:77:15:77:15 | y | semmle.label | y |
|
||||
| test.swift:80:1:82:1 | arg[return] : | semmle.label | arg[return] : |
|
||||
| test.swift:81:11:81:18 | call to source : | semmle.label | call to source : |
|
||||
| test.swift:84:1:91:1 | arg[return] : | semmle.label | arg[return] : |
|
||||
| test.swift:86:15:86:22 | call to source : | semmle.label | call to source : |
|
||||
| test.swift:87:9:87:9 | arg[return] : | semmle.label | arg[return] : |
|
||||
| test.swift:89:15:89:22 | call to source : | semmle.label | call to source : |
|
||||
| test.swift:97:9:97:41 | arg : | semmle.label | arg : |
|
||||
| test.swift:98:19:98:19 | x | semmle.label | x |
|
||||
| test.swift:104:9:104:54 | arg : | semmle.label | arg : |
|
||||
| test.swift:105:19:105:19 | x | semmle.label | x |
|
||||
subpaths
|
||||
| test.swift:75:21:75:22 | &... : | test.swift:65:16:65:28 | WriteDef : | test.swift:69:5:69:5 | arg2[return] : | test.swift:75:5:75:33 | arg2 : |
|
||||
| test.swift:75:21:75:22 | &... : | test.swift:65:16:65:28 | arg1 : | test.swift:69:5:69:5 | arg2[return] : | test.swift:75:5:75:33 | arg2 : |
|
||||
| test.swift:75:21:75:22 | &... : | test.swift:65:16:65:28 | WriteDef : | test.swift:65:1:70:1 | arg2[return] : | test.swift:75:5:75:33 | arg2 : |
|
||||
| test.swift:75:21:75:22 | &... : | test.swift:65:16:65:28 | arg1 : | test.swift:65:1:70:1 | arg2[return] : | test.swift:75:5:75:33 | arg2 : |
|
||||
#select
|
||||
| test.swift:7:15:7:15 | t1 | test.swift:6:19:6:26 | call to source : | test.swift:7:15:7:15 | t1 | result |
|
||||
| test.swift:9:15:9:15 | t1 | test.swift:6:19:6:26 | call to source : | test.swift:9:15:9:15 | t1 | result |
|
||||
@@ -76,4 +85,6 @@ subpaths
|
||||
| test.swift:50:15:50:15 | t | test.swift:43:19:43:26 | call to source : | test.swift:50:15:50:15 | t | result |
|
||||
| test.swift:62:15:62:15 | x | test.swift:54:11:54:18 | call to source : | test.swift:62:15:62:15 | x | result |
|
||||
| test.swift:77:15:77:15 | y | test.swift:73:18:73:25 | call to source : | test.swift:77:15:77:15 | y | result |
|
||||
| test.swift:98:19:98:19 | x | test.swift:81:11:81:18 | call to source : | test.swift:98:19:98:19 | x | result |
|
||||
| test.swift:105:19:105:19 | x | test.swift:86:15:86:22 | call to source : | test.swift:105:19:105:19 | x | result |
|
||||
| test.swift:105:19:105:19 | x | test.swift:89:15:89:22 | call to source : | test.swift:105:19:105:19 | x | result |
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
| test.swift:48:9:48:13 | WriteDef | test.swift:50:5:50:5 | Phi |
|
||||
| test.swift:48:13:48:13 | 1 | test.swift:48:9:48:13 | WriteDef |
|
||||
| test.swift:50:5:50:5 | Phi | test.swift:50:15:50:15 | t |
|
||||
| test.swift:54:5:54:18 | WriteDef | test.swift:55:5:55:5 | arg[return] |
|
||||
| test.swift:54:5:54:18 | WriteDef | test.swift:53:1:56:1 | arg[return] |
|
||||
| test.swift:54:11:54:18 | call to source | test.swift:54:5:54:18 | WriteDef |
|
||||
| test.swift:59:9:59:12 | WriteDef | test.swift:60:15:60:15 | x |
|
||||
| test.swift:59:18:59:18 | 0 | test.swift:59:9:59:12 | WriteDef |
|
||||
@@ -37,9 +37,9 @@
|
||||
| test.swift:65:33:65:45 | arg2 | test.swift:67:12:67:12 | arg2 |
|
||||
| test.swift:66:9:66:15 | WriteDef | test.swift:68:12:68:12 | temp |
|
||||
| test.swift:66:21:66:21 | arg1 | test.swift:66:9:66:15 | WriteDef |
|
||||
| test.swift:67:5:67:12 | WriteDef | test.swift:69:5:69:5 | arg1[return] |
|
||||
| test.swift:67:5:67:12 | WriteDef | test.swift:65:1:70:1 | arg1[return] |
|
||||
| test.swift:67:12:67:12 | arg2 | test.swift:67:5:67:12 | WriteDef |
|
||||
| test.swift:68:5:68:12 | WriteDef | test.swift:69:5:69:5 | arg2[return] |
|
||||
| test.swift:68:5:68:12 | WriteDef | test.swift:65:1:70:1 | arg2[return] |
|
||||
| test.swift:68:12:68:12 | temp | test.swift:68:5:68:12 | WriteDef |
|
||||
| test.swift:73:9:73:12 | WriteDef | test.swift:75:22:75:22 | x |
|
||||
| test.swift:73:18:73:25 | call to source | test.swift:73:9:73:12 | WriteDef |
|
||||
@@ -51,10 +51,15 @@
|
||||
| test.swift:75:5:75:33 | arg2 | test.swift:75:5:75:33 | WriteDef |
|
||||
| test.swift:75:22:75:22 | x | test.swift:75:21:75:22 | &... |
|
||||
| test.swift:75:32:75:32 | y | test.swift:75:31:75:32 | &... |
|
||||
| test.swift:81:5:81:18 | WriteDef | test.swift:80:1:82:1 | arg[return] |
|
||||
| test.swift:81:11:81:18 | call to source | test.swift:81:5:81:18 | WriteDef |
|
||||
| test.swift:84:1:91:1 | Phi | test.swift:84:1:91:1 | arg[return] |
|
||||
| test.swift:84:48:84:54 | WriteDef | test.swift:85:8:85:8 | bool |
|
||||
| test.swift:84:48:84:54 | bool | test.swift:85:8:85:8 | bool |
|
||||
| test.swift:86:9:86:22 | WriteDef | test.swift:87:9:87:9 | arg[return] |
|
||||
| test.swift:86:9:86:22 | WriteDef | test.swift:84:1:91:1 | Phi |
|
||||
| test.swift:86:15:86:22 | call to source | test.swift:86:9:86:22 | WriteDef |
|
||||
| test.swift:89:9:89:22 | WriteDef | test.swift:84:1:91:1 | Phi |
|
||||
| test.swift:89:15:89:22 | call to source | test.swift:89:9:89:22 | WriteDef |
|
||||
| test.swift:93:17:93:23 | WriteDef | test.swift:104:50:104:50 | bool |
|
||||
| test.swift:93:17:93:23 | bool | test.swift:104:50:104:50 | bool |
|
||||
| test.swift:95:13:95:16 | WriteDef | test.swift:96:19:96:19 | x |
|
||||
|
||||
Reference in New Issue
Block a user