Commit Graph

560 Commits

Author SHA1 Message Date
Paolo Tranquilli
235181fb21 Swift: share translateDiagnosticsKind with SwiftDiagnosticsConsumer 2022-11-09 12:00:43 +01:00
Paolo Tranquilli
7bcee6e9a8 Merge branch 'main' into redsun82/swift-decls 2022-11-09 11:59:16 +01:00
AlexDenisov
8756989b4b Merge pull request #11101 from github/alexdenisov/extractor-errors
Swift: extract diagnostics
2022-11-09 11:33:54 +01:00
Paolo Tranquilli
73ad1307ae Swift: extract PoundDiagnosticDecl 2022-11-09 11:13:55 +01:00
Paolo Tranquilli
b399d8df7e Swift: extract opaque types and their decls 2022-11-09 09:27:25 +01:00
Paolo Tranquilli
53b7584a90 Merge pull request #11169 from github/redsun82/swift-extract-last-stmts
Swift: extract remaining `Stmt`s
2022-11-08 20:51:10 +01:00
Paolo Tranquilli
9ee4f8b388 Swift: extract remaining Stmts
`FailStmt` are `return nil` in fallible initializers.

`PoundAssertStmt` are an experimental feature for compile time
assertions.
2022-11-08 17:38:17 +01:00
Paolo Tranquilli
00d3ff8a18 Swift: extract UnaryPostfixExpr 2022-11-08 17:10:33 +01:00
Paolo Tranquilli
d325a42890 Swift: print unextracted entities 2022-11-08 15:38:53 +01:00
Alex Denisov
3f2f328d87 Swift: put invocation files into a separate folder 2022-11-08 15:32:51 +01:00
Alex Denisov
096469c6fe Swift: use timestamp + getpid for the invocation filename 2022-11-08 15:26:35 +01:00
Alex Denisov
42004d93f0 Swift: cleanup diagnostic message construction 2022-11-08 15:07:01 +01:00
Alex Denisov
d9b3104c78 Swift: remove unneeded include 2022-11-08 15:03:43 +01:00
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