Commit Graph

274 Commits

Author SHA1 Message Date
AlexDenisov
8756989b4b Merge pull request #11101 from github/alexdenisov/extractor-errors
Swift: extract diagnostics
2022-11-09 11:33:54 +01:00
Paolo Tranquilli
73ad1307ae Swift: extract PoundDiagnosticDecl 2022-11-09 11:13:55 +01:00
Paolo Tranquilli
b399d8df7e Swift: extract opaque types and their decls 2022-11-09 09:27:25 +01:00
Paolo Tranquilli
53b7584a90 Merge pull request #11169 from github/redsun82/swift-extract-last-stmts
Swift: extract remaining `Stmt`s
2022-11-08 20:51:10 +01:00
Paolo Tranquilli
cbae72d9da Swift: remove emoji in test 2022-11-08 17:41:40 +01:00
Paolo Tranquilli
9ee4f8b388 Swift: extract remaining Stmts
`FailStmt` are `return nil` in fallible initializers.

`PoundAssertStmt` are an experimental feature for compile time
assertions.
2022-11-08 17:38:17 +01:00
Paolo Tranquilli
00d3ff8a18 Swift: extract UnaryPostfixExpr 2022-11-08 17:10:33 +01:00
Alex Denisov
2b8b6d3dc3 Swift: ignore diagnostics for PrintAst 2022-11-08 14:45:56 +01:00
Alex Denisov
e9c4cb227f Swift: add more diagnostics tests 2022-11-08 14:41:10 +01:00
Alex Denisov
433f4e0cb5 Swift: use DbFile/DbLocation 2022-11-08 14:36:28 +01:00
Alex Denisov
288bdc2ee9 Swift: add diagnostics test case 2022-11-08 14:36:28 +01:00
Alex Denisov
62c26f8f27 Swift: add diagnostics to dbscheme 2022-11-08 14:36:25 +01:00
Paolo Tranquilli
552c5249ac Merge pull request #11131 from github/redsun82/swift-incomplete-ast
Swift: deal with incomplete ASTs
2022-11-08 14:01:58 +01:00
Paolo Tranquilli
450a4a04af Swift: add incomplete ast test
The test was inspired by locally running the query against files in
https://github.com/apple/swift/tree/main/test/Parse

A query for missing elements was also added to the AST tests, expecting
nothing to be found.
2022-11-08 11:46:07 +01:00
Paolo Tranquilli
e17bc6c581 Swift: add UnspecifiedElement 2022-11-08 11:40:27 +01:00
Tony Torralba
4411852e59 Add BitwiseOperation.qll 2022-11-08 11:33:10 +01:00
Paolo Tranquilli
072edad0fd Swift: accept new test changes 2022-11-08 09:30:25 +01:00
Paolo Tranquilli
21adcca065 Swift: add bitwise ops to PrintAst test 2022-11-08 08:53:36 +01:00
Paolo Tranquilli
b30a6d36b5 Swift: extract AwaitExpr 2022-11-07 12:08:51 +01:00
Paolo Tranquilli
3acd4486a3 Swift: add tests for RUN_UNDER support
While I would have preferred to add a proper unit test, this required
more infrastructure for mocking system calls. Instead I made `qltest.sh`
accept a `//codeql-extractor-env` header and used that to write a QL
test exercising the `RUN_UNDER` functionality.
2022-11-02 12:09:13 +01:00
Paolo Tranquilli
e49268d036 Swift: show QL class in generated tests on collapsed hierarchies
In those kinds of tests the results may have different final classes
that are not necessarily visible (or tested) solely through the string
representation. For better testing and reading of expected results,
`getQlPrimaryClasses` is added in these cases.
2022-10-17 14:08:04 +02:00
Paolo Tranquilli
789be9a1ad Swift: add ImplicitConversionExpr test 2022-10-17 12:57:44 +02:00
Alex Denisov
b364647d76 Swift: add stubs for new exprs 2022-09-22 11:17:07 +02:00
Alex Denisov
d937234f83 Swift: add stubs for new types 2022-09-22 11:17:07 +02:00
Alex Denisov
13fe02edfa Swift: NestedArchetypeType was removed 2022-09-22 11:17:04 +02:00
Paolo Tranquilli
69dfdf5a34 Swift: fix IfConfigDecl in QL libraries
This fixes `IfConfigDecl` for both the AST printer and control flow
libraries.

It turns out that the active lements of an `IfConfigDecl` are already
listed in the enclosing scope (like a `BraceStmt`), so they should not
be listed as children, and `IfConfigDecl` can be jsut a leaf in the
control flow.
2022-09-21 12:12:55 +02:00
Paolo Tranquilli
3fd8136dc7 Swift: accept test results 2022-09-20 15:37:09 +02:00
Paolo Tranquilli
72a4bd3f1e Swift: group unresolved elements and remove their tests 2022-09-20 15:22:20 +02:00
Paolo Tranquilli
7ae68fcc03 Swift: rework IfConfigDecl schema 2022-09-20 15:11:58 +02:00
Paolo Tranquilli
30049f622d Swift: move new code down in tests 2022-08-31 11:38:32 +02:00
Paolo Tranquilli
a237f691b5 Swift: show conversions in PrintAst
This also showcases the customizability of the `PrintAst` infrastructure
resting on generated code.
2022-08-31 11:28:17 +02:00
Paolo Tranquilli
281cd79b48 Swift: add generics to ast tests 2022-08-31 11:09:35 +02:00
Paolo Tranquilli
742cf0a593 Swift: hide orphaned DeclRefExpr nodes 2022-08-31 08:35:00 +02:00
Paolo Tranquilli
38d65d3fae Swift: make ConstructorDecl's name include params
In order to distinguish overloads of the constructor and for consistency
with other function calls, `ConstructorDecl` string representation uses
the name which includes parentheses and parameter labels.

For consistency also the destructor got the same change, which means
all `DestructorDecl`s will now show as `deinit()` rather than `deinit`.
2022-08-30 11:11:50 +02:00
Paolo Tranquilli
b5d18b05e2 Swift: accept new module type in tests 2022-08-26 13:52:24 +02:00
Paolo Tranquilli
ebc7432f46 Swift: implement imported_ and exported_modules
This has expanded the required builtin symbols.
2022-08-26 11:37:14 +02:00
Paolo Tranquilli
2e9d9cfb20 Swift: add imported modules properties to ModuleDecl 2022-08-26 11:23:02 +02:00
Paolo Tranquilli
df3dc9677f Swift: fix missing extractions from Builtin
There were missing extractions from the Builtin (and other) modules.

This was actually caused by two issues:
* we did not visit all required modules, as for example the `Builtin`
  module does not appear as being imported by anybody (together with
  another mysterious `__Objc` module)
* moreover the `Builtin` module works internally by only creating
  declarations on demand, and does not provide a list of its top level
  declarations.

The first problem was solved by moving module collection to the actual
visiting. This may mean we extract less modules, as we only extract the
modules we actually use something from (recursively). This change can
be reverted if we feel we need it.

The second one was solved by explicitly listing the builtin symbols
encountered during a normal extraction. This does mean this list needs
to be kept up to date.
2022-08-25 15:18:24 +02:00
Paolo Tranquilli
610c788e34 Merge pull request #10156 from github/redsun82/swift-import-optional-module
Swift: make `ImportDecl:imported_module` optional
2022-08-24 15:18:04 +02:00
Paolo Tranquilli
2ee8d1a9d3 Swift: implement optional ImportDecl:imported_module 2022-08-24 14:31:55 +02:00
Paolo Tranquilli
7873f07fac Swift: define ImportDecl:imported_module optional 2022-08-24 14:26:29 +02:00
Mathias Vorreiter Pedersen
1d50dd54ce Merge branch 'main' into swift-extract-this-param-decl 2022-08-24 10:14:18 +01:00
Mathias Vorreiter Pedersen
09427af2a2 Swift: Accept test changes. 2022-08-24 10:01:25 +01:00
Mathias Vorreiter Pedersen
ca31984040 Swift: Autogenerate files. 2022-08-24 10:01:25 +01:00
Paolo Tranquilli
2fc88d5f8e Swift: add module to Decl and remove forward traps
Add module context to all declarations. As keeping the `std::variant`s
required slightly more work for this, and we intended to remove them
any way, this is done in this change.

For background, we put those in as we were not extracting all modules at
the time, so we were missing some DB ids that we put back in by adding
the "defining" traps not only in the trap file related to the defining
module but also to the one where the declaration was used. Since then
we fixed module extraction, so this should not be needed any more.
2022-08-23 16:53:07 +02:00
Paolo Tranquilli
631d234026 Swift: expand tests 2022-08-19 16:15:17 +02:00
Paolo Tranquilli
6706ba6ded Swift: accept toString changes in tests 2022-08-19 15:22:02 +02:00
Paolo Tranquilli
9b50336e47 Swift: synthesize MethodRefExpr
This introduces a `MethodRefExpr` node synthesized out of
`DotSyntaxCallExpr` under the `LookupExpr` hierarchy. This means that
much like
```free_function(1, 2)```
is a `CallExpr` with `getFunction` giving a `DeclRefExpr`,
```foo.method(1, 2)```
is now a `CallExpr` with `getFunction` giving a `MethodRefExpr`.

`ApplyExpr::getStaticTarget` has been made work with it (as well as
`ConstructorRefCallExpr` which for the moment has been left where it
is), a new `MethodApplyExpr` has been introduced deriving from it,
and control and data flow libraries have adapted.

A small but was fixed in `qlgen` where the default constructor for DB
types was not correctly subtracting derived IPA types depending on the
order of definitions in `schema.yml`.

There are still some occurrences of `DotSyntaxCallExpr`, and as already
mentioned the other `SelfApply` class (`ConstructorRefCallExpr`) was
left alone. Their treatment is left for a future PR.
2022-08-19 14:48:36 +02:00
Paolo Tranquilli
979706903a Merge pull request #10070 from github/redsun82/swift-self-apply-tests
Swift: add more `SelfApplyExpr` testing
2022-08-17 09:34:20 +02:00
Paolo Tranquilli
f17fed7c9a Swift: add more SelfApplyExpr testing 2022-08-16 17:46:22 +02:00