Commit Graph

2155 Commits

Author SHA1 Message Date
Robert Marsh
97815bfa61 Swift: fix implicit this usage 2022-06-09 18:50:40 +00:00
Robert Marsh
755c56dafe Swift: autoformat 2022-06-09 18:50:39 +00:00
Robert Marsh
fca1afa493 Swift: fix inout parameter conflation at return 2022-06-09 17:09:49 +00:00
Robert Marsh
a7663adf90 Swift: add flow through inout parameters 2022-06-09 17:09:49 +00:00
Robert Marsh
21ba73138d Swift: add CallExprCfgNode 2022-06-09 17:09:49 +00:00
Robert Marsh
cb3da0eedd Swift: add some ParamDecl methods 2022-06-09 17:09:48 +00:00
Robert Marsh
776a2965ca Swift: extract isInOut for parameters 2022-06-09 17:09:48 +00:00
Paolo Tranquilli
a0acb19b68 Swift: remove redundant import 2022-06-03 15:28:48 +02:00
Paolo Tranquilli
01e1c13c29 Swift: add UnknownLocation
`getLocation()` will now exists for all entities. When there is no
valid location, the location will still not be emitted in the DB, but
on the QL side we will then assign a special `UnknownLocation` with
empty filename and 0 for line/column start/end.

This unknown location is currently emitted (with a unique `@` key) at
the start of every extraction, but we can move it elsewhere (and
possibly in a unique global trap file) at a later stage, possibly after
or when we rework the trap file strategy.

This should solve flakiness that was observed on the control flow tests,
which is probably caused by the `nodes` predicate in the `TestOutput`
class in `ControlFlowGraphImplShared.qll` not able to assign a proper
rank when the node does not have a location.
2022-06-03 14:59:22 +02:00
Alex Denisov
1dab01a31c Swift: fix ctor/dtor names in toString 2022-06-02 08:28:46 +02:00
Mathias Vorreiter Pedersen
cde2880392 Swift: Add getEnclosingFunction to AstNode. 2022-06-01 16:40:08 +01:00
Mathias Vorreiter Pedersen
7d962ac62b Merge pull request #9397 from MathiasVP/use-autogenerated-parent-in-cfg-library
Swift: Use the autogenerated `getParent`
2022-06-01 14:45:43 +01:00
Mathias Vorreiter Pedersen
eabb5c7137 Swift: Respond to PR comments. 2022-06-01 14:34:22 +01:00
Paolo Tranquilli
3414028b1b Swift: simplify GetImmediateParent.qll 2022-06-01 15:01:49 +02:00
Mathias Vorreiter Pedersen
db0498e38c Swift: Use the autogenerated 'getParent' predicate in the CFG library. 2022-06-01 13:49:12 +01:00
Paolo Tranquilli
6b90b2b05f Swift: add children to IsPattern 2022-06-01 14:35:58 +02:00
Paolo Tranquilli
a4f97dd67a Swift: add comment about unique in getImmediateParent 2022-06-01 14:32:59 +02:00
Paolo Tranquilli
bc0a32c26e Swift: sort import list
Also fix parent tests with updated `statements.swift` file.
2022-06-01 14:32:59 +02:00
Paolo Tranquilli
3597efb728 Swift: rename to getImmediateParent and use hidden AST 2022-06-01 14:32:58 +02:00
Paolo Tranquilli
a86d0fc8a7 Swift: move getAChild to a separate module 2022-06-01 14:32:58 +02:00
Paolo Tranquilli
946e1f498a Swift: generate getParent implementation
By explicitly marking children in the `schema.yml` file, an internal
`getAChild` predicate is implemented, that is in turn used in `AstNode`
to implement `getParent`.

This is yet to be used in the control flow library to replace the
hand-rolled implementation.

A further, more complex step is to use the same information to fully
generate the core implementation of `PrintAst` (including the
accessor string). This will be done later.

The `parent` tests use the same swift code as the extractor tests, and
this is currently enforced by `sync-files.py`. Notice that `qltest.sh`
had to be modified to deal with multiple files, which was not working
yet.
2022-06-01 14:32:58 +02:00
Anders Schack-Mulligen
4f3751dfea Merge pull request #9316 from hvitved/dataflow/edges-get-a-successor-consistency
Data flow: Make `PathGraph::edges/2` and `PathNode::getASuccessor/1` consistent
2022-06-01 10:38:25 +02:00
Paolo Tranquilli
9231013401 Swift: use C++ entry style visitor in DeclVisitor 2022-06-01 08:41:43 +02:00
Robert Marsh
42ec6350eb Merge pull request #9349 from MathiasVP/fix-inconsistent-cfg
Swift: Fix three CFG inconsistencies
2022-05-31 14:38:08 -04:00
Robert Marsh
bd095abea4 Merge pull request #9388 from MathiasVP/cfg-for-yield
Swift: CFG for `yield`
2022-05-31 11:22:21 -04:00
Mathias Vorreiter Pedersen
6386daf44c Merge branch 'main' into fix-inconsistent-cfg 2022-05-31 15:59:53 +01:00
Robert Marsh
78fd0385fc Merge pull request #9355 from MathiasVP/not-all-functions-throw
Swift: Only construct exceptional edges for calls that may throw
2022-05-31 10:56:31 -04:00
Mathias Vorreiter Pedersen
5f9d03f7c6 Swift: CFG for 'yield'. 2022-05-31 15:45:43 +01:00
Geoffrey White
f598b26b03 Merge pull request #9384 from MathiasVP/qlpacks-for-swift
Swift: Add qlpacks
2022-05-31 15:39:20 +01:00
Mathias Vorreiter Pedersen
1d120486b4 Swift: Extract 'yield' statements. 2022-05-31 14:43:09 +01:00
Mathias Vorreiter Pedersen
9af31bab2a Swift: Add qlpacks. 2022-05-31 13:59:44 +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
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
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
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
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