Commit Graph

4492 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
8d4830cd23 Swift: make dataflow test a path-problem 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
8b52bb0c31 Swift: build x86_64 on arm64 macOS
This is a temporary workaround. At a later stage we will add
* a Swift/LLVM prebuilt package for arm64
* universal binary for the extractor
2022-06-08 10:25:38 +02: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
AlexDenisov
0a861ff616 Merge pull request #9410 from github/alexdenisov/swift-extract-only-primary-files
Swift: extract only primary files
2022-06-03 10:44:18 +02:00
Alex Denisov
14384b7696 Swift: switch back to references 2022-06-03 10:22:25 +02:00
Paolo Tranquilli
87234938ef Swift: correct typo 2022-06-03 08:45:59 +02:00
Robert Marsh
43907b6a30 Merge pull request #9409 from github/alexdenisov/swift-fix-ctor-dtor-tostring
Swift: fix ctor/dtor names in toString
2022-06-02 10:34:03 -04:00
Paolo Tranquilli
ede6bd8ffe Swift: document and partially simplify codegen
This adds:
* a base `README.md` file to `codegen`
* module docstrings for the modules in `generators`
* help strings on all command line flags

Moreover some unneeded command line flags (`--namespace`,
`--include-dir` and `--trap-affix`) have been dropped.
2022-06-02 15:28:57 +02:00
Paolo Tranquilli
c9d109ddd3 Revert "Swift: Control-flow for key paths" 2022-06-02 14:55:52 +02:00
Mathias Vorreiter Pedersen
927aceb420 Merge pull request #9373 from MathiasVP/cfg-for-key-paths 2022-06-02 08:32:29 +01:00
Alex Denisov
6419af39f3 Swift: extract only primary files
While the (removed) comment is correct and the frontend can be called in
different modes, both `swift build` and `xcodebuild` always use
`-primary-files` when compiling Swift projects.
The other mode was present only within our test runner (`qltest.sh`), so
removing it and doing what the official build systems do simplifies our
code base.

Additionally, file archival is now a separate function/operation.
2022-06-02 08:57:03 +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
Paolo Tranquilli
77f7fe8dbc Swift: merge codegen and cppcodegen
Python code was simplified, and now a `--generate` option can be used
to drive what can be generated.

The extractor pack creation now will use an internally generated
dbscheme. This should be the same as the checked in one, but doing so
allows `bazel run create-extractor-pack` and `bazel run codegen` to be
run independently from one another, while previously the former had to
follow the latter in case of a schema change. This is the change that
triggered the above simplification, as in order for the two dbscheme
files to be identical, the first `// generated` line had to state the
same generator script.
2022-06-01 17:07:52 +02: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
a894ba64c4 Swift: make test run in Python 3.8 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
Paolo Tranquilli
4d6c8da74b Swift: no perfect forwarding for label fetchers
While we need universal references to catch different value categories,
we don't need perfect forwarding as `fetchLabel` does not behave
differently on lvalue and rvalues.
2022-06-01 11:26:21 +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
6e44a12a67 Swift: make enable_if_t a non-type parameter
This disallows completely calling the disabled function (which could
be done by explicitly providing `void` otherwise).
2022-06-01 08:47:53 +02:00
Paolo Tranquilli
905cc23719 Swift: update comment 2022-06-01 08:41:43 +02:00
Paolo Tranquilli
19f16678ac Swift: change translation signature and detection
Translation now takes const references to swift entities and return
trap entries (instead of taking apointer as an out parameter).
2022-06-01 08:41:43 +02:00
Paolo Tranquilli
c3cb0d6ad7 Swift: fix name extraction in VarDecl 2022-06-01 08:41:43 +02:00
Paolo Tranquilli
86b4f16b3a Swift: remove Binding<> class
That class was meant to allow aggregate initialization of generated
C++ entries having the label `id` as first argument.

As aggregate initialization turned out to be undesirable (names of
fields are not explicit, and `{}` must be inserted for empty
superclasses), this commit removes it and disallows aggregate
initialization altogether by defining empty constructors for generated
classes.
2022-06-01 08:41:43 +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
Mathias Vorreiter Pedersen
e2ddfcd437 Merge pull request #9387 from github/geoffw0-patch-2
Swift: Update readme
2022-05-31 16:34:17 +01: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
a175f49759 Merge pull request #3 from geoffw0/swiftsrc
Swift: Add swift-security-and-quality, swift-security-extended packs.
2022-05-31 15:02:33 +01:00
Mathias Vorreiter Pedersen
b5d229d4d8 Apply suggestions from code review
Co-authored-by: Geoffrey White <40627776+geoffw0@users.noreply.github.com>
2022-05-31 15:01:36 +01:00