Commit Graph

535 Commits

Author SHA1 Message Date
Paolo Tranquilli
6d192cdcc1 Swift: make C++ code generation language agnostic 2023-02-27 09:46:48 +01:00
Alex Denisov
712c25e6f4 Swift: extract availability info 2023-02-07 14:26:39 +01:00
Paolo Tranquilli
a244b825df Merge branch 'main' into redsun82/swift-regex 2023-02-07 09:37:09 +01:00
Nora Dimitrijević
ce2e7f1d12 Swift: all Callables can have captures [hand-written] 2023-02-02 11:35:50 +01:00
Nora Dimitrijević
6895c113cf Swift: extract closure captures (hand-written part) 2023-02-02 11:30:33 +01:00
Nora Dimitrijević
f96c18a6db Swift: subsume IterableDeclContext into Decl [hand-written] 2023-01-28 00:44:48 +01:00
Paolo Tranquilli
4880ab41a2 Swift: use weakly_canonical instead of canonical
`weakly_canonical` will resolve as much as possible in the path, and not
return an error if it can't resolve everything (for example due to a
non existant file). In any case in case of problems with the file we
will see an error when actually using the resolved path.

This tunes down some unhelpful log messages.
2023-01-24 16:34:47 +01:00
Paolo Tranquilli
a74247e5d8 Swift: add filename to an error message 2023-01-24 16:29:10 +01:00
Paolo Tranquilli
6b77e6748a Swift: use same implementation for createTarget{Link,Object}Domain 2023-01-24 16:27:21 +01:00
Paolo Tranquilli
57ec5db1a9 Merge branch 'main' into redsun82/swift-linkage-awareness 2023-01-19 10:49:33 +01:00
Alex Denisov
35620c4c86 Swift: drop dead code 2023-01-18 15:35:40 +01:00
Paolo Tranquilli
f383fd1dc1 Swift: introduce module disambuigation via linkage awareness 2023-01-18 10:07:46 +01:00
Paolo Tranquilli
d7feb001be Swift: prepare extractSwiftInvocation 2023-01-18 10:07:46 +01:00
Paolo Tranquilli
a3b4c32f07 Swift: stamp all named declarations with an id-ref to the containing module 2023-01-18 10:07:46 +01:00
Paolo Tranquilli
f7a046ccd2 Swift: add trap linkage awareness infrastructure 2023-01-18 10:07:46 +01:00
Paolo Tranquilli
5fdb09380c Swift: move TargetTrapDomain to TargetDomains in infra 2023-01-18 10:07:46 +01:00
Paolo Tranquilli
7f389b9f9a Swift: introduce TrapType 2023-01-18 10:07:46 +01:00
Paolo Tranquilli
353536b826 Swift: collect original output module paths 2023-01-18 10:07:46 +01:00
Paolo Tranquilli
84b285a4c6 Swift: collect source files 2023-01-18 10:07:46 +01:00
Paolo Tranquilli
33c4a8233c Swift: collect encountered modules 2023-01-18 10:07:46 +01:00
Paolo Tranquilli
c7f13f1036 Swift: collect TRAP files related to an extractor run
In order to do this a mutable `SwiftExtractorState` is introduced.
2023-01-18 10:07:46 +01:00
Paolo Tranquilli
c31c515205 Swift: move TargetFile as managed inside TrapDomain 2023-01-18 10:07:46 +01:00
Paolo Tranquilli
2c4c2dfeb3 Swift: remove obsolete configuration fields 2023-01-18 08:55:59 +01:00
Paolo Tranquilli
6b43ff45a4 Merge pull request #11904 from github/redsun82/swift-extension-protocols
Swift: extract `ExtensionDecl` protocols
2023-01-17 15:16:20 +01:00
Paolo Tranquilli
d6e0ef9ff9 Swift: extract ExtensionDecl protocols 2023-01-17 12:56:09 +01:00
Paolo Tranquilli
874fe2b8f9 Swift: introduce an in-memory file hash cache
File hashing is now done internally in `SwiftFileInterception` (and
exported as a `getHashOfRealFile` function for future use in linkage
awareness), and using a per-process in-memory cache. The persistent
caching of paths is removed, so the solution is now robust against input
file changes during the build.

For the same reason, the hash to artifact mapping have the symlinks
reversed now. The artifacts themselves are stored using the hash as
filenames, and the original paths of the artifacts are reacreated in the
scratch dir with symlinks mostly for debugging purposes (to understand
what artifact each hash corresponds to, and to follow what was built by
the extractor).
2023-01-16 12:05:36 +01:00
Paolo Tranquilli
4f5f0aad45 Merge branch 'main' into redsun82/swift-open-redirection 2023-01-12 10:54:04 +01:00
Paolo Tranquilli
2fb5621527 Swift: replace $(CC) with clang
On macOS `$(CC)` points to a wrapper that requires `DEVELOPER_DIR` to be
set in the environment. Using `clang` is slightly less generic, but
that's our default any way. Even if we do set a different clang version
somewhere, the selected version of GCC would not change, and the test
is targeting that.
2023-01-10 14:58:21 +01:00
Paolo Tranquilli
943763a026 Swift: add -Wno-pragma-once-outside-header to check 2023-01-10 14:30:35 +01:00
Paolo Tranquilli
28d79eeb77 Swift: make compilation with different STL versions possible
Previous to this patch the code contained a workaround for the standard
defect

https://cplusplus.github.io/LWG/issue3657

where `std::filesystem::path` did not have a `std::hash` implementation.

This patch allows compiling against versions of the STL that contain the
fix to the above issue. This is done by running the compiler against
code defining `std::hash<std::filesystem::path>`: if compilation
succeeds, it means the fix is not there and we need to use the
workaround, contained in `PathHash.h.workaround`. Otherwise, the fix is
there and we use `PathHash.h.fixed` instead, which only includes the
standard headers included by `PathHash.h.workaround`, so that one is a
drop-in replacement of the other.
2023-01-10 14:14:33 +01:00
Paolo Tranquilli
82d9edfabf Merge branch 'main' into redsun82/swift-open-redirection 2023-01-09 08:44:02 +01:00
Paolo Tranquilli
454af0d721 Swift: fix locking of output swiftmodule trap 2022-12-20 15:34:18 +01:00
Nora Dimitrijević
1c64bf4bbc Swift: remove superfluous newline 2022-12-19 18:00:20 -05:00
Nora Dimitrijević
60727b1e5e Swift: Fix Builtin(Types) test extraction failure 2022-12-15 10:47:10 -05:00
Paolo Tranquilli
7f505d8715 Swift: do not filter frontend actions 2022-12-15 14:39:43 +01:00
Paolo Tranquilli
208388e04d Swift: hard code libc.dylib path on macOS
Also, handle the corner case where loading libc fails.
2022-12-15 13:30:23 +01:00
Paolo Tranquilli
e42ae09e1c Swift: fix interaction between bash wrapper and open redirection on macOS 2022-12-15 09:50:31 +01:00
Nora Dimitrijević
7ea0eada11 Swift: add missing Builtin symbols 2022-12-14 20:03:41 -05:00
Paolo Tranquilli
14fd89d482 Swift: generalize output redirection code 2022-12-14 18:26:48 +01:00
Paolo Tranquilli
45c0c7fe6c Merge branch 'main' into redsun82/swift-open-redirection 2022-12-14 18:26:16 +01:00
Paolo Tranquilli
de2e92d5e1 Swift: remove / delimiters from regex extracted patterns 2022-12-14 09:18:36 +01:00
Paolo Tranquilli
fb5b6eab19 Swift: extract RegexLiteralExpr 2022-12-14 09:12:07 +01:00
Alex Denisov
ee94849528 Swift: switch to bootstrapped Swift compiler 2022-12-13 13:59:13 +01:00
Paolo Tranquilli
03d7adb303 Swift: wrap extractor with shell script
This is in preparation for the extractor to use shared libraries
packaged alongside it.

We could probably also move the `CODEQL_EXTRACTOR_SWIFT_RUN_UNDER` logic
in it, where it would be simpler and more robust.
2022-12-13 09:07:37 +01:00
Paolo Tranquilli
7162692656 Swift: exit directly on actions not requiring extraction 2022-12-09 10:00:01 +01:00
Paolo Tranquilli
4a41bb4061 Merge branch 'main' into redsun82/swift-open-redirection 2022-12-09 09:59:21 +01:00
Paolo Tranquilli
bf1b32f210 Swift: rework file redirection
The hash map mechanism that was already in use for reading swiftmodule
files on macOS is now in use also on Linux. The output replacing
mechanism has been also reworked so that:
* frontend module emission modes have the remapping done directly in
  the internal frontend options instead of painstakingly modifying input
  flags (this requires a patch on the swift headers though)
* object emission mode is silenced to be just a type checking pass,
  thus producing no output files
* all other passes but some debugging and version related ones become
  noops

The open file read redirection uses a global weak pointer instance to
maximize robustness in the face of possibly multi-threaded calls to open
happening while `main` is exiting. Possibly overkill, but better safe
than sorry.
2022-12-08 16:10:44 +01:00
Paolo Tranquilli
1ba8b6d35a Swift: fix extraction of sources from .. 2022-12-08 15:57:57 +01:00
Alex Denisov
f5ddbd6abb Swift: add a test case showing case canonicalization 2022-12-02 14:06:21 +01:00
AlexDenisov
691188bc48 Merge pull request #11523 from github/alexdenisov/preserve-symlinks
Swift: resolve symlinks conditionally
2022-12-02 14:05:13 +01:00