Commit Graph

2187 Commits

Author SHA1 Message Date
Paolo Tranquilli
c0f477e5c1 Swift: reorder generic type param children in nominal types 2022-08-31 10:57:34 +02:00
Paolo Tranquilli
66e6c7bb13 Swift: make GenericTypeParamDecls children 2022-08-31 10:47:36 +02:00
Paolo Tranquilli
3ce76e6c08 Swift: preserve base order in code generation 2022-08-31 10:45:22 +02:00
Paolo Tranquilli
742cf0a593 Swift: hide orphaned DeclRefExpr nodes 2022-08-31 08:35:00 +02:00
Paolo Tranquilli
8f09485414 Swift: enhance PrintAst testing
The `ParentChild` tests have been generalized to test all `PrintAst`
by factoring out `PrintAstNode` into a separate file.

The `child.ql` and `parent.ql` tests have been removed as they are
subsumed by `PrintAst.ql`. Also, a new `no_parent_child_loops` is
added to detect back edges to a root node (back edges to a non-root
node are already detected by `no_double_parents.ql`).
2022-08-31 06:54:30 +02:00
Paolo Tranquilli
cd632dcfee Swift: minor tweaks
Replace string singleton with a newtype-based one, and fix some doc
comment cosmetics.
2022-08-31 06:39:35 +02:00
Mathias Vorreiter Pedersen
a4209df239 Merge branch 'main' into swift-field-flow-2 2022-08-30 18:52:23 +01:00
Paolo Tranquilli
47b905bfaf Swift: add PrintAst 2022-08-30 18:04:55 +02:00
Paolo Tranquilli
4825e6b8ba Swift: change some children
* made `members` children of an `IterableDeclContext`
* removed `elements` from the children of `EnumCaseDecl`, as they are
  already children of the enclosing `EnumDecl`
* removed `base` from the children of `SelfApplyExpr`, as they currently
  are already descendants via `getArgument(0).getExpr()`. We should
  maybe consider either removing `base` from the schema and add it as
  a shortcut on QL, or finish up replacing all `SelfApplyExpr` instances
  with synthesized types.
2022-08-30 17:30:39 +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
9102cb5d0d Swift: make some ParentChild predicates private 2022-08-30 10:35:08 +02:00
Paolo Tranquilli
beb0472811 Swift: fix ParentChild generation
There was an issue in case multiple inheritance from classes with
children was involved, where indexes would overlap.

The generated code structure has been reshuffled a bit, with
`Impl::getImmediateChildOf<Class>` predicates giving 0-based children
for a given class, including those coming from bases, and the final
`Impl::getImmediateChild` disjuncting the above on final classes only.

This removes the need of `getMaximumChildrenIndex<Class>`, and also
removes the code scanning alerts.

Also, comments were fixed addressing the review.
2022-08-30 10:15:11 +02:00
Paolo Tranquilli
3f4a330658 Swift: make ParentChild::Impl module private 2022-08-29 17:35:16 +02:00
Paolo Tranquilli
105c0d0dce Swift: update after generated parent-child changes 2022-08-29 17:10:46 +02:00
Paolo Tranquilli
b5aad04f65 Swift: add indexes to generated parent-child library 2022-08-29 17:10:46 +02:00
Paolo Tranquilli
0aecbc2a01 Swift: reorganize some children in schema.yml 2022-08-29 14:52:14 +02:00
Paolo Tranquilli
2e9d9cfb20 Swift: add imported modules properties to ModuleDecl 2022-08-26 11:23:02 +02:00
Geoffrey White
2d57786dae Merge branch 'main' into cleartext 2022-08-25 23:10:36 +01:00
Geoffrey White
dacb7f5f25 Swift: Add a SensitiveExprs lib (and test it). 2022-08-25 22:15:15 +01:00
Mathias Vorreiter Pedersen
2d90940111 Swift: Add field flow. 2022-08-24 14:52:36 +01: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
7873f07fac Swift: define ImportDecl:imported_module optional 2022-08-24 14:26:29 +02:00
Mathias Vorreiter Pedersen
edb29b498d Swift: Teach 'DataFlowDispatch' about property getters, observers and setters. 2022-08-24 13:08:26 +01:00
Mathias Vorreiter Pedersen
cee15277ce Merge pull request #10144 from MathiasVP/swift-extract-this-param-decl
Swift: Extract `self` parameter declarations
2022-08-24 11:17:51 +01:00
Michael Nebel
c514c8838d Merge pull request #9867 from michaelnebel/csharp/nosummary
C#: Negative summaries (ie. no flow through)
2022-08-24 12:06:05 +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
997d9e8559 Swift: Include 'self' parameter declaration in the CFG. 2022-08-24 10:01:25 +01:00
Mathias Vorreiter Pedersen
ca31984040 Swift: Autogenerate files. 2022-08-24 10:01:25 +01:00
Mathias Vorreiter Pedersen
273053c92a Swift: Extract self parameter declarations. 2022-08-24 10:01:25 +01:00
Michael Nebel
761ed283b6 C#/Java/Ruby/Swift: Address review comments. 2022-08-24 09:58:54 +02:00
Michael Nebel
160ae934af C#/Java/Ruby/Swift: Fix typo in QL doc. 2022-08-24 09:58:53 +02:00
Michael Nebel
37976d56bc C#/Java/Go/Swift: Move CsvValidation back into ExternalFlow. 2022-08-24 09:58:53 +02:00
Michael Nebel
581824a9b4 C#/Java/Ruby/Swift: Fix various typos. 2022-08-24 09:58:53 +02:00
Michael Nebel
9b16192a7f Swift: Re-factor CsvValidation into a separate file. 2022-08-24 09:58:52 +02:00
Michael Nebel
54e85ff903 Swift: Remove some of the copied (and dead) language specific (to C#) code from swift. 2022-08-24 09:58:52 +02:00
Michael Nebel
8db454aa15 Swift: Sync files and make dummy negative summary implementation. 2022-08-24 09:58:52 +02: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
f0ec43b04c Swift: remove getMethodDeclaration
`getStaticTarget` gives the same result.
2022-08-19 15:37:49 +02:00
Paolo Tranquilli
66459b81da Swift: use field in MethodApplyExpr
Also rename `getMethod` to `getMethodDeclaration` to clear up possible
confusion with `getFunction`.
2022-08-19 15:31:00 +02:00
Paolo Tranquilli
e3f86a9eb0 Swift: fix QL warning 2022-08-19 15:03:18 +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
Erik Krogh Kristensen
4f93f2b9ba Merge pull request #10076 from erik-krogh/ql-for-ql-fixes
various QL-for-QL fixes
2022-08-18 15:46:48 +02:00
Tom Hvitved
355c1f5959 Merge pull request #10035 from hvitved/ssa/phi-reads
SSA: Improve use-use calculation using "phi read nodes"
2022-08-17 13:43:00 +02:00
erik-krogh
dbbba32579 revert change to generated swift code 2022-08-17 13:34:22 +02:00
erik-krogh
2e44fba67d add explicit this 2022-08-17 13:33:31 +02:00
Paolo Tranquilli
9cd2ae2fd1 Swift: rename Synth conversion functions 2022-08-16 16:54:33 +02:00
Tom Hvitved
7395587244 Sync files 2022-08-16 14:07:39 +02:00
Paolo Tranquilli
98819f64da Merge branch 'main' into redsun82/swift-first-prototype-of-generated-ipa-layer 2022-08-16 14:05:44 +02:00
Mathias Vorreiter Pedersen
cbb1108f6e Swift: Fix SSA for calls to getter functions. 2022-08-16 11:48:46 +01:00
Paolo Tranquilli
5bad696b41 Swift: remove unused no-parameter constructors 2022-08-16 09:09:00 +02:00