151 Commits

Author SHA1 Message Date
Tom Hvitved
d77b35c5d2 Codegen: Add Raw::getImmediateChild and Synth::getSynthParent 2025-11-09 20:39:38 +01:00
Paolo Tranquilli
de72e68d2c Merge branch 'main' into redsun82/codegen-new-parent-child 2025-06-26 12:14:53 +02:00
Paolo Tranquilli
355fd85c23 Codegen: remove unneeded has|getNumberOf in instance tests 2025-06-25 12:02:13 +02:00
Paolo Tranquilli
6bbf1e3bc1 Codegen: use one generated test file per directory
This collapses all generated test QL sources into a single one per
directory, using query predicates to run the different tests.

This should improve the time required to run generated tests.
2025-06-25 11:44:54 +02:00
Paolo Tranquilli
1dcd60527c Codegen: improve implementation of generated parent/child relationship
This improves the implementation of the generated parent/child
relationship by adding a new `all_children` field to `ql.Class` which
lists all children (both direct and inherited) of a class, carefully
avoiding duplicating children in case of diamond inheritance. This:
* simplifies the generated code,
* avoid children ambiguities in case of diamond inheritance.

This only comes with some changes in the order of children in the
generated tests (we were previously sorting bases alphabetically there).
For the rest this should be a non-functional change.
2025-06-24 17:26:24 +02:00
Paolo Tranquilli
0d292b785c Rust: remove reduntant Item superclass from Adt subclasses 2025-06-20 15:45:18 +02:00
Paolo Tranquilli
e935bd6faf Rust: expand derive macros 2025-06-20 11:19:06 +02:00
Paolo Tranquilli
55eb9fb838 Merge pull request #19712 from github/redsun82/python-black
Add `black` pre-commit hook
2025-06-12 20:49:56 +02:00
Paolo Tranquilli
14d48e9d58 Add black pre-commit hook
This switched `codegen` from the `autopep8` formatting to the `black`
one, and applies it to `bulk_mad_generator.py` as well. We can enroll
more python scripts to it in the future.
2025-06-10 12:25:39 +02:00
Paolo Tranquilli
77c40da51a Rust/Codegen: fix detached predicates 2025-06-03 10:41:31 +02:00
Paolo Tranquilli
9958cc7784 Codegen: consider windows paths in local codeql binary heuristic 2025-04-30 11:43:03 +02:00
Paolo Tranquilli
ba89a5de6f Codegen: make missing codeql error clearer 2025-04-30 11:38:52 +02:00
Tom Hvitved
4fb138a1a3 Rust: Make Element.toString non-recursive 2025-04-01 08:48:13 +02:00
Paolo Tranquilli
a762e518c6 Merge branch 'main' into redsun82/codegen-rename-dbscheme 2025-03-20 15:52:49 +01:00
Paolo Tranquilli
4110636032 Rust: preserve ordering in rust generated code
This is a small devex improvement to the rust code generator.

Usage of `sorted` in `rustgen.py` was causing the generated code to be
completely reshuffled on renames, which made diffs hard to follow. As an
example see [this generated file diff](https://github.com/github/codeql/pull/19059/files#diff-c938ba77a3398dd4c633ada5702a03477705c24740a2f7d1e40d4b270d8c3f86).

This will make the order deterministically based on the order of
definitions in the schema file. This means that renames will find the
same place in the generated file, and the place in the generated file
will generally be more predictable with respect to the schema.

However, that does mean this change is heavily reshuffling the generated
code.
2025-03-20 12:12:52 +01:00
Paolo Tranquilli
7c8eb9ea0d Codegen: implement db_table_name in cppgen 2025-03-19 15:14:15 +01:00
Paolo Tranquilli
9639d6c8bb Codegen: implement db_table_name in rustgen 2025-03-19 15:14:15 +01:00
Paolo Tranquilli
f48aa79927 Codegen: implement db_table_name in qlgen 2025-03-19 15:14:15 +01:00
Paolo Tranquilli
fc9e066ecd Codegen: implement db_table_name in dbschemegen 2025-03-19 15:14:14 +01:00
Paolo Tranquilli
841214f0f4 Codegen: introduce property-only pragmas 2025-03-19 15:14:14 +01:00
Paolo Tranquilli
91b7329652 Codegen: update dependencies 2025-03-19 15:14:13 +01:00
Paolo Tranquilli
53c235dfd5 Bazel: bump python version to 3.12 2025-03-19 15:14:13 +01:00
Paolo Tranquilli
06b349e307 Codegen: introduce name conflict error in dbschemegen 2025-03-19 12:15:45 +01:00
Paolo Tranquilli
bed7ab51d4 Merge pull request #19029 from github/reddsun82/swift-ql-test-to-internal
Swift: simplify `codeql` workflow
2025-03-18 08:50:34 +01:00
Paolo Tranquilli
622aa7c170 Swift: simplify codeql workflow
* remove ql test running and upgrade/downgrade scripts checking (now
  done internally)
* removed all the bazel caching stuff, that never really worked any way
* moved `misc/codegen` generic testing to a separate workflow, as it's
  not swift specific any more
* reinstanted checking that the extractor can be built locally from
  the `codeql` repo.
2025-03-14 16:13:58 +01:00
Tom Hvitved
d1ad65ae09 Rust: Cache Element.toString 2025-03-14 11:58:38 +01:00
Tom Hvitved
8777bc42c7 Rust: Add get(Immediate)Child predicate 2025-03-13 11:13:01 +01:00
Tom Hvitved
e78b79fa45 Update misc/codegen/lib/ql.py
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-02-03 09:11:13 +01:00
Tom Hvitved
ec33457ad4 Codegen: Improve return type of self-typed properties 2025-02-03 09:11:09 +01:00
Cornelius Riemenschneider
53ca5083a9 Upgrade bazel to 8.0.0.
Previously, we were using 8.0.0rc1.
In particular, this upgrade means we need to explicitly
import more rules, as they've been moved out of the core bazel repo.
2024-12-10 12:05:37 +01:00
Paolo Tranquilli
31b9b3adaa Merge branch 'main' into redsun82/rust-perf-measures 2024-12-04 10:50:37 +01:00
Paolo Tranquilli
db18d1046b Rust: rename getTy -> getTypeRepr 2024-12-03 11:17:08 +01:00
Paolo Tranquilli
b57a37479b Rust: make File usable in codegen 2024-12-02 15:15:46 +01:00
Paolo Tranquilli
99bd75c429 Rust: expand Ty in documentation 2024-12-02 09:51:15 +01:00
Paolo Tranquilli
5d3c9d050d Rust: expand Pat in documentation 2024-12-02 09:48:10 +01:00
Paolo Tranquilli
261e0a1a53 Codegen/Rust: allow renaming in QL
This adds a `ql.name` codegen pragma to change the name of a property on
the QL side. This is useful to give more meaningful names than what we
get from the generated rust AST.
2024-11-25 17:04:03 +01:00
Tom Hvitved
86a7c486f9 Rust: "control-flow" -> "control flow" 2024-11-21 10:42:11 +01:00
Tom Hvitved
be7aca9780 Address review comments 2024-11-21 10:32:06 +01:00
Tom Hvitved
c8736e8a3d Rust: Auto-generate CfgNodes.qll 2024-11-21 10:21:11 +01:00
Paolo Tranquilli
bd08bc7923 Rust: address review 2024-10-15 14:21:11 +02:00
Tom Hvitved
b284a2a7c0 Rust: Add Callable as a base class of Function and ClosureExpr 2024-10-11 12:00:30 +02:00
Paolo Tranquilli
c364fd7e56 Codegen: allow annotations to replace bases and drop fields 2024-10-10 14:33:06 +02:00
Tom Hvitved
062127b42e Codegen: Do not cache injectors/projectors in Synth module 2024-09-24 14:41:20 +02:00
Arthur Baars
04e3b39ffb Merge pull request #17537 from github/redsun82/rust-doctest-gen
Rust: take test code also from property descriptions
2024-09-23 11:41:32 +02:00
Arthur Baars
05173fa7ac Merge pull request #17539 from github/redsun82/rust-codegen-detach
Rust/Codegen: allow to "detach" property emission
2024-09-23 11:40:11 +02:00
Paolo Tranquilli
c74b6be136 Rust/Codegen: allow to "detach" property emission
By using the `rust.detach` pragma on a property, we make that property
not appear in the generated struct as a field, and provide instead
a `generated::Class::emit_property` function that can be used to emit
the corresponding TRAP entry independently.
2024-09-20 16:06:22 +02:00
Paolo Tranquilli
2a95068a0a Rust: take test code also from property descriptions 2024-09-20 15:12:13 +02:00
Paolo Tranquilli
4e59fa9035 Codegen: remove unneeded code 2024-09-20 12:47:45 +02:00
Paolo Tranquilli
f7afcd038a Codegen: move use_for_null to pragmas 2024-09-20 12:47:45 +02:00
Paolo Tranquilli
d2ebe00492 Codegen: move group to parametrized pragmas 2024-09-20 12:47:44 +02:00