Commit Graph

2187 Commits

Author SHA1 Message Date
Paolo Tranquilli
3527897eff Swift: make type optional in TypeRepr
A type representation may not have a type in unresolved things, which
for example pop up in inactive `#if` clauses.
2022-07-20 09:13:34 +02:00
Paolo Tranquilli
e1bd4a78ff Merge branch 'main' into redsun82/swift-type-repr-collapse 2022-07-18 14:05:43 +02:00
Paolo Tranquilli
98fc8812fc Merge 'main' into redsun82/swift-extraction 2022-07-18 11:55:21 +02:00
Paolo Tranquilli
f7dca4d70f Swift: trap output rework
Firstly, this change reworks how inter-process races are resolved.
Moreover some responsability reorganization has led to merging
`TrapArena` and `TrapOutput` again into a `TrapDomain` class.

A `TargetFile` class is introduced, that is successfully created
only for the first process that starts processing a given trap output
file. From then on `TargetFile` simply wraps around `<<` stream
operations, dumping them to a temporary file. When `TargetFile::commit`
is called, the temporary file is moved on to the actual target trap
file.

Processes that lose the race can now just ignore the unneeded
extraction and go on, while previously all processes would carry out
all extractions overwriting each other at the end.

Some of the file system logic contained in `SwiftExtractor.cpp` has been
moved to this class, and two TODOs are solved:
* introducing a better inter process file collision avoidance strategy
* better error handling for trap output operations: if unable to write
  to the trap file (or carry out other basic file operations), we just
  abort.

The changes to `ExprVisitor` and `StmtVisitor` are due to wanting to
hide the raw `TrapDomain::createLabel` from them, and bring more
funcionality under the generic caching/dispatching mechanism.
2022-07-13 11:19:57 +02:00
Paolo Tranquilli
033b239b22 Swift: collapse TypeRepr hierarchy
Now `TypeRepr` is a final class in the AST, which is more or less just
a type with a location in code.

As the frontend does not provide a direct way to get a type from a
type representation, this information must be provided when fetching
the label of a type repr.

This meant:
* removing the type repr field from `EnumIsCaseExpr`: this is a virtual
  AST node introduced in place of some kinds of `IsEpxr`. The type
  repr is still available from the `ConditionalCheckedCastExpr` wrapped
  by this virtual node, and we will rebuild the original `IsExpr` with
  the IPA layer.
* some logic to get the type of keypath roots has been added to
  `KeyPathExpr`. This was done to keep the `TypeRepr` to `Type` relation
  total in the DB, but goes against the design of a dumb extractor. The
  logic could be moved to QL in the future
* in the control flow library, `TypeRepr` children are now ignored. As
  far as I can tell, there is no runtime evaluation going on in
  `TypeRepr`s, so it does not make much sense to have control flow
  through them.
2022-07-12 10:49:14 +02:00
Paolo Tranquilli
39406436bf Swift: extract IfConfigDecl
This also adds `UnresolvedDeclRefExpr` tests, as `IfConfigDecl`
consistently introduces those.
2022-07-11 15:11:13 +02:00
Paolo Tranquilli
7d5dd384c3 Swift: extract UnresolvedPatternExpr 2022-07-11 10:59:00 +02:00
Paolo Tranquilli
3a975174c3 Swift: extract ImportDecl and ModuleDecl
As `ASTMangler` crashes when called on `ModuleDecl`, we simply use
its name.

This might probably not work reliably in a scenario where multiple
modules are compiled with the same name (like `main`), but this is left
for future work. At the moment this cannot create DB inconsistencies.
2022-07-01 15:29:30 +02:00
Mathias Vorreiter Pedersen
51e3ff9d09 Merge pull request #9736 from github/redsun82/swift-fix-warnings
Swift: fix QL warnings about overriding methods
2022-06-30 11:44:44 +01:00
Paolo Tranquilli
d00fec34c3 Merge pull request #9336 from MathiasVP/swift-decls-in-cfg
Swift: CFG for local declarations
2022-06-29 15:10:45 +02:00
Mathias Vorreiter Pedersen
e03646aba4 Merge pull request #9737 from geoffw0/arithmetic
Swift: Add ArithmeticOperation.qll library
2022-06-29 13:40:20 +01:00
Geoffrey White
8b7535af81 Swift: Don't use abstract classes. 2022-06-29 11:49:22 +01:00
Geoffrey White
822002d37d Swift: Missing qldoc. 2022-06-29 11:49:20 +01:00
Mathias Vorreiter Pedersen
4356155eeb Merge branch 'main' into swift-decls-in-cfg 2022-06-29 10:03:34 +01:00
Jeroen Ketema
55e052af26 Merge pull request #9686 from aschackmull/dataflow/no-node-scan
Dataflow performance: Avoid node scans
2022-06-29 10:38:56 +02:00
Mathias Vorreiter Pedersen
f2ae73b6be Merge pull request #9738 from geoffw0/misc
Swift: Add a Locatable.getFile() shortcut similar to the one in CPP.
2022-06-28 16:44:02 +01:00
Geoffrey White
ff06e3cb6b Swift: Add a Locatable.getFile() shortcut similar to the one in CPP. 2022-06-28 15:49:49 +01:00
Geoffrey White
a5fff9af5d Swift: Create ArithmeticOperation.qll. 2022-06-28 15:34:15 +01:00
Geoffrey White
9e0cf62cda Swift: Fix + simplify LogicalOperation.qll. 2022-06-28 15:33:03 +01:00
Paolo Tranquilli
363f7a88a9 Swift: fix QL warnings about overriding methods
The `getName` in `Type.qll` was issuing a warning in other generated
classes having a `getName` from a `name` property in `schema.yml`.

To fix the possible inconsistency, `diagnostic_name` is being renamed to
`name` in the schema. Despite the scary doc comment on
`swift::Type::getString` (namely `for use in diagnostics only`), that
seems to be the right generic naming mechanism for types, and it
coincides with the name we were extracting on types with an explicit
`name` property.

In case we find a case where `Type::getString` gives something wrong,
we can probably just patch it on that specific type class.
2022-06-28 16:30:25 +02:00
Paolo Tranquilli
57981384df Swift: extract ProtocolComposition- and BuiltinType 2022-06-28 12:01:36 +02:00
Mathias Vorreiter Pedersen
41b23572f0 Merge pull request #9673 from geoffw0/stringlengthconflation2
Swift: String length conflation query
2022-06-27 10:29:09 +01:00
Paolo Tranquilli
41fb55a7a8 Swift: extract all ReferenceStorageTypes 2022-06-24 18:10:31 +02:00
Paolo Tranquilli
fd209e57cd Swift: extract InoutType 2022-06-24 17:29:46 +02:00
Paolo Tranquilli
346110e8dd Swift: extract DynamicSelfType 2022-06-24 16:49:58 +02:00
Paolo Tranquilli
4281605ba7 Swift: extract existential types 2022-06-24 16:28:18 +02:00
Paolo Tranquilli
631156dbc6 Swift: extract Nested- and PrimaryArchetypeType 2022-06-24 16:28:17 +02:00
Paolo Tranquilli
299e1af22e Merge main into redsun82/swift-code-reorg 2022-06-24 13:06:14 +02:00
Paolo Tranquilli
8ca529e8d9 Swift: make Element::resolve final
One should only override `getResolveStep` (or `convertsFrom` for `Expr`
classes), as otherwise the resolution/conversion becomes inconsitent.
2022-06-24 10:05:58 +02:00
Mathias Vorreiter Pedersen
71efffd79b Merge pull request #9691 from rdmarsh2/rdmarsh2/swift/ssa-perf-1
Swift: remove check for inout params in SSA gen
2022-06-23 17:16:38 +01:00
Robert Marsh
946d0358c9 Swift: remove check for inout params in SSA gen
This check is unnecessary since it's enforced by the compiler, and is
causing a bad join order.
2022-06-23 15:59:34 +00:00
Anders Schack-Mulligen
dc517a758e Autoformat 2022-06-23 14:44:40 +02:00
Anders Schack-Mulligen
4a317a25d3 Dataflow: Sync. 2022-06-23 14:34:52 +02:00
Paolo Tranquilli
a9877ed2fd Swift: split generated C++ files by directory 2022-06-23 14:24:03 +02:00
Geoffrey White
3b48cb02bc Swift: Add Type.getName(). 2022-06-23 12:54:56 +01:00
Mathias Vorreiter Pedersen
9b587843ff Merge pull request #9669 from rdmarsh2/rdmarsh2/swift/dataflow-lambda-flow
Swift: implement LambdaCall in dataflow library
2022-06-23 10:38:45 +01:00
Robert Marsh
42929a70e8 Swift: implement LambdaCall in dataflow library 2022-06-22 17:30:54 +00:00
Mathias Vorreiter Pedersen
77b8ceb976 Swift: Make sure property setters and getters also have ExprNodes. 2022-06-22 17:53:41 +01:00
Paolo Tranquilli
e25f22da26 Merge main into redsun82/swift-extraction 2022-06-22 16:54:52 +02:00
Paolo Tranquilli
1fc2bc4938 Swift: really fix tests 2022-06-22 16:15:02 +02:00
Mathias Vorreiter Pedersen
07c4308a32 Merge branch 'main' into swift-add-remote-flow-sources 2022-06-22 14:27:44 +01:00
Robert Marsh
d13d4c6cd1 Merge pull request #9623 from MathiasVP/swift-interpretElement0
Swift: Interpret MaD strings
2022-06-22 09:27:13 -04:00
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
Anders Schack-Mulligen
df6d68b215 Merge pull request #9618 from aschackmull/dataflow/deprecate-barrierguard-class
Dataflow: Deprecate BarrierGuard class
2022-06-22 10:44:08 +02:00
Michael Nebel
24ba5cc06e Merge pull request #9025 from michaelnebel/csharp/generatedrefactor
C#: Provenance column in Models as Data CSV format.
2022-06-22 10:34:31 +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
Mathias Vorreiter Pedersen
415e9742a7 Swift: Add a 'RemoteFlowSource' class. 2022-06-21 14:09:56 +01:00
Mathias Vorreiter Pedersen
f9c8926fcc Swift: Fill in some easy TODOs in 'FlowSummaryImplSpecific' and implement a source model for 'String(contentsOf:)'. 2022-06-21 10:27:46 +01:00