Commit Graph

146 Commits

Author SHA1 Message Date
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
146591934a Swift: clean up SwiftMangler 2023-05-02 10:45:43 +02:00
Paolo Tranquilli
0aed7d56c2 Swift: more mangling 2023-05-02 10:45:42 +02:00
Paolo Tranquilli
c8ca6057d3 Swift: mangle several new things 2023-05-02 10:45:40 +02:00
Nora Dimitrijević
90ad36ed6c Swift: update extractor 2023-04-26 15:47:19 +02: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
Paolo Tranquilli
1ed5f6ac96 Swift: flush log files on log flushing 2023-04-24 10:08:37 +02:00
Paolo Tranquilli
55f23ffa6f Merge branch 'main' into redsun82/swift-logging-assertions-and-prints 2023-04-21 09:18:48 +02:00
Paolo Tranquilli
60c723e7cc Swift: aggregate default output directories
In case the extractor is run in isolation for debugging/testing, this
will avoid littering the current working directory with artifacts, and
instead having a single `extractor-out` directory to inspect or clean
up.

Also extractor logs have been nested into a `swift` directory, as the
log directory provided by the `codeql` cli is actually shared between
languages.
2023-04-20 09:20:11 +02:00
Paolo Tranquilli
a1cec3e970 Swift: replace assertions and prints in the file library 2023-04-18 12:16:22 +02:00
Paolo Tranquilli
f965495ddf Swift: replace assertions and direct prints in SwiftDispatcher
Also added opt-in logging of undefined trap labels for all emissions
outside the `SwiftDispatcher`.
2023-04-18 12:16:22 +02:00
Paolo Tranquilli
f42975f132 Swift: add assertion and expectation macros 2023-04-18 11:48:45 +02:00
Paolo Tranquilli
cbe247e123 Merge branch 'main' into redsun82/swift-logging 2023-04-17 10:27:14 +02:00
Paolo Tranquilli
3f139bd93b Swift: address logging review comments 2023-04-17 10:27:01 +02:00
Alexandre Boulgakov
35a2d55d18 Swift: Extract structured keypath components.
Changes in swift/ql/lib are generated by swift/codegen without manual intervention.
2023-04-11 13:34:17 +01:00
Paolo Tranquilli
a5162b0b7d Swift: remove Log::configure 2023-04-06 12:53:13 +02:00
Paolo Tranquilli
6ef9088076 Swift: rename LOG_IMPL->LOG_WITH_LEVEL and strengthen it 2023-04-05 06:30:49 +02:00
Paolo Tranquilli
5a01feca6c Swift: expand Logger doc comment 2023-04-04 10:37:59 +02:00
Paolo Tranquilli
6c932bc807 Swift: address logging review comments 2023-04-04 10:28:11 +02:00
Paolo Tranquilli
abc0c7cf24 Swift: add trace logging of all trap emission 2023-04-03 11:47:24 +02:00
Paolo Tranquilli
a386c58371 Swift: add preliminary logging to dispatcher 2023-04-03 11:47:23 +02:00
Paolo Tranquilli
ed48065c2d Swift: add logging infrastructure 2023-04-03 11:47:23 +02:00
Alex Denisov
069598c9e1 Swift: consider declarations from non-swift modules as lazy
This change fixes all of the VALUE_NOT_IN_TYPE errors I'm seeing with
the integration tests on macOS.
2023-03-29 14:02:56 +02:00
Paolo Tranquilli
a131966066 Swift: make SuccessfullyExtractedFiles.ql more precise
This is done by adding a `isSuccessfullyExtracted` predicate that is
filled for primary files at the very end of the extractor invocation if
the frontend was performed successfully. If for example the extractor
crashes this will therefore not be filled.

The upgrade script is written so that `SuccessfullyExtractedFiles.ql`
on an upgraded script will give exactly the same results as before it.
2023-03-20 08:34:34 +01:00
Alex Denisov
60c1505097 Swift: address review comments 2023-03-03 10:26:44 +01:00
Alex Denisov
ffcb382705 Swift: only consider Builting and __ObjC declarations as lazy 2023-03-02 20:00:23 +01:00
Alex Denisov
ded0e570b0 Swift: extract lazy declarations 2023-03-01 15:22:22 +01:00
Alex Denisov
def9831180 Swift: move decision making out of dispatcher 2023-03-01 12:02:58 +01:00
Alex Denisov
b1aef82117 Swift: move location extraction logic into a separate class 2023-03-01 11:32:50 +01:00
Alex Denisov
712c25e6f4 Swift: extract availability info 2023-02-07 14:26:39 +01:00
Nora Dimitrijević
6895c113cf Swift: extract closure captures (hand-written part) 2023-02-02 11:30:33 +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
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
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
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
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
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
Alex Denisov
7a3beac494 Swift: resolve symlinks conditionally 2022-12-02 10:07:10 +01:00
Paolo Tranquilli
1b6a50147a Merge branch 'main' into redsun82/swift-type-mapping
Conflict resolved on addition of `AbiSafeConversionExpr`
2022-12-02 09:02:47 +01:00
Alex Denisov
0bfe502bb0 Swift: remove patches from the extractor
Moved elsewhere https://github.com/dsp-testing/codeql-swift-artifacts/pull/3
2022-11-30 15:36:09 +01:00
Alex Denisov
67fb56deb8 Swift: workaround an internal crash coming from Swift 5.7.1 2022-11-30 12:40:42 +01:00