Commit Graph

560 Commits

Author SHA1 Message Date
Paolo Tranquilli
3ed783df7f Swift: fix tests 2022-06-22 12:14:47 +02:00
Paolo Tranquilli
ee5c30ebda Merge main into redsun82/swift-extraction 2022-06-22 11:11:20 +02:00
Paolo Tranquilli
1e4ac44362 Swift: some expression extractions 2022-06-21 17:31:40 +02:00
Paolo Tranquilli
c77fc26c69 Swift: Callable abstraction
This new class encompasses both `AbstractFunctionDecl` and
`AbstractClosureExpr`, together with their common parts (namely
parameters and the body).

`ClosureExpr` and `AutoClosureExpr` got ported to structured C++
generated translation in the process.
2022-06-21 15:50:35 +02:00
Paolo Tranquilli
3d222a7377 Merge main into redsun82/swift-use-generated-classes 2022-06-20 18:02:13 +02:00
Paolo Tranquilli
48584a6c2e Merge main into redsun82/swift-use-generated-classes 2022-06-20 17:53:21 +02:00
Mathias Vorreiter Pedersen
850a90d9a8 Swift: Change the declaration names generated by the extractor to match the output of the Swift compiler. 2022-06-20 14:57:16 +01:00
Alex Denisov
42dc6814f0 Swift: extract all output-producing source files, not only primary files 2022-06-20 14:06:54 +02:00
Paolo Tranquilli
90f0e3ee72 Swift: remove forgotten resolved TODO 2022-06-20 13:08:28 +02:00
Paolo Tranquilli
95a6c5d4e5 Swift: fix emission of synthesized entities
This was temporarily broken as we were skipping full emission of all
entities without any valid location.

We now rely on `decl->getDeclContext()->getParentSourceFile()` which is
more robust.
2022-06-20 13:00:05 +02:00
Paolo Tranquilli
a91c94c38b Swift: temporarily disable failing test 2022-06-20 10:32:19 +02:00
Paolo Tranquilli
1f53b7fbe8 Merge main into alexdenisov/xref-decls 2022-06-20 10:25:29 +02:00
Paolo Tranquilli
be210aa3af Merge alexdenisov/xref-decls into redsun82/swift-use-generated-classes 2022-06-17 17:03:30 +02:00
Alex Denisov
08ad95b769 Swift: switch to references instead of pointers 2022-06-15 14:19:31 +02:00
AlexDenisov
343ba5ffa8 Update swift/extractor/SwiftDispatcher.h
Co-authored-by: Paolo Tranquilli <redsun82@github.com>
2022-06-15 14:13:50 +02:00
Alex Denisov
1c9a684ac6 Swift: Introduce SwiftExtractionMode 2022-06-15 09:25:01 +02:00
Mathias Vorreiter Pedersen
b0c66dda3a Merge pull request #9556 from MathiasVP/swift-extract-closure-params
Swift: Extract closure parameters
2022-06-15 08:07:08 +01:00
Mathias Vorreiter Pedersen
4595a9cf0b Swift: Extract parameters to closure expressions. 2022-06-14 20:38:57 +01:00
Alex Denisov
26d3c4a7fc Swift: extract system and builtin modules separately 2022-06-14 14:15:48 +02:00
Alex Denisov
9681358a6d Swift: extract OtherConstructorDeclRefExpr 2022-06-14 12:53:25 +02:00
Alex Denisov
e677b78ab9 Swift: attach NominalTypeDecl to the ExtensionDecl 2022-06-14 12:09:26 +02:00
Alex Denisov
cf0fc5829f Swift: extract extension declarations 2022-06-14 08:22:43 +02:00
Mathias Vorreiter Pedersen
6c8982b46e Merge pull request #9469 from rdmarsh2/rdmarsh2/swift/dataflow-inout
Swift: Dataflow through inout parameters
2022-06-13 18:11:11 +01:00
Mathias Vorreiter Pedersen
32ef535ad7 Merge pull request #9430 from github/redsun82/swift-unknown-location
Swift: add `UnknownLocation`
2022-06-13 10:55:53 +02:00
Paolo Tranquilli
28d2fd7a22 Merge pull request #9416 from github/redsun82/swift-codegen-docs
Swift: document and partially simplify codegen
2022-06-13 10:50:16 +02:00
Robert Marsh
776a2965ca Swift: extract isInOut for parameters 2022-06-09 17:09:48 +00: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
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
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
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
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
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
Mathias Vorreiter Pedersen
1d120486b4 Swift: Extract 'yield' statements. 2022-05-31 14:43:09 +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
45bbd24355 Swift: Extract whether a function type is throwing or async. 2022-05-27 11:48:01 +01:00
Mathias Vorreiter Pedersen
cf5f1e593e Swift: Extract new entities. 2022-05-24 08:57:05 +01:00
Paolo Tranquilli
06a8cf6f1e Merge pull request #9198 from github/redsun82/swift-self-contained-cpp-code-gen
Swift: make C++ code generation more self-contained
2022-05-23 13:45:58 +02:00
Paolo Tranquilli
ea6a249fee Swift: fix extractor built with NDEBUG
There was a call with side effects in an `assert`, that was therefore
not being called with `NDEBUG` turned on, changing extractor results.
2022-05-23 12:35:54 +02:00
Paolo Tranquilli
fc165c1975 Swift: remove IDE generated comment header 2022-05-20 16:25:33 +02:00
Paolo Tranquilli
f52a849ab8 Merge branch 'main' into redsun82/swift-self-contained-cpp-code-gen 2022-05-20 16:16:35 +02:00
Paolo Tranquilli
b0668ee6c2 Swift: remove unused decl properties 2022-05-20 15:42:28 +02:00