Commit Graph

4438 Commits

Author SHA1 Message Date
Alex Denisov
c92576690f Swift: change the return types of getCanonicalPointer 2022-05-13 15:20:30 +02:00
Alex Denisov
2f00945a23 Swift: change the return types of getCanonicalPointer 2022-05-13 15:20:30 +02:00
Alex Denisov
039aaec6b7 Swift: make TrapLabelStore store untyped label internally 2022-05-13 15:20:30 +02:00
Alex Denisov
e584afb895 Swift: fix format 2022-05-13 15:20:30 +02:00
Alex Denisov
7b9f88637e Swift: describe TrapTagTraits API and implementation 2022-05-13 15:20:30 +02:00
Alex Denisov
efa4565af2 Swift: move generated code to generated directory 2022-05-13 15:20:29 +02:00
Paolo Tranquilli
f52119dc81 Merge branch 'main' into alexdenisov/introduce-dispatcher 2022-05-13 13:44:01 +02:00
Paolo Tranquilli
8cb9fd7eec Swift: publish C++ generated code as artifacts 2022-05-13 11:48:27 +02:00
Alex Denisov
d0e2e2bec8 Swift: introduce SwiftDispatcher 2022-05-12 14:09:44 +02:00
Alex Denisov
8f8ece63e7 Swift: add extractor test for declarations 2022-05-12 14:09:44 +02:00
Alex Denisov
cfd242e489 Swift: add human readable string representation for Location and UnkownAstNode 2022-05-12 14:09:44 +02:00
Paolo Tranquilli
ddb567b639 Swift: remove Tag nested alias in TrapLabel 2022-05-11 17:44:00 +02:00
Paolo Tranquilli
f1413f29c6 Swift: move back file opening code 2022-05-11 16:53:51 +02:00
Paolo Tranquilli
a46582d7d5 Swift: replace friend in TrapLabel with unsafeCreateFromExplicitId 2022-05-11 14:42:55 +02:00
Paolo Tranquilli
e679612a5a Swift: move most of TrapArena to TrapFile 2022-05-11 12:32:14 +02:00
Paolo Tranquilli
e63d079322 Swift: transfer TrapArena 2022-05-11 11:28:38 +02:00
Paolo Tranquilli
bf71e4c500 Swift: getPrimaryQlClass -> getAPrimaryQlClass 2022-05-10 12:42:18 +02:00
Paolo Tranquilli
0b9dc9703f Swift: changes required for TBD node rework
These changes are required to allow a new type-safe approach to TBD
nodes, that will come in a separate commit.

This introduces:
* the possibility to add properties to the root `Element`
* a functor taking tags to the corresponding binding trap entry
* `hasProp()` methods for optional properties in QL
* `getPrimaryQlClass()` method
2022-05-10 11:59:25 +02:00
Paolo Tranquilli
c08e6fdc1e Swift codegen: add predicate properties
Properties marked with `predicate` in the schema are now accepted.

* in the dbscheme, they will translate to a table with a single `id`
  column (and the table name will not be pluralized)
* in C++ classes, they will translate to `bool` fields
* in QL classes, they will translate to predicates

Closes https://github.com/github/codeql-c-team/issues/1016
2022-05-09 17:50:49 +02:00
Paolo Tranquilli
effa9ee207 Merge pull request #9034 from redsun82/swift-cpp-gen
Swift: add structured C++ generated classes
2022-05-09 17:49:23 +02:00
Paolo Tranquilli
93f8b6b29d Swift: add missing trap_affix 2022-05-09 12:20:22 +02:00
Paolo Tranquilli
20317a280b Swift: make width fields unsigned 2022-05-09 12:19:52 +02:00
Paolo Tranquilli
9c5b2d7e9d Swift: tweaks for use in the PoC branch 2022-05-09 09:46:47 +02:00
Paolo Tranquilli
918ba1b1fc Swift: make generator.run accept options 2022-05-09 09:34:49 +02:00
AlexDenisov
c21849bb2e Merge pull request #9015 from redsun82/swift-enable-dynamic-library
Swift: enable dynamic mode
2022-05-09 09:15:37 +02:00
Paolo Tranquilli
6cbfb5a10c Swift cppgen: emit final trap before bases 2022-05-09 09:02:20 +02:00
Paolo Tranquilli
a7129c1f4c Swift: add --ql-format/--no-ql-format to codegen 2022-05-05 18:33:05 +02:00
Paolo Tranquilli
b2b5fd281f Swift: add more parametrization
This enables codegen to run on the swift PoC branch.
2022-05-05 17:34:00 +02:00
Paolo Tranquilli
ac3cceab19 Swift: turn some generated paths to relative 2022-05-05 16:15:16 +02:00
Paolo Tranquilli
7bcc5db4a6 Swift: parametrize namespace and other things in codegen
This is so that we can use this in the PoC branch.
2022-05-05 16:01:54 +02:00
Paolo Tranquilli
c87fb4df53 Swift: remove now unused ql.Property.params 2022-05-05 12:01:13 +02:00
Paolo Tranquilli
9798d8ba26 Swift: add ?* modifier to schema specification
This indicates a list of optional entries. This is different than
simply repeatind entries because of the indexing.
2022-05-05 11:50:12 +02:00
Paolo Tranquilli
c2d3aac349 Swift: fix no functools.cache in python 3.8 2022-05-05 09:48:07 +02:00
Paolo Tranquilli
d5d1eb717d Swift: add structured C++ generated classes
This adds `cppgen`, creating structured C++ classes mirroring QL classes
out of `schema.yml`.

An example of generated code at the time of this commit can be found
[in this gist][1].

[1]: https://gist.github.com/redsun82/57304ddb487a8aa40eaa0caa695048fa

Closes https://github.com/github/codeql-c-team/issues/863
2022-05-04 18:20:25 +02:00
Paolo Tranquilli
10c5c8e71f Swift: add trapgen unit tests
Closes: https://github.com/github/codeql-c-team/issues/981
2022-05-04 18:20:06 +02:00
Paolo Tranquilli
c2be267feb Swift: enable dynamic mode
Providing `--dynamic_mode=fully` (for example setting it in
`local.bazelrc`) will now work.

All runfiles are now copied in the extractor pack: in dynamic mode,
those will be the executable and the dynamic libraries, while in static
mode only the executable will be part of the runfiles.

Setting the correct `LD_LIBRARY_PATH` in `qltest.sh` then allows to
run tests with this pakcage. If we need something more, we can switch to
a wrapper script in place of `extractor` in the future.

Notice that `LD_LIBRARY_PATH` is also set in static mode, but that has
no consequence.
2022-05-03 12:33:24 +02:00
AlexDenisov
5c6e5173ad Merge pull request #8959 from AlexDenisov/alexdenisov/pip-install-from-bazel
Swift: teach bazel to install python dependencies
2022-04-29 14:31:37 +02:00
Paolo Tranquilli
2fe38c2bbb Swift: cc wrapper rules 2022-04-29 14:18:36 +02:00
Alex Denisov
7332460268 Swift: teach bazel to install python dependencies 2022-04-29 14:05:36 +02:00
AlexDenisov
f6769735e5 Merge pull request #8939 from AlexDenisov/alexdenisov/swift-tracer-integration
Swift: tracer integration
2022-04-28 19:20:55 +02:00
AlexDenisov
a59d7f6a85 Update swift/extractor/main.cpp 2022-04-28 16:52:34 +02:00
Paolo Tranquilli
c4fae0806f Swift: use #pragma once 2022-04-28 16:39:27 +02:00
AlexDenisov
84bcc2e64a Merge branch 'main' into alexdenisov/swift-tracer-integration 2022-04-28 16:28:48 +02:00
Alex Denisov
85918173a6 Swift: ensure the folder for trap files exists 2022-04-28 13:19:25 +02:00
Alex Denisov
9c73ae5a97 Swift: teach extractor to not produce artifacts 2022-04-28 13:18:20 +02:00
Alex Denisov
5b75b4db79 Swift: add tracer config 2022-04-28 13:17:35 +02:00
Alex Denisov
4a03976a15 Swift: set compiler flags explicitly 2022-04-28 13:17:05 +02:00
Paolo Tranquilli
773ef62406 Swift: added trapgen
This checks in the trapgen script generating trap entries in C++.

The codegen suite has been slightly reorganized, moving the templates
directory up one level and chopping everything into smaller bazel
packages. Running tests is now done via
```
bazel run //swift/codegen/test
```

With respect to the PoC, the nested `codeql::trap` namespace has been
dropped in favour of a `Trap` prefix (or suffix in case of entries)
within the `codeql` namespace. Also, generated C++ code is not checked
in in git any more, and generated during build. Finally, labels get
printed in hex in the trap file.

`TrapLabel` is for the moment only default-constructible, so only one
single label is possible. `TrapArena`, that is responsible for creating
disjoint labels will come in a later commit.
2022-04-28 12:01:59 +02:00
Paolo Tranquilli
f95b5853c1 Merge pull request #8788 from AlexDenisov/alexdenisov/swift-first-extractor-test
Swift: file extraction
2022-04-27 17:47:17 +02:00
Mathias Vorreiter Pedersen
abbb7f861f Merge pull request #8904 from MathiasVP/sync-swift-schema
Swift: Sync schema after extractor changes
2022-04-27 16:14:46 +01:00