Commit Graph

535 Commits

Author SHA1 Message Date
Alexandre Boulgakov
5952a729df Build: Bump build mode to C++20. 2023-06-08 13:10:43 +01:00
Paolo Tranquilli
0b09fdae43 Merge branch 'main' into alexdenisov+redsun82/tuple-mangling 2023-06-07 10:40:38 +02:00
Paolo Tranquilli
400176f677 Swift: fix cmake generation
The bazel -> cmake generator is currently not capable of handling
separate included generated cmake files making use of common C/C++
dependencies.

To work around this limitation, a single generated cmake is now in
place. Long-term, we should either:
* make the cmake generator handle common dependencies gracefully, or
* make the cmake generation aspect travel up `pkg_` rules `srcs`
  attributes
so to avoid having to list the targets to be generated in the top-level
`BUILD` file.

Other things fixed:
* removed some warning spam about redefined `BAZEL_CURRENT_REPOSITORY`
* fixed the final link step, that was failing because `libswiftCore.so`
  was not being linked.
2023-06-05 11:12:11 +02:00
Paolo Tranquilli
edb822279b Swift: update comments to the mangler 2023-05-31 10:12:31 +02:00
Paolo Tranquilli
70ff401f21 Swift: replace internal swift mangler with our own
Our mangler is split in two version:
* `SwiftTrapMangler`, with the same behaviour as the previous
  `SwiftMangler`, constructing mangled names with trap label references
* `SwiftRecursiveMangler` that replaces trap label references with
  recursive calls to its own `mangle` functions, effectively rolling out
  the entire chain of references

The latter is used to create lazy trap file names. Hashing is used to
avoid excessively long filenames.
2023-05-31 09:52:20 +02:00
Paolo Tranquilli
2183d380db Swift: implement review suggestions 2023-05-30 10:30:44 +02:00
Paolo Tranquilli
15047368e8 Swift: add a warning to unmangled types 2023-05-26 15:12:21 +02:00
Paolo Tranquilli
3f7c4dec25 Swift: add a header comment to SwiftMangler 2023-05-26 15:05:40 +02:00
Paolo Tranquilli
d81dc274f6 Swift: make a TODO more assertive as there is a draft PR already 2023-05-26 14:45:29 +02:00
Paolo Tranquilli
05ed66ad8f Swift: remove debugging print 2023-05-26 14:42:02 +02:00
Paolo Tranquilli
2fb6cdc19b Merge branch 'main' into alexdenisov+redsun82/tuple-mangling 2023-05-24 11:16:59 +02:00
Paolo Tranquilli
9a0f87434e Swift: remove unneeded properties from InterpolatedStringLiteralExpr
These properties were unused in the QL library (hence the full
upgrade/downgrade compatibility).
2023-05-22 15:28:54 +02:00
Alexandre Boulgakov
7ada125299 Swift: Support fmtlib for assertions/expectations.
Specifically, this adds custom formatters using `path::operator string()` and `error_code::message()` and dereferences a (non-empty) optional. `fmtlib` provides formatters for these standard library types in `fmt/std.h`, but that file also requires RTTI (which we disable) for `std::exception` so we can't use it without either patching `fmtlib` (which they're open to: https://github.com/fmtlib/fmt/issues/3170) or enabling RTTI (which will require some consideration).
2023-05-16 18:33:28 +01:00
Mathias Vorreiter Pedersen
87325dbfd1 Merge pull request #13112 from geoffw0/swifttodos2
Swift: Delete some more TODO comments.
2023-05-10 16:39:37 +01:00
Geoffrey White
4af97274dd Swift: Delete TODO (already fixed). 2023-05-10 08:55:43 +01:00
Paolo Tranquilli
ec3c63a2b3 Swift: replace all usages of std::to_string with absl::StrCat or absl::StrAppend 2023-05-10 07:03:06 +02:00
Paolo Tranquilli
2904aa8439 Revert "Swift: auto-flush logs at exit"
This reverts commit 0d9dcb161f.

This turns out to introduce a subtle bug related to destruction order
between `Log::instance()` and the `Logger` instances.
2023-05-09 13:08:28 +02:00
Paolo Tranquilli
0d9dcb161f Swift: auto-flush logs at exit 2023-05-09 10:08:34 +02:00
Paolo Tranquilli
bce483ddb1 Swift: rename log package to logging 2023-05-04 10:42:39 +02:00
Paolo Tranquilli
9544b96ff1 Merge branch 'main' into redsun82/swift-json 2023-05-04 10:34:11 +02:00
Paolo Tranquilli
a30d5f5030 Swift: fix diagnostic source creation being called really once 2023-05-03 16:14:22 +02:00
Paolo Tranquilli
1d492f89cc Merge branch 'main' into redsun82/swift-logging-assertions-and-prints 2023-05-03 15:19:08 +02:00
Paolo Tranquilli
51763d65b0 Swift: reshape a TODO into another 2023-05-03 15:18:35 +02:00
Paolo Tranquilli
f461e719da Swift: fix wrong condition for log 2023-05-03 14:54:28 +02:00
Paolo Tranquilli
8de2f9958e Swift: add support to output JSON diagnostics
New `DIAGNOSE_ERROR` and `DIAGNOSE_CRITICAL` macros are added.

These accept an ID which should indicate a diagnostic source via
a function definition in `codeql::diagnostics`, together with the usual
format + arguments accepted by other `LOG_*` macros.

When the log is flushed, these special logs will result in an error JSON
diagnostic entry in the database.
2023-05-03 14:32:31 +02:00
Paolo Tranquilli
0ad529dff8 Swift: move logging to a common directory 2023-05-03 14:32:31 +02:00
Paolo Tranquilli
c7c12a7108 Swift: add json and date dependencies 2023-05-03 14:32:30 +02:00
Paolo Tranquilli
3685590a12 Swift: remove version control markers 2023-05-02 10:45:43 +02:00
Paolo Tranquilli
7adcd0d043 Swift: small tweak to visitBuiltinType 2023-05-02 10:45:43 +02:00
Paolo Tranquilli
87c73879cb Swift: add explanation to getExtensionIndex 2023-05-02 10:45:43 +02:00
Paolo Tranquilli
826d7c7dbe Swift: preload extension indexes
Finding each extension declaration separately within its parent seemed
to create an `O(n^2)` noticeable performance problem. This is solved
by preloading indexes and storing them in a map, so as to iterate
through the parent of an extension only once per parent instead of once
per extension.
2023-05-02 10:45:43 +02:00
Paolo Tranquilli
146591934a Swift: clean up SwiftMangler 2023-05-02 10:45:43 +02:00
Paolo Tranquilli
f6a6958c03 Swift: mangle ParameterizedProtocolType 2023-05-02 10:45:43 +02:00
Alex Denisov
92c20be038 Swift: change indexing for extension declarations to make them more stable 2023-05-02 10:45:42 +02:00
Alex Denisov
6c954eae3c Swift: handle isolated types 2023-05-02 10:45:42 +02:00
Paolo Tranquilli
dfbc248e78 Swift: mangle opened archetype and fix global actor 2023-05-02 10:45:42 +02:00
Paolo Tranquilli
0aed7d56c2 Swift: more mangling 2023-05-02 10:45:42 +02:00
Paolo Tranquilli
2592129d83 Swift: mangle remaining unmangled types appearing during test run 2023-05-02 10:45:42 +02:00
Paolo Tranquilli
c8ca6057d3 Swift: mangle several new things 2023-05-02 10:45:40 +02:00
Paolo Tranquilli
4ac91ea1b2 Swift: mangle function types, type paramters, metatypes, dependent member types 2023-05-02 10:39:46 +02:00
Paolo Tranquilli
b6146478dc Swift: mangle nominal and bound generic types 2023-05-02 09:49:48 +02:00
Paolo Tranquilli
1274aaaf9c Swift: mangle GenericTypeDecl 2023-05-02 09:49:48 +02:00
Paolo Tranquilli
476cf72710 Swift: mangle AnyGenericType 2023-05-02 09:49:48 +02:00
Paolo Tranquilli
348bc964be Swift: turn current decl mangling into visitor 2023-05-02 09:49:48 +02:00
Paolo Tranquilli
b269bd5010 Swift: mangle builtin and tuple types 2023-05-02 09:49:48 +02:00
Nora Dimitrijević
90ad36ed6c Swift: update extractor 2023-04-26 15:47:19 +02:00
Paolo Tranquilli
9d80a43d6a Merge pull request #12500 from github/redsun82/swift-dispatcher-rework
Swift: rework fetching and dispatching
2023-04-26 09:58:19 +02:00
Alexandre Boulgakov
909f40b6ea Merge pull request #12918 from github/sashabu/absl
Swift: Fix some TODOs with Abseil.
2023-04-25 14:05:12 +01:00
Alex Denisov
125aab8107 Swift: rework fetching and dispatching
* visiting now happens in a later stage than fetching labels. While
  fetching a list of entities to be visited is created, and then acted
  upon in actual extraction. This partially flattens the recursive
  nature of `fetchLabel` into a loop inside `SwiftVisitor::extract`.
  Recursion in `fetchLabel` will only happen on labels fetched while
  naming an entity (calling into `SwiftMangler`).
* The choice whether to name a declaration or type has been moved from
  the translators to `SwiftMangler`. Acting on this choice is contained
  in `SwiftDispatcher::createLabel`.
* The choice whether to emit a body of a declaration has been moved from
  `DeclTranslator` to the dispatcher. This choice is also contained in
  `SwiftDispatcher::createLabel`.
* The simple functionality of the `LabelStore` has been moved to the
  `SwiftDispatcher` as well.
2023-04-25 11:15:27 +02:00
AlexDenisov
fcbd211783 Merge pull request #12910 from github/redsun82/swift-hash-lazy-trap-names
Swift: use hashing for lazy decl trap file names
2023-04-25 09:54:46 +02:00