Commit Graph

4433 Commits

Author SHA1 Message Date
Mathias Vorreiter Pedersen
9175354bbd Swift: Add test and accept changes. 2022-05-30 15:51:49 +01:00
Mathias Vorreiter Pedersen
52f0b0d8d8 Swift: Fix extraction of roots in 'KeyPathExpr'. 2022-05-30 15:46:54 +01:00
Mathias Vorreiter Pedersen
21527f66e1 Swift: Extract KeyPath applications and KeyPathDot expressions. 2022-05-30 15:46:18 +01:00
Mathias Vorreiter Pedersen
d8916568b6 Merge branch 'main' into fix-inconsistent-cfg 2022-05-30 14:07:10 +01:00
Mathias Vorreiter Pedersen
9b17493b3b Merge branch 'main' into not-all-functions-throw 2022-05-30 14:03:29 +01:00
Mathias Vorreiter Pedersen
ef31aec29e Swift: Autoformat. 2022-05-30 12:58:12 +01:00
Mathias Vorreiter Pedersen
425d66e454 Update swift/ql/lib/codeql/swift/dataflow/internal/DataFlowPrivate.qll 2022-05-30 12:52:48 +01:00
Mathias Vorreiter Pedersen
2106d48785 Swift: Add 'Argument.getIndex()' and use it in 'DataFlowDispatch'. 2022-05-30 12:51:29 +01:00
Mathias Vorreiter Pedersen
0d8a9458c6 Merge branch 'main' into rdmarsh2/swift/dataflow-global-flow 2022-05-30 12:46:06 +01:00
Mathias Vorreiter Pedersen
7c25063f7f Merge branch 'main' into swift-decls-in-cfg 2022-05-27 17:56:58 +01:00
Mathias Vorreiter Pedersen
c734646099 Swift: Accept test changes. 2022-05-27 17:42:51 +01:00
Mathias Vorreiter Pedersen
6d5504412a Swift: Only create a 'ThrowCompletion' for functions that actually can throw. 2022-05-27 17:42:51 +01:00
Mathias Vorreiter Pedersen
b9809b4219 Swift: CFG for opening existentials. 2022-05-27 17:29:22 +01:00
Mathias Vorreiter Pedersen
02c73d3c1c Swift: Fix implicit-this alert. 2022-05-27 17:25:56 +01:00
Mathias Vorreiter Pedersen
6815e731d2 Swift: Add test and accept output 2022-05-27 11:48:20 +01:00
Mathias Vorreiter Pedersen
45bbd24355 Swift: Extract whether a function type is throwing or async. 2022-05-27 11:48:01 +01:00
Mathias Vorreiter Pedersen
7d36bc1c73 Swift: Fix CFG for 'foreach' statements. 2022-05-27 10:01:12 +01:00
Mathias Vorreiter Pedersen
73c189957d Swift: Fix CFG inconsistencies with StmtConditions. 2022-05-27 09:58:36 +01:00
Mathias Vorreiter Pedersen
795c0110e5 Swift: Accept more test changes. 2022-05-27 09:17:52 +01:00
Mathias Vorreiter Pedersen
52a10c826a Merge branch 'main' into swift-to-string 2022-05-27 09:06:36 +01:00
Robert Marsh
32e4c496f6 Swift: Dataflow through Phi nodes 2022-05-26 17:55:25 +00:00
Robert Marsh
507fdef028 Swift: add more data flow tests 2022-05-26 17:33:12 +00:00
Robert Marsh
81ac648065 Swift: flow out of calls via return statements 2022-05-26 16:58:53 +00:00
Robert Marsh
ae6d16a40f Swift: flow into callees via params 2022-05-26 16:53:42 +00:00
Robert Marsh
25c8b8141c Swift: add params to CFG 2022-05-26 16:48:24 +00:00
Robert Marsh
3213549a73 Merge pull request #9329 from MathiasVP/fixes-for-9291
Swift: Fixups for #9291
2022-05-26 07:25:24 -04:00
Mathias Vorreiter Pedersen
df2c1972e9 Swift: Add CFG trees for local declarations and accept test changes. 2022-05-26 09:09:17 +01:00
Mathias Vorreiter Pedersen
b715a6b63b Swift: Add test containing local declarations. 2022-05-26 09:06:13 +01:00
Mathias Vorreiter Pedersen
c7cc8d2592 Swift: Fix copy-paste error. 2022-05-25 21:36:24 +01:00
Robert Marsh
aa77ea6bef Swift: minimal tests for interprocedural flow 2022-05-25 19:24:34 +00:00
Robert Marsh
9f64622f31 Swift: data flow configurations working 2022-05-25 19:23:43 +00:00
Robert Marsh
d326b3a91c Swift: global dataflow WIP 2022-05-25 18:54:47 +00:00
Robert Marsh
bba3564187 Swift: adjust for changes in main 2022-05-25 18:52:47 +00:00
Robert Marsh
91b34d5e8f Swift: make LambdaCallKind a TODO 2022-05-25 18:26:38 +00:00
Robert Marsh
765e1e1115 Swift: autoformat 2022-05-25 18:26:38 +00:00
Robert Marsh
cf22ade9f3 Swift: initial local data flow implementation 2022-05-25 18:26:37 +00:00
Robert Marsh
117a1ad2f4 Swift: DataFlow expr and parameter nodes 2022-05-25 18:26:37 +00:00
Mathias Vorreiter Pedersen
fafdb016fa Swift: Fixup based on review comments in #9291. 2022-05-25 16:10:44 +01:00
Mathias Vorreiter Pedersen
f17afa8a11 Swift: Accept test changes. 2022-05-25 16:01:42 +01:00
Mathias Vorreiter Pedersen
dc2ba5b410 Swift: Implement better 'toString' overrides for all AST nodes. 2022-05-25 15:59:45 +01:00
Mathias Vorreiter Pedersen
80fad348bb Swift: Implement CFG for property reads, writes, and observers. 2022-05-25 13:46:14 +01:00
Mathias Vorreiter Pedersen
67cc1b503b Swift: Implement step 3 from the previous commit message. 2022-05-25 13:44:59 +01:00
Mathias Vorreiter Pedersen
1f4924f978 Swift: Create a custom "AST" version of the public CFG classes. This is
necessary because the CFG library doesn't support the following
       two requirements simultaneously:
       1. Traverse AST classes by virtual dispatch
       2. Construct ControlFlowElements from non-AST classes

       Because the CFG trees derive from the a base type that must be a
       subtype of `ControlFlowElement`. So if we make `ControlFlowElement`
       an IPA type, we cannot write:
       ```
       class AssignTree extends PostOrderTree instanceof AssignExpr { ... }
       ```
       because `AssignExpr` is not a subtype of PostOrderTree (since
       PostOrderTree is now a subtype of the new IPA type).

       To fix this, Tom suggested the following (which is implemented in
       this PR):
       1. Create a copy of the CFG tree classes (i.e., Pre/PostOrderTree,
          LeafTree, etc.) and call them AstPreOrderTree/AstPostOrderTree,
          AstLeafTree, etc.
       2. For each tree AstTree from step 1, create a instance of the
          internal CFG library's appropriate class.
       3. In `ControlFlowGraphImpl`, proceed as normal with virtual
          dispatch using `instanceof`, but extend the AstTree classes
          from step 1 instead of the CFG's own tree classes.

       This works because each AstTree implements one of the CFG
       library's tree classes (as per step 2).
       This commit performs step 1 and 2. Step 3 will be the next commit.
2022-05-25 13:39:48 +01:00
Mathias Vorreiter Pedersen
ab268514a1 Swift: Create a custom IPA type for 'ControlFlowElement's and fixup various type annotations. 2022-05-25 13:39:48 +01:00
Tom Hvitved
bcdef98392 Data flow: Sync files 2022-05-25 14:39:37 +02:00
AlexDenisov
8b131adeb1 Merge pull request #9283 from github/alexdenisov/swift-integration-tests
Swift: add integration tests
2022-05-25 10:04:08 +02:00
Michael Nebel
5f3a039c65 Swift: Sync changes to DataFlowImplCommon from PR #9024. 2022-05-25 08:05:22 +02:00
Robert Marsh
8cc509e5e9 Merge pull request #9275 from MathiasVP/swift-add-dataflow-lib
Swift: Add shared dataflow library
2022-05-24 15:11:42 -04:00
Alex Denisov
fa09078976 Swift: do not keep trap files for tests 2022-05-24 11:48:45 +02:00
Alex Denisov
8e8da66325 Swift: share .gitignore across all tests 2022-05-24 11:48:06 +02:00