Commit Graph

547 Commits

Author SHA1 Message Date
Alex Denisov
4f05f083a5 Swift: split SwiftLocationExtractor into h/cpp 2022-11-08 15:02:22 +01:00
Alex Denisov
609c7cf84d Swift: Rename diagnostics consumer 2022-11-08 14:56:50 +01:00
Alex Denisov
680b7a16fb Swift: extract location extraction into a separate entity 2022-11-08 14:41:10 +01:00
Alex Denisov
b62a4aae1a Swift: include null terminators into the invocation file hash 2022-11-08 14:36:28 +01:00
Alex Denisov
433f4e0cb5 Swift: use DbFile/DbLocation 2022-11-08 14:36:28 +01:00
Alex Denisov
b39cf7ea11 Swift: diagnostics: fix bazel build 2022-11-08 14:36:28 +01:00
Alex Denisov
1574e855eb Swift: consume and store compiler frontend diagnostics 2022-11-08 14:36:28 +01:00
Paolo Tranquilli
fda9d19a97 Swift: replace undefined labels with UnspecifiedElement 2022-11-08 11:47:12 +01:00
Paolo Tranquilli
8d3e6ff8a7 Swift: add label iteration 2022-11-08 11:47:12 +01:00
Paolo Tranquilli
b30a6d36b5 Swift: extract AwaitExpr 2022-11-07 12:08:51 +01:00
Paolo Tranquilli
b94066acd8 Merge pull request #11094 from github/redsun82/swift-translators
Swift: refactor visitors to use translations
2022-11-07 12:01:44 +01:00
Paolo Tranquilli
3a8efb3db1 Swift: make visit arguments pointers again 2022-11-04 06:06:05 +01:00
Paolo Tranquilli
e0eb820ef9 Swift: fix extraction of BuiltinIntegerLiteralType 2022-11-03 18:16:54 +01:00
Paolo Tranquilli
a1d798b817 Swift: make visit arguments references instead of pointers 2022-11-03 18:16:53 +01:00
Paolo Tranquilli
cc9dafffde Swift: encapsulate swift::ASTVisitor functionality 2022-11-03 18:16:53 +01:00
Paolo Tranquilli
7c9fffc201 Swift: rename all visitors to translators 2022-11-03 18:16:53 +01:00
Paolo Tranquilli
75f30a8f9c Swift: refactor ExprVisitor to use translations 2022-11-03 18:16:53 +01:00
Paolo Tranquilli
a6b1806e66 Swift: refactor TypeVisitor to use translations 2022-11-03 18:16:53 +01:00
Paolo Tranquilli
c8cb30f76e Swift: refactor StmtVisitor to use translations
Also make `visit` in `SwiftDispatcher` work on `const` pointers.

Also, fixed a bug where the guard of a `CaseLabelItem` was not being
extracted, hence the test updates.
2022-11-03 18:16:53 +01:00
Paolo Tranquilli
faf10294ed Swift: refactor PatternVisitor to use translations 2022-11-03 18:16:53 +01:00
Paolo Tranquilli
82998ce3a3 Merge branch 'main' into redsun82/swift-filtered-debugging 2022-11-02 06:39:16 +01:00
Paolo Tranquilli
46c7ee0e4f Swift: refactor RUN_UNDER code 2022-10-31 09:51:20 +01:00
Paolo Tranquilli
80debe19e0 Swift: fix RUN_UNDER_FILTER check 2022-10-31 09:50:45 +01:00
Paolo Tranquilli
3dcdc739de Swift: add possibility to run the extractor under an env-specified tool
if `CODEQL_EXTRACTOR_SWIFT_RUN_UNDER` env variable is set, and either
* `CODEQL_EXTRACTOR_SWIFT_RUN_UNDER_FILTER` is not set, or
* it is set to a regexp matching any substring of the extractor call
then the extractor process is substituted with the command (and possibly
options) stated in `CODEQL_EXTRACTOR_SWIFT_RUN_UNDER`, followed by the
system arguments of the extractor itself (which should include the
extractor program itself at the start).

Before calling `exec`, `CODEQL_EXTRACTOR_SWIFT_RUN_UNDER` is unset to
avoid unpleasant loops.

An example usage is to run the extractor under `gdbserver :1234` when
the arguments match a given source file.
2022-10-28 14:12:27 +02:00
Paolo Tranquilli
a87495226a Swift: fix remapping
With the change to `std::filesystem` some path concatenations were
translated to appending, which is not the same. In case rhs is absolute
`lhs / rhs == rhs`, while concatenating treats `rhs` as if it was
relative. The same behaviour can be obtained in `std::filesystem` by
using `lhs / rhs.relative_path()`.
2022-10-28 11:16:49 +02:00
Paolo Tranquilli
3fca25310f Swift: fix copy option 2022-10-27 09:29:05 +02:00
Paolo Tranquilli
22db4932ee Swift: add overwrite_existing to source archiving 2022-10-27 09:26:57 +02:00
Paolo Tranquilli
521e6235b5 Swift: use std::filesystem and picoSHA2
This replaces usages of `llvm::fs` and string manipulation with
`std::filesystem`, also replacing `std::string` with
`std::filesystem::path` where it made sense.

Moreover MD5 hashing used in macOS file remapping was replaced by
SHA256 hashing using a small header-only SHA256 C++ library with an
MIT license, https://github.com/okdshin/PicoSHA2.

File contents hashing was relocated to the newly created `file` library
for later planned reuse.
2022-10-26 13:23:44 +02:00
Paolo Tranquilli
e422a4eef9 Swift: move TargetFile to a separate lib 2022-10-26 10:54:51 +02:00
Paolo Tranquilli
c8788bb5cd Swift: move libraries from tools to third_party 2022-10-26 07:05:56 +02:00
Paolo Tranquilli
789be9a1ad Swift: add ImplicitConversionExpr test 2022-10-17 12:57:44 +02:00
Paolo Tranquilli
e4bcea708e Swift: extract all ImplicitConversionExpr
In order to do so, `VisitorBase` was changed to allow writing one
`translate` function for an abstract class like
`ImplicitConversionExpr`.
2022-10-17 12:47:05 +02:00
Paolo Tranquilli
7ad3d8776b Merge branch 'main' into redsun82/cmake-generator-prototype 2022-10-14 10:13:12 +02:00
Paolo Tranquilli
14f2d3995a Swift: make generate_cmake public 2022-10-14 10:01:10 +02:00
Josh Soref
0a508726e0 spelling: canonicalization
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2022-10-13 19:42:46 -04:00
Paolo Tranquilli
b8b6b254bb Swift: cmake generator for better IDE support
A cmake generator in bazel is introduced allowing to import the Swift
extractor as a CMake project while keeping Bazel files as the source of
truth for the build.

Using the CMake project:
* requires bazel and clang to be installed and available on the command
  line
* does not require a previous bazel build, however
* will require a CMake reconfiguration for changes to generated code
  (like changes to the schema)
2022-10-13 15:25:24 +02:00
Alex Denisov
e4731fd41f Swift: redirect more artfacts 2022-09-22 11:17:07 +02:00
Alex Denisov
6a08b8dcfb Swift: getSequence was renamed 2022-09-22 11:17:07 +02:00
Alex Denisov
13fe02edfa Swift: NestedArchetypeType was removed 2022-09-22 11:17:04 +02:00
Paolo Tranquilli
a67341c53b Revert "Swift: make unknown entity type check more solid"
This reverts commit b52a4e19c1.
2022-09-21 18:01:59 +02:00
Paolo Tranquilli
b52a4e19c1 Swift: make unknown entity type check more solid 2022-09-21 16:44:34 +02:00
Paolo Tranquilli
96897a0cdc Swift: implement python schema
The information that was contained in `schema.yml` is now in
`swift/schema.py`, which allows a more integrated IDE experience
for writing and navigating it.

Another minor change is that `schema.Class` now has a `str` `group`
field instead of a `pathlib.Path` `dir` one.
2022-09-21 15:53:09 +02:00
Paolo Tranquilli
b4df557c5a Merge branch 'main' into redsun82/swift-do-not-extract-inactive-ifconfig-clauses 2022-09-20 15:41:34 +02:00
Paolo Tranquilli
250965b140 Swift: update extractor for TypeRepr changes 2022-09-20 15:24:51 +02:00
Paolo Tranquilli
0e62d6f123 Swift: update extractor to new IfConfigDecl 2022-09-20 15:12:37 +02:00
Alex Denisov
c020bee529 Swift: remove VFS related code 2022-09-20 15:06:25 +02:00
Alex Denisov
3c12644ab1 Swift: add a guard around hashing to aboid use-after-destructor 2022-09-19 10:37:26 +02:00
Alex Denisov
c638789f3e Swift: open(2) interception 2022-09-16 12:02:16 +02:00
Paolo Tranquilli
43e5abac39 Swift: do not extract unresolved things from IfConfigDecl
This avoids extracting things that are unresolved within an
`IfConfigDecl` instance:
* all conditions
* all inactive code blocks
This is meant to test out the hypothesis that this should solve some
extractor issues. If going through with it we should definitely change
the schema model for this.

Also, tests have not been updated and are expected to fail.
2022-09-12 16:34:28 +02:00
Paolo Tranquilli
c9b14b4459 Swift: address review comments 2022-08-26 12:49:19 +02:00