diff --git a/.github/labeler.yml b/.github/labeler.yml index db5a336716e5..0e43646c7ba2 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -30,6 +30,10 @@ Ruby: - ruby/**/* - change-notes/**/*ruby* +Rust: + - rust/**/* + - change-notes/**/*rust* + Swift: - swift/**/* - change-notes/**/*swift* diff --git a/.github/workflows/check-change-note.yml b/.github/workflows/check-change-note.yml index 026408a028d5..3330e6e1136d 100644 --- a/.github/workflows/check-change-note.yml +++ b/.github/workflows/check-change-note.yml @@ -16,11 +16,12 @@ on: - "shared/**/*.qll" - "!**/experimental/**" - "!ql/**" + - "!rust/**" - ".github/workflows/check-change-note.yml" jobs: check-change-note: - env: + env: REPO: ${{ github.repository }} PULL_REQUEST_NUMBER: ${{ github.event.number }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -33,7 +34,7 @@ jobs: !contains(github.event.pull_request.labels.*.name, 'no-change-note-required') run: | change_note_files=$(gh api "repos/$REPO/pulls/$PULL_REQUEST_NUMBER/files" --paginate --jq '.[].filename | select(test("/change-notes/.*[.]md$"))') - + if [ -z "$change_note_files" ]; then echo "No change note found. Either add one, or add the 'no-change-note-required' label." exit 1 diff --git a/.github/workflows/ruby-build.yml b/.github/workflows/ruby-build.yml index 4a3242ce6041..fcabff5d110e 100644 --- a/.github/workflows/ruby-build.yml +++ b/.github/workflows/ruby-build.yml @@ -65,8 +65,8 @@ jobs: id: cache-extractor with: path: | - ruby/extractor/target/release/codeql-extractor-ruby - ruby/extractor/target/release/codeql-extractor-ruby.exe + target/release/codeql-extractor-ruby + target/release/codeql-extractor-ruby.exe ruby/extractor/ql/lib/codeql/ruby/ast/internal/TreeSitter.qll key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-extractor-${{ hashFiles('ruby/extractor/rust-toolchain.toml', 'ruby/extractor/Cargo.lock') }}-${{ hashFiles('shared/tree-sitter-extractor') }}-${{ hashFiles('ruby/extractor/**/*.rs') }} - uses: actions/cache@v3 @@ -75,7 +75,7 @@ jobs: path: | ~/.cargo/registry ~/.cargo/git - ruby/target + target key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-rust-cargo-${{ hashFiles('ruby/extractor/rust-toolchain.toml', 'ruby/extractor/**/Cargo.lock') }} - name: Check formatting if: steps.cache-extractor.outputs.cache-hit != 'true' @@ -91,7 +91,7 @@ jobs: run: cd extractor && cargo build --release - name: Generate dbscheme if: ${{ matrix.os == 'ubuntu-latest' && steps.cache-extractor.outputs.cache-hit != 'true'}} - run: extractor/target/release/codeql-extractor-ruby generate --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll + run: ../target/release/codeql-extractor-ruby generate --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll - uses: actions/upload-artifact@v3 if: ${{ matrix.os == 'ubuntu-latest' }} with: @@ -106,8 +106,8 @@ jobs: with: name: extractor-${{ matrix.os }} path: | - ruby/extractor/target/release/codeql-extractor-ruby - ruby/extractor/target/release/codeql-extractor-ruby.exe + target/release/codeql-extractor-ruby + target/release/codeql-extractor-ruby.exe retention-days: 1 compile-queries: if: github.repository_owner == 'github' diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml new file mode 100644 index 000000000000..bdecc2ebdd72 --- /dev/null +++ b/.github/workflows/rust.yml @@ -0,0 +1,51 @@ +name: "Rust" + +on: + pull_request: + paths: + - "rust/**" + - "misc/bazel/**" + - "misc/codegen/**" + - "shared/**" + - "MODULE.bazel" + - .github/workflows/rust.yml + - .github/actions/** + - codeql-workspace.yml + - "!**/*.md" + - "!**/*.qhelp" + branches: + - rust-experiment + - main + - rc/* + - codeql-cli-* + +permissions: + contents: read + +jobs: + rust-check: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Format + working-directory: rust/extractor + shell: bash + run: | + cargo fmt --check + - name: Compilation + working-directory: rust/extractor + shell: bash + run: cargo check + - name: Clippy + working-directory: rust/extractor + shell: bash + run: | + cargo clippy --fix + git diff --exit-code + - name: Code generation + shell: bash + run: | + bazel run //rust/codegen + git add . + git diff --exit-code HEAD diff --git a/.gitignore b/.gitignore index 445faf8efafa..9a9a423425df 100644 --- a/.gitignore +++ b/.gitignore @@ -65,3 +65,9 @@ node_modules/ # bazel-built in-tree extractor packs /*/extractor-pack + +# Jetbrains IDE files +.idea + +# cargo build directory +/target diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 45935401beeb..cf38289452db 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -5,9 +5,9 @@ repos: rev: v3.2.0 hooks: - id: trailing-whitespace - exclude: /test/.*$(? argparse.Namespace: p = argparse.ArgumentParser(description="Code generation suite") p.add_argument("--generate", type=lambda x: x.split(","), - help="specify what targets to generate as a comma separated list, choosing among dbscheme, ql, trap " - "and cpp") + help="specify what targets to generate as a comma separated list, choosing among dbscheme, ql, " + "trap, cpp and rust") p.add_argument("--verbose", "-v", action="store_true", help="print more information") p.add_argument("--quiet", "-q", action="store_true", help="only print errors") p.add_argument("--configuration-file", "-c", type=_abspath, default=conf, @@ -57,6 +57,9 @@ def _parse_args() -> argparse.Namespace: p.add_argument("--cpp-output", help="output directory for generated C++ files, required if trap or cpp is provided to " "--generate"), + p.add_argument("--rust-output", + help="output directory for generated Rust files, required if rust is provided to " + "--generate"), p.add_argument("--generated-registry", help="registry file containing information about checked-in generated code. A .gitattributes" "file is generated besides it to mark those files with linguist-generated=true. Must" diff --git a/misc/codegen/generators/__init__.py b/misc/codegen/generators/__init__.py index 985c4b25c126..beeeabbecdfc 100644 --- a/misc/codegen/generators/__init__.py +++ b/misc/codegen/generators/__init__.py @@ -1,4 +1,4 @@ -from . import dbschemegen, qlgen, trapgen, cppgen +from . import dbschemegen, trapgen, cppgen, rustgen, rusttestgen, qlgen def generate(target, opts, renderer): diff --git a/misc/codegen/generators/qlgen.py b/misc/codegen/generators/qlgen.py index 305f5d866b25..36a490f897a3 100755 --- a/misc/codegen/generators/qlgen.py +++ b/misc/codegen/generators/qlgen.py @@ -26,6 +26,7 @@ import subprocess import typing import itertools +import os import inflection @@ -287,7 +288,7 @@ def _is_under_qltest_collapsed_hierarchy(cls: schema.Class, lookup: typing.Dict[ _is_in_qltest_collapsed_hierarchy(lookup[b], lookup) for b in cls.bases) -def _should_skip_qltest(cls: schema.Class, lookup: typing.Dict[str, schema.Class]): +def should_skip_qltest(cls: schema.Class, lookup: typing.Dict[str, schema.Class]): return "qltest_skip" in cls.pragmas or not ( cls.final or "qltest_collapse_hierarchy" in cls.pragmas) or _is_under_qltest_collapsed_hierarchy( cls, lookup) @@ -370,8 +371,10 @@ def generate(opts, renderer): imports = {} generated_import_prefix = get_import(out, opts.root_dir) + registry = opts.generated_registry or pathlib.Path( + os.path.commonpath((out, stub_out, test_out)), ".generated.list") - with renderer.manage(generated=generated, stubs=stubs, registry=opts.generated_registry, + with renderer.manage(generated=generated, stubs=stubs, registry=registry, force=opts.force) as renderer: db_classes = [cls for name, cls in classes.items() if not data.classes[name].synth] @@ -413,7 +416,7 @@ def generate(opts, renderer): if test_out: for c in data.classes.values(): - if _should_skip_qltest(c, data.classes): + if should_skip_qltest(c, data.classes): continue test_with = data.classes[c.test_with] if c.test_with else c test_dir = test_out / test_with.group / test_with.name diff --git a/misc/codegen/generators/rustgen.py b/misc/codegen/generators/rustgen.py new file mode 100644 index 000000000000..9b850c3cf1be --- /dev/null +++ b/misc/codegen/generators/rustgen.py @@ -0,0 +1,109 @@ +""" +Rust trap class generation +""" + +import functools +import typing + +import inflection + +from misc.codegen.lib import rust, schema +from misc.codegen.loaders import schemaloader + + +def _get_type(t: str) -> str: + match t: + case None: # None means a predicate + return "bool" + case "string": + return "String" + case "int": + return "usize" + case _ if t[0].isupper(): + return "trap::Label" + case "boolean": + assert False, "boolean unsupported" + case _: + return t + + +def _get_field(cls: schema.Class, p: schema.Property) -> rust.Field: + table_name = inflection.tableize(cls.name) + if not p.is_single: + table_name = f"{cls.name}_{p.name}" + if p.is_predicate: + table_name = inflection.underscore(table_name) + else: + table_name = inflection.tableize(table_name) + args = dict( + field_name=rust.avoid_keywords(p.name), + base_type=_get_type(p.type), + is_optional=p.is_optional, + is_repeated=p.is_repeated, + is_predicate=p.is_predicate, + is_unordered=p.is_unordered, + table_name=table_name, + ) + args.update(rust.get_field_override(p.name)) + return rust.Field(**args) + + +def _get_properties( + cls: schema.Class, lookup: dict[str, schema.Class], +) -> typing.Iterable[tuple[schema.Class, schema.Property]]: + for b in cls.bases: + yield from _get_properties(lookup[b], lookup) + for p in cls.properties: + yield cls, p + + +class Processor: + def __init__(self, data: schema.Schema): + self._classmap = data.classes + + def _get_class(self, name: str) -> rust.Class: + cls = self._classmap[name] + return rust.Class( + name=name, + fields=[ + _get_field(c, p) + for c, p in _get_properties(cls, self._classmap) + if "rust_skip" not in p.pragmas and not p.synth + ], + table_name=inflection.tableize(cls.name), + ) + + def get_classes(self): + ret = {"": []} + for k, cls in self._classmap.items(): + if not cls.synth and not cls.derived: + ret.setdefault(cls.group, []).append(self._get_class(cls.name)) + return ret + + +def generate(opts, renderer): + assert opts.rust_output + processor = Processor(schemaloader.load_file(opts.schema)) + out = opts.rust_output + groups = set() + with renderer.manage(generated=out.rglob("*.rs"), + stubs=(), + registry=out / ".generated.list", + force=opts.force) as renderer: + for group, classes in processor.get_classes().items(): + group = group or "top" + groups.add(group) + renderer.render( + rust.ClassList( + classes, + opts.schema, + ), + out / f"{group}.rs", + ) + renderer.render( + rust.ModuleList( + groups, + opts.schema, + ), + out / f"mod.rs", + ) diff --git a/misc/codegen/generators/rusttestgen.py b/misc/codegen/generators/rusttestgen.py new file mode 100644 index 000000000000..e834b9c393ec --- /dev/null +++ b/misc/codegen/generators/rusttestgen.py @@ -0,0 +1,64 @@ +import dataclasses +import typing +import inflection + +from misc.codegen.loaders import schemaloader +from . import qlgen + + +@dataclasses.dataclass +class Param: + name: str + type: str + first: bool = False + + +@dataclasses.dataclass +class Function: + name: str + signature: str + + +@dataclasses.dataclass +class TestCode: + template: typing.ClassVar[str] = "rust_test_code" + + code: str + function: Function | None = None + + +def generate(opts, renderer): + assert opts.ql_test_output + schema = schemaloader.load_file(opts.schema) + with renderer.manage(generated=opts.ql_test_output.rglob("gen_*.rs"), + stubs=(), + registry=opts.ql_test_output / ".generated_tests.list", + force=opts.force) as renderer: + for cls in schema.classes.values(): + if (qlgen.should_skip_qltest(cls, schema.classes) or + "rust_skip_test_from_doc" in cls.pragmas or + not cls.doc): + continue + code = [] + adding_code = False + has_code = False + for line in cls.doc: + match line, adding_code: + case "```", _: + adding_code = not adding_code + has_code = True + case _, False: + code.append(f"// {line}") + case _, True: + code.append(line) + if not has_code: + continue + test_name = inflection.underscore(cls.name) + signature = cls.rust_doc_test_function + fn = signature and Function(f"test_{test_name}", signature) + if fn: + indent = 4 * " " + code = [indent + l for l in code] + test_with = schema.classes[cls.test_with] if cls.test_with else cls + test = opts.ql_test_output / test_with.group / test_with.name / f"gen_{test_name}.rs" + renderer.render(TestCode(code="\n".join(code), function=fn), test) diff --git a/misc/codegen/lib/rust.py b/misc/codegen/lib/rust.py new file mode 100644 index 000000000000..ac7bf4313d3f --- /dev/null +++ b/misc/codegen/lib/rust.py @@ -0,0 +1,138 @@ +import dataclasses +import re +import typing + +# taken from https://doc.rust-lang.org/reference/keywords.html +keywords = { + "as", + "break", + "const", + "continue", + "crate", + "else", + "enum", + "extern", + "false", + "fn", + "for", + "if", + "impl", + "in", + "let", + "loop", + "match", + "mod", + "move", + "mut", + "pub", + "ref", + "return", + "self", + "Self", + "static", + "struct", + "super", + "trait", + "true", + "type", + "unsafe", + "use", + "where", + "while", + "async", + "await", + "dyn", + "abstract", + "become", + "box", + "do", + "final", + "macro", + "override", + "priv", + "typeof", + "unsized", + "virtual", + "yield", + "try", +} + + +def avoid_keywords(s: str) -> str: + return s + "_" if s in keywords else s + + +_field_overrides = [ + (re.compile(r"(.*)_"), lambda m: {"field_name": m[1]}), +] + + +def get_field_override(field: str): + for r, o in _field_overrides: + m = r.fullmatch(field) + if m: + return o(m) if callable(o) else o + return {} + + +@dataclasses.dataclass +class Field: + field_name: str + base_type: str + table_name: str + is_optional: bool = False + is_repeated: bool = False + is_unordered: bool = False + is_predicate: bool = False + first: bool = False + + def __post_init__(self): + self.field_name = avoid_keywords(self.field_name) + + @property + def type(self) -> str: + type = self.base_type + if self.is_optional: + type = f"Option<{type}>" + if self.is_repeated: + type = f"Vec<{type}>" + return type + + @property + def is_single(self): + return not (self.is_optional or self.is_repeated or self.is_predicate) + + @property + def is_label(self): + return self.base_type == "trap::Label" + + +@dataclasses.dataclass +class Class: + name: str + table_name: str + fields: list[Field] = dataclasses.field(default_factory=list) + + @property + def single_field_entries(self): + ret = {self.table_name: []} + for f in self.fields: + if f.is_single: + ret.setdefault(f.table_name, []).append(f) + return [{"table_name": k, "fields": v} for k, v in ret.items()] + + +@dataclasses.dataclass +class ClassList: + template: typing.ClassVar[str] = "rust_classes" + + classes: list[Class] + source: str + + +@dataclasses.dataclass +class ModuleList: + template: typing.ClassVar[str] = "rust_module" + + modules: list[str] + source: str diff --git a/misc/codegen/lib/schema.py b/misc/codegen/lib/schema.py index 0d3399187d92..37f0f53c5f51 100644 --- a/misc/codegen/lib/schema.py +++ b/misc/codegen/lib/schema.py @@ -94,6 +94,7 @@ class Class: default_doc_name: Optional[str] = None hideable: bool = False test_with: Optional[str] = None + rust_doc_test_function: Optional["FunctionInfo"] = None # TODO: parametrized pragmas @property def final(self): diff --git a/misc/codegen/lib/schemadefs.py b/misc/codegen/lib/schemadefs.py index 3d1024fc5261..5f424b2bffcd 100644 --- a/misc/codegen/lib/schemadefs.py +++ b/misc/codegen/lib/schemadefs.py @@ -52,6 +52,7 @@ def modify(self, prop: _schema.Property): qltest = _Namespace() ql = _Namespace() cpp = _Namespace() +rust = _Namespace() synth = _SynthModifier() @@ -156,6 +157,10 @@ def f(cls: type) -> type: _Pragma("cpp_skip") +_Pragma("rust_skip_doc_test") + +rust.doc_test_signature = lambda signature: _annotate(rust_doc_test_function=signature) + def group(name: str = "") -> _ClassDecorator: return _annotate(group=name) diff --git a/misc/codegen/loaders/schemaloader.py b/misc/codegen/loaders/schemaloader.py index 8f26a6335f52..ab84c8171739 100644 --- a/misc/codegen/loaders/schemaloader.py +++ b/misc/codegen/loaders/schemaloader.py @@ -56,6 +56,7 @@ def _get_class(cls: type) -> schema.Class: ], doc=schema.split_doc(cls.__doc__), default_doc_name=cls.__dict__.get("_doc_name"), + rust_doc_test_function=cls.__dict__.get("_rust_doc_test_function") ) diff --git a/swift/schema_documentation.md b/misc/codegen/schema_documentation.md similarity index 100% rename from swift/schema_documentation.md rename to misc/codegen/schema_documentation.md diff --git a/misc/codegen/templates/rust_classes.mustache b/misc/codegen/templates/rust_classes.mustache new file mode 100644 index 000000000000..3b415683d5f3 --- /dev/null +++ b/misc/codegen/templates/rust_classes.mustache @@ -0,0 +1,54 @@ +// generated by {{generator}} + +#![cfg_attr(any(), rustfmt::skip)] + +use crate::trap::{TrapId, TrapEntry}; +use codeql_extractor::trap; +{{#classes}} + +#[derive(Debug)] +pub struct {{name}} { + pub id: TrapId, + {{#fields}} + pub {{field_name}}: {{type}}, + {{/fields}} +} + +impl TrapEntry for {{name}} { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + {{#single_field_entries}} + out.add_tuple("{{table_name}}", vec![trap::Arg::Label(id){{#fields}}, self.{{field_name}}.into(){{/fields}}]); + {{/single_field_entries}} + {{#fields}} + {{#is_predicate}} + if self.{{field_name}} { + out.add_tuple("{{table_name}}", vec![trap::Arg::Label(id)]); + } + {{/is_predicate}} + {{#is_optional}} + {{^is_repeated}} + if let Some(v) = self.{{field_name}} { + out.add_tuple("{{table_name}}", vec![trap::Arg::Label(id), v.into()]); + } + {{/is_repeated}} + {{/is_optional}} + {{#is_repeated}} + for (i, v) in self.{{field_name}}.into_iter().enumerate() { + {{^is_optional}} + out.add_tuple("{{table_name}}", vec![trap::Arg::Label(id){{^is_unordered}}, i.into(){{/is_unordered}}, v.into()]); + {{/is_optional}} + {{#is_optional}} + if let Some(v) = v { + out.add_tuple("{{table_name}}", vec![trap::Arg::Label(id){{^is_unordered}}, i.into(){{/is_unordered}}, v.into()]); + } + {{/is_optional}} + } + {{/is_repeated}} + {{/fields}} + } +} +{{/classes}} diff --git a/misc/codegen/templates/rust_module.mustache b/misc/codegen/templates/rust_module.mustache new file mode 100644 index 000000000000..bc7fb3158c6d --- /dev/null +++ b/misc/codegen/templates/rust_module.mustache @@ -0,0 +1,6 @@ +// generated by {{generator}} +{{#modules}} + +mod {{.}}; +pub use {{.}}::*; +{{/modules}} diff --git a/misc/codegen/templates/rust_test_code.mustache b/misc/codegen/templates/rust_test_code.mustache new file mode 100644 index 000000000000..d38da6a353bb --- /dev/null +++ b/misc/codegen/templates/rust_test_code.mustache @@ -0,0 +1,9 @@ +// generated by {{generator}} + +{{#function}} +fn {{name}}{{signature}} { +{{/function}} +{{code}} +{{#function}} +} +{{/function}} diff --git a/ruby/Makefile b/ruby/Makefile index d40bc33698b4..23333b494f4e 100644 --- a/ruby/Makefile +++ b/ruby/Makefile @@ -24,7 +24,7 @@ FILES=codeql-extractor.yml\ ql/lib/ruby.dbscheme.stats\ ql/lib/ruby.dbscheme -BIN_FILES=target/release/codeql-extractor-ruby$(EXE) +BIN_FILES=../target/release/codeql-extractor-ruby$(EXE) extractor-common: rm -rf build @@ -37,14 +37,14 @@ extractor-common: tools: $(BIN_FILES) rm -rf tools/bin mkdir tools/bin - cp -r target/release/codeql-extractor-ruby$(EXE) tools/bin/extractor$(EXE) + cp -r ../target/release/codeql-extractor-ruby$(EXE) tools/bin/extractor$(EXE) -target/release/%$(EXE): +../target/release/%$(EXE): cd extractor && cargo build --release dbscheme: cd extractor && cargo build --release - extractor/target/release/codeql-extractor-ruby generate --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll + ../target/release/codeql-extractor-ruby generate --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll codeql query format -i ql/lib/codeql/ruby/ast/internal/TreeSitter.qll .PHONY: extractor @@ -62,7 +62,7 @@ extractor: $(FILES) $(BIN_FILES) cp tools/autobuild.cmd extractor-pack/tools/autobuild.cmd cp ql/lib/ruby.dbscheme.stats extractor-pack/ruby.dbscheme.stats cp ql/lib/ruby.dbscheme extractor-pack/ruby.dbscheme - cp extractor/target/release/codeql-extractor-ruby$(EXE) extractor-pack/tools/$(CODEQL_PLATFORM)/extractor$(EXE) + cp ../target/release/codeql-extractor-ruby$(EXE) extractor-pack/tools/$(CODEQL_PLATFORM)/extractor$(EXE) test: extractor dbscheme codeql test run --check-databases --check-unused-labels --check-repeated-labels --check-redefined-labels --check-use-before-definition --search-path .. --consistency-queries ql/consistency-queries ql/test diff --git a/ruby/actions/create-extractor-pack/action.yml b/ruby/actions/create-extractor-pack/action.yml index bd9485bb5786..d8bba46064bd 100644 --- a/ruby/actions/create-extractor-pack/action.yml +++ b/ruby/actions/create-extractor-pack/action.yml @@ -18,7 +18,7 @@ runs: path: | ~/.cargo/registry ~/.cargo/git - ruby/target + target key: ${{ runner.os }}-${{ steps.os_version.outputs.version }}-ruby-qltest-cargo-${{ hashFiles('ruby/extractor/rust-toolchain.toml', 'ruby/scripts/create-extractor-pack.sh', 'ruby/extractor/**/Cargo.lock') }} - name: Build Extractor if: steps.cache-extractor.outputs.cache-hit != 'true' diff --git a/ruby/extractor/.cargo/config.toml b/ruby/extractor/.cargo/config.toml deleted file mode 100644 index 3e8c45cb78bb..000000000000 --- a/ruby/extractor/.cargo/config.toml +++ /dev/null @@ -1 +0,0 @@ -paths = ["../../shared/tree-sitter-extractor"] diff --git a/ruby/extractor/BUILD.bazel b/ruby/extractor/BUILD.bazel index e3c2a387af59..203f90310fa7 100644 --- a/ruby/extractor/BUILD.bazel +++ b/ruby/extractor/BUILD.bazel @@ -1,4 +1,4 @@ -load("@ruby_deps//:defs.bzl", "aliases", "all_crate_deps") +load("@tree_sitter_extractors_deps//:defs.bzl", "aliases", "all_crate_deps") load("//misc/bazel:rust.bzl", "codeql_rust_binary") codeql_rust_binary( diff --git a/ruby/extractor/Cargo.lock b/ruby/extractor/Cargo.lock deleted file mode 100644 index d32d1bd69811..000000000000 --- a/ruby/extractor/Cargo.lock +++ /dev/null @@ -1,1008 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - -[[package]] -name = "android-tzdata" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" - -[[package]] -name = "android_system_properties" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" -dependencies = [ - "libc", -] - -[[package]] -name = "anstream" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "418c75fa768af9c03be99d17643f93f79bbba589895012a80e3452a19ddda15b" -dependencies = [ - "anstyle", - "anstyle-parse", - "anstyle-query", - "anstyle-wincon", - "colorchoice", - "is_terminal_polyfill", - "utf8parse", -] - -[[package]] -name = "anstyle" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "038dfcf04a5feb68e9c60b21c9625a54c2c0616e79b72b0fd87075a056ae1d1b" - -[[package]] -name = "anstyle-parse" -version = "0.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c03a11a9034d92058ceb6ee011ce58af4a9bf61491aa7e1e59ecd24bd40d22d4" -dependencies = [ - "utf8parse", -] - -[[package]] -name = "anstyle-query" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" -dependencies = [ - "windows-sys", -] - -[[package]] -name = "anstyle-wincon" -version = "3.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" -dependencies = [ - "anstyle", - "windows-sys", -] - -[[package]] -name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "bstr" -version = "1.9.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05efc5cfd9110c8416e471df0e96702d58690178e206e61b7173706673c93706" -dependencies = [ - "memchr", - "serde", -] - -[[package]] -name = "bumpalo" -version = "3.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" - -[[package]] -name = "cc" -version = "1.1.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57b6a275aa2903740dc87da01c62040406b8812552e97129a63ea8850a17c6e6" -dependencies = [ - "shlex", -] - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "chrono" -version = "0.4.38" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a21f936df1771bf62b77f047b726c4625ff2e8aa607c01ec06e5a05bd8463401" -dependencies = [ - "android-tzdata", - "iana-time-zone", - "js-sys", - "num-traits", - "serde", - "wasm-bindgen", - "windows-targets", -] - -[[package]] -name = "clap" -version = "4.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bc066a67923782aa8515dbaea16946c5bcc5addbd668bb80af688e53e548a0" -dependencies = [ - "clap_builder", - "clap_derive", -] - -[[package]] -name = "clap_builder" -version = "4.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae129e2e766ae0ec03484e609954119f123cc1fe650337e155d03b022f24f7b4" -dependencies = [ - "anstream", - "anstyle", - "clap_lex", - "strsim", -] - -[[package]] -name = "clap_derive" -version = "4.5.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" -dependencies = [ - "heck", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "clap_lex" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" - -[[package]] -name = "codeql-extractor" -version = "0.2.0" -dependencies = [ - "chrono", - "encoding", - "flate2", - "globset", - "lazy_static", - "num_cpus", - "rand", - "rayon", - "regex", - "serde", - "serde_json", - "tracing", - "tracing-subscriber", - "tree-sitter", - "tree-sitter-json", - "tree-sitter-ql", -] - -[[package]] -name = "codeql-extractor-ruby" -version = "0.1.0" -dependencies = [ - "clap", - "codeql-extractor", - "encoding", - "lazy_static", - "rayon", - "regex", - "tracing", - "tracing-subscriber", - "tree-sitter", - "tree-sitter-embedded-template", - "tree-sitter-ruby", -] - -[[package]] -name = "colorchoice" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" - -[[package]] -name = "core-foundation-sys" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" - -[[package]] -name = "crc32fast" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" -dependencies = [ - "cfg-if", -] - -[[package]] -name = "crossbeam-deque" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" -dependencies = [ - "crossbeam-epoch", - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-epoch" -version = "0.9.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" -dependencies = [ - "crossbeam-utils", -] - -[[package]] -name = "crossbeam-utils" -version = "0.8.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" - -[[package]] -name = "either" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dca9240753cf90908d7e4aac30f630662b02aebaa1b58a3cadabdb23385b58b" - -[[package]] -name = "encoding" -version = "0.2.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec" -dependencies = [ - "encoding-index-japanese", - "encoding-index-korean", - "encoding-index-simpchinese", - "encoding-index-singlebyte", - "encoding-index-tradchinese", -] - -[[package]] -name = "encoding-index-japanese" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91" -dependencies = [ - "encoding_index_tests", -] - -[[package]] -name = "encoding-index-korean" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81" -dependencies = [ - "encoding_index_tests", -] - -[[package]] -name = "encoding-index-simpchinese" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7" -dependencies = [ - "encoding_index_tests", -] - -[[package]] -name = "encoding-index-singlebyte" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a" -dependencies = [ - "encoding_index_tests", -] - -[[package]] -name = "encoding-index-tradchinese" -version = "1.20141219.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18" -dependencies = [ - "encoding_index_tests", -] - -[[package]] -name = "encoding_index_tests" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569" - -[[package]] -name = "flate2" -version = "1.0.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f54427cfd1c7829e2a139fcefea601bf088ebca651d2bf53ebc600eac295dae" -dependencies = [ - "crc32fast", - "miniz_oxide", -] - -[[package]] -name = "getrandom" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" -dependencies = [ - "cfg-if", - "libc", - "wasi", -] - -[[package]] -name = "globset" -version = "0.4.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" -dependencies = [ - "aho-corasick", - "bstr", - "log", - "regex-automata 0.4.6", - "regex-syntax 0.8.4", -] - -[[package]] -name = "heck" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" - -[[package]] -name = "hermit-abi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" - -[[package]] -name = "iana-time-zone" -version = "0.1.60" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" -dependencies = [ - "android_system_properties", - "core-foundation-sys", - "iana-time-zone-haiku", - "js-sys", - "wasm-bindgen", - "windows-core", -] - -[[package]] -name = "iana-time-zone-haiku" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" -dependencies = [ - "cc", -] - -[[package]] -name = "is_terminal_polyfill" -version = "1.70.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" - -[[package]] -name = "itoa" -version = "1.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" - -[[package]] -name = "js-sys" -version = "0.3.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" -dependencies = [ - "wasm-bindgen", -] - -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - -[[package]] -name = "libc" -version = "0.2.155" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" - -[[package]] -name = "log" -version = "0.4.21" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" - -[[package]] -name = "matchers" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" -dependencies = [ - "regex-automata 0.1.10", -] - -[[package]] -name = "memchr" -version = "2.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" - -[[package]] -name = "miniz_oxide" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" -dependencies = [ - "adler", -] - -[[package]] -name = "nu-ansi-term" -version = "0.46.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" -dependencies = [ - "overload", - "winapi", -] - -[[package]] -name = "num-traits" -version = "0.2.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" -dependencies = [ - "autocfg", -] - -[[package]] -name = "num_cpus" -version = "1.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" -dependencies = [ - "hermit-abi", - "libc", -] - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "overload" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" - -[[package]] -name = "pin-project-lite" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" - -[[package]] -name = "ppv-lite86" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" - -[[package]] -name = "proc-macro2" -version = "1.0.83" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.36" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "rand" -version = "0.8.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rayon" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" -dependencies = [ - "either", - "rayon-core", -] - -[[package]] -name = "rayon-core" -version = "1.12.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" -dependencies = [ - "crossbeam-deque", - "crossbeam-utils", -] - -[[package]] -name = "regex" -version = "1.10.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata 0.4.6", - "regex-syntax 0.8.4", -] - -[[package]] -name = "regex-automata" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" -dependencies = [ - "regex-syntax 0.6.29", -] - -[[package]] -name = "regex-automata" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax 0.8.4", -] - -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" - -[[package]] -name = "regex-syntax" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" - -[[package]] -name = "ryu" -version = "1.0.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" - -[[package]] -name = "serde" -version = "1.0.202" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" -dependencies = [ - "serde_derive", -] - -[[package]] -name = "serde_derive" -version = "1.0.202" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "serde_json" -version = "1.0.117" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" -dependencies = [ - "itoa", - "ryu", - "serde", -] - -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - -[[package]] -name = "shlex" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" - -[[package]] -name = "smallvec" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" - -[[package]] -name = "strsim" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" - -[[package]] -name = "syn" -version = "2.0.66" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thread_local" -version = "1.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c" -dependencies = [ - "cfg-if", - "once_cell", -] - -[[package]] -name = "tracing" -version = "0.1.40" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" -dependencies = [ - "pin-project-lite", - "tracing-attributes", - "tracing-core", -] - -[[package]] -name = "tracing-attributes" -version = "0.1.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tracing-core" -version = "0.1.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-log" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" -dependencies = [ - "log", - "once_cell", - "tracing-core", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" -dependencies = [ - "matchers", - "nu-ansi-term", - "once_cell", - "regex", - "sharded-slab", - "smallvec", - "thread_local", - "tracing", - "tracing-core", - "tracing-log", -] - -[[package]] -name = "tree-sitter" -version = "0.23.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20f4cd3642c47a85052a887d86704f4eac272969f61b686bdd3f772122aabaff" -dependencies = [ - "cc", - "regex", - "regex-syntax 0.8.4", - "tree-sitter-language", -] - -[[package]] -name = "tree-sitter-embedded-template" -version = "0.23.0" -source = "git+https://github.com/tree-sitter/tree-sitter-embedded-template.git?rev=62b0a6e45900a7dff7c37da95fec20a09968ba52#62b0a6e45900a7dff7c37da95fec20a09968ba52" -dependencies = [ - "cc", - "tree-sitter-language", -] - -[[package]] -name = "tree-sitter-json" -version = "0.23.0" -source = "git+https://github.com/tree-sitter/tree-sitter-json#8bfdb43f47ad805bb1ce093203cfcbaa8ed2c571" -dependencies = [ - "cc", - "tree-sitter-language", -] - -[[package]] -name = "tree-sitter-language" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2545046bd1473dac6c626659cc2567c6c0ff302fc8b84a56c4243378276f7f57" - -[[package]] -name = "tree-sitter-ql" -version = "0.23.0" -source = "git+https://github.com/tree-sitter/tree-sitter-ql#c73c31c89cb0019ef56fe8bc1723e7c36e0be607" -dependencies = [ - "cc", - "tree-sitter-language", -] - -[[package]] -name = "tree-sitter-ruby" -version = "0.23.0" -source = "git+https://github.com/tree-sitter/tree-sitter-ruby.git?rev=a66579f70d6f50ffd81a16fc3d3358e2ac173c88#a66579f70d6f50ffd81a16fc3d3358e2ac173c88" -dependencies = [ - "cc", - "tree-sitter-language", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "utf8parse" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" - -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - -[[package]] -name = "wasi" -version = "0.11.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" - -[[package]] -name = "wasm-bindgen" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" -dependencies = [ - "cfg-if", - "wasm-bindgen-macro", -] - -[[package]] -name = "wasm-bindgen-backend" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" -dependencies = [ - "bumpalo", - "log", - "once_cell", - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-macro" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" -dependencies = [ - "quote", - "wasm-bindgen-macro-support", -] - -[[package]] -name = "wasm-bindgen-macro-support" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" -dependencies = [ - "proc-macro2", - "quote", - "syn", - "wasm-bindgen-backend", - "wasm-bindgen-shared", -] - -[[package]] -name = "wasm-bindgen-shared" -version = "0.2.92" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "windows-core" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-sys" -version = "0.52.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" -dependencies = [ - "windows-targets", -] - -[[package]] -name = "windows-targets" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" diff --git a/ruby/extractor/Cargo.toml b/ruby/extractor/Cargo.toml index 89e0d3cf9db7..bd0cde9bb027 100644 --- a/ruby/extractor/Cargo.toml +++ b/ruby/extractor/Cargo.toml @@ -1,4 +1,3 @@ -[workspace] [package] name = "codeql-extractor-ruby" description = "CodeQL Ruby extractor" @@ -16,8 +15,6 @@ tracing-subscriber = { version = "0.3.3", features = ["env-filter"] } rayon = "1.5.0" regex = "1.7.1" encoding = "0.2" -lazy_static = "1.4.0" -# Ideally, we'd like to pull this in via a relative path. -# However, our bazel/rust tooling chokes on this, c.f. https://github.com/bazelbuild/rules_rust/issues/1525 -# Therefore, we have a pretty bad hack in place instead, see README.md in the codeql-extractor-fake-crate directory. -codeql-extractor = { path = "codeql-extractor-fake-crate" } +lazy_static = "1.4.0" + +codeql-extractor = { path = "../../shared/tree-sitter-extractor" } diff --git a/ruby/extractor/codeql-extractor-fake-crate/BUILD.bazel b/ruby/extractor/codeql-extractor-fake-crate/BUILD.bazel deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/ruby/extractor/codeql-extractor-fake-crate/Cargo.toml b/ruby/extractor/codeql-extractor-fake-crate/Cargo.toml deleted file mode 100644 index d7d1e0f37abe..000000000000 --- a/ruby/extractor/codeql-extractor-fake-crate/Cargo.toml +++ /dev/null @@ -1,26 +0,0 @@ -[package] -name = "codeql-extractor" -version = "0.2.0" -edition = "2021" -authors = ["GitHub"] - -[dependencies] -flate2 = "1.0" -globset = "0.4" -tree-sitter = ">= 0.23.0" -tracing = "0.1" -tracing-subscriber = { version = "0.3.3", features = ["env-filter"] } -rayon = "1.5.0" -regex = "1.7.1" -encoding = "0.2" -lazy_static = "1.4.0" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -chrono = { version = "0.4.19", features = ["serde"] } -num_cpus = "1.14.0" - -[dev-dependencies] -tree-sitter-ql = { git = "https://github.com/tree-sitter/tree-sitter-ql" } -tree-sitter-json = {git = "https://github.com/tree-sitter/tree-sitter-json" } -rand = "0.8.5" - diff --git a/ruby/extractor/codeql-extractor-fake-crate/README.md b/ruby/extractor/codeql-extractor-fake-crate/README.md deleted file mode 100644 index 71f7ec8974b6..000000000000 --- a/ruby/extractor/codeql-extractor-fake-crate/README.md +++ /dev/null @@ -1,7 +0,0 @@ -We're presenting a fake crate in this workspace that ensures that the correct crate dependencies from the shared tree sitter -extractor can be parsed by Bazel (which doesn't resolve path dependencies outside of the cargo workspace unfortunately). - -The sync-identical-files script keeps this up-to-date. -For local development and IDEs, we override the path to `codeql-extractor` using the `.cargo/config.toml` mechanism. -Bazel doesn't actually do anything with path dependencies except to pull in their dependency tree, so we manually -specify the dependency from the ruby extractor to the shared extractor in `BUILD.bazel`. diff --git a/ruby/extractor/codeql-extractor-fake-crate/src/lib.rs b/ruby/extractor/codeql-extractor-fake-crate/src/lib.rs deleted file mode 100644 index 8b137891791f..000000000000 --- a/ruby/extractor/codeql-extractor-fake-crate/src/lib.rs +++ /dev/null @@ -1 +0,0 @@ - diff --git a/ruby/scripts/create-extractor-pack.sh b/ruby/scripts/create-extractor-pack.sh index e601a4b2dd49..4cef0b8c73f3 100755 --- a/ruby/scripts/create-extractor-pack.sh +++ b/ruby/scripts/create-extractor-pack.sh @@ -8,10 +8,12 @@ else echo "Unknown OS" exit 1 fi +cd "$(dirname "$0")/.." (cd extractor && cargo build --release) -BIN_DIR=extractor/target/release +# we are in a cargo workspace rooted at the git checkout +BIN_DIR=../target/release "$BIN_DIR/codeql-extractor-ruby" generate --dbscheme ql/lib/ruby.dbscheme --library ql/lib/codeql/ruby/ast/internal/TreeSitter.qll codeql query format -i ql/lib/codeql/ruby/ast/internal/TreeSitter.qll diff --git a/rust/BUILD.bazel b/rust/BUILD.bazel new file mode 100644 index 000000000000..fff7c807ffb9 --- /dev/null +++ b/rust/BUILD.bazel @@ -0,0 +1,65 @@ +load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup") +load( + "//misc/bazel:pkg.bzl", + "codeql_pack", + "codeql_pkg_files", +) + +package(default_visibility = ["//rust:__subpackages__"]) + +filegroup( + name = "schema", + srcs = ["schema.py"], +) + +filegroup( + name = "schema-includes", + srcs = glob(["*.dbscheme"]), +) + +filegroup( + name = "codegen-conf", + srcs = ["codegen.conf"], +) + +codeql_pkg_files( + name = "tools-arch", + exes = ["//rust/extractor"], + prefix = "{CODEQL_PLATFORM}", +) + +pkg_filegroup( + name = "tools", + srcs = [ + ":tools-arch", + "//rust/tools", + ], + prefix = "tools", +) + +codeql_pkg_files( + name = "root-files", + srcs = [ + "codeql-extractor.yml", + "ql/lib/rust.dbscheme", + "ql/lib/rust.dbscheme.stats", + ], +) + +[ + codeql_pack( + name = "-".join(parts), + srcs = [ + ":root-files", + ":tools", + ], + pack_prefix = "/".join(parts), + ) + for parts in ( + [ + "experimental", + "rust", + ], + ["rust"], + ) +] diff --git a/rust/README.md b/rust/README.md new file mode 100644 index 000000000000..87c7072c6758 --- /dev/null +++ b/rust/README.md @@ -0,0 +1,43 @@ +# Rust on CodeQL + +> [!WARNING] +> Rust support for CodeQL is experimental. No support is offered. QL and database interfaces will change and break without notice or deprecation periods. + +## Development + +### Dependencies + +If you don't have the `semmle-code` repo you may need to install Bazel manually, e.g. from https://github.com/bazelbuild/bazelisk. + +### Building the Rust Extractor + +This approach uses a released `codeql` version and is simpler to use for QL development. From your `semmle-code` directory run: +```bash +bazel run @codeql//rust:rust-installer +``` +You now need to create a [per-user CodeQL configuration file](https://docs.github.com/en/code-security/codeql-cli/using-the-advanced-functionality-of-the-codeql-cli/specifying-command-options-in-a-codeql-configuration-file#using-a-codeql-configuration-file) and specify the option: +``` +--search-path PATH/TO/semmle-code/ql +``` +(wherever the `codeql` checkout is on your system) + +You can now use the Rust extractor e.g. to run Rust tests from the command line or in VSCode. + +### Building the Rust Extractor (as a sembuild target) + +This approach allows you to build a Rust extractor with a CLI built from source. From your `semmle-code` directory run: +```bash +./build target/intree/codeql-rust +``` +You can now invoke it directly, for example to run some tests: +```bash +./target/intree/codeql-rust/codeql test run ql/rust/ql/test/PATH/TO/TEST/ +``` + +### Building a Database + +TODO + +### Code Generation + +TODO diff --git a/rust/codegen.conf b/rust/codegen.conf new file mode 100644 index 000000000000..cce7a27fe916 --- /dev/null +++ b/rust/codegen.conf @@ -0,0 +1,8 @@ +# configuration file for Swift code generation default options +--generate=dbscheme,rusttest,ql,rust +--dbscheme=ql/lib/rust.dbscheme +--ql-output=ql/lib/codeql/rust/generated +--ql-stub-output=ql/lib/codeql/rust/elements +--ql-test-output=ql/test/extractor-tests/generated +--rust-output=extractor/src/generated +--script-name=codegen diff --git a/rust/codegen/BUILD.bazel b/rust/codegen/BUILD.bazel new file mode 100644 index 000000000000..99f737538a6b --- /dev/null +++ b/rust/codegen/BUILD.bazel @@ -0,0 +1,15 @@ +load("@bazel_skylib//rules:native_binary.bzl", "native_binary") + +native_binary( + name = "codegen", + src = "//misc/codegen", + out = "codegen", + args = [ + "--configuration-file=$(location //rust:codegen-conf)", + ], + data = [ + "//rust:codegen-conf", + "//rust:schema", + ], + visibility = ["//rust:__subpackages__"], +) diff --git a/rust/codeql-extractor.yml b/rust/codeql-extractor.yml new file mode 100644 index 000000000000..e33d2c0c7153 --- /dev/null +++ b/rust/codeql-extractor.yml @@ -0,0 +1,36 @@ +name: "rust" +display_name: "Rust" +version: 0.1.0 +column_kind: "utf8" +legacy_qltest_extraction: true +build_modes: + - none +github_api_languages: + - Rust +scc_languages: + - Rust +file_types: + - name: rust + display_name: Rust files + extensions: + - .rs +options: + trap: + title: Options pertaining to TRAP. + type: object + properties: + compression: + title: Controls compression for the TRAP files written by the extractor. + description: > + This option is only intended for use in debugging the extractor. Accepted + values are 'gzip' (the default, to write gzip-compressed TRAP) and 'none' + (to write uncompressed TRAP). + type: string + pattern: "^(none|gzip)$" + extract_dependencies: + title: Whether to extract dependencies. + description: > + Extract the source code of dependencies and the standard libraries in addition to + normal source code. + type: string + pattern: "^(false|true)$" diff --git a/rust/extractor/.gitignore b/rust/extractor/.gitignore new file mode 100644 index 000000000000..d81f12ed1b1c --- /dev/null +++ b/rust/extractor/.gitignore @@ -0,0 +1,2 @@ +/target +/.idea diff --git a/rust/extractor/BUILD.bazel b/rust/extractor/BUILD.bazel new file mode 100644 index 000000000000..924d5e01497c --- /dev/null +++ b/rust/extractor/BUILD.bazel @@ -0,0 +1,17 @@ +load("@tree_sitter_extractors_deps//:defs.bzl", "aliases", "all_crate_deps") +load("//misc/bazel:rust.bzl", "codeql_rust_binary") + +codeql_rust_binary( + name = "extractor", + srcs = glob(["src/**/*.rs"]), + aliases = aliases(), + proc_macro_deps = all_crate_deps( + proc_macro = True, + ), + visibility = ["//rust:__subpackages__"], + deps = all_crate_deps( + normal = True, + ) + [ + "//shared/tree-sitter-extractor:codeql-extractor", + ], +) diff --git a/rust/extractor/Cargo.toml b/rust/extractor/Cargo.toml new file mode 100644 index 000000000000..c849ea4aa464 --- /dev/null +++ b/rust/extractor/Cargo.toml @@ -0,0 +1,28 @@ +[package] +name = "codeql-rust" +version = "0.1.0" +edition = "2021" + +[dependencies] +anyhow = "1.0.86" +clap = { version = "4.5.16", features = ["derive"] } +figment = { version = "0.10.19", features = ["env"]} +log = "0.4.22" +num-traits = "0.2.19" +ra_ap_base_db = "0.0.232" +ra_ap_hir = "0.0.232" +ra_ap_hir_def = "0.0.232" +ra_ap_ide_db = "0.0.232" +ra_ap_load-cargo = "0.0.232" +ra_ap_paths = "0.0.232" +ra_ap_project_model = "0.0.232" +ra_ap_syntax = "0.0.232" +ra_ap_vfs = "0.0.232" +serde = "1.0.209" +serde_with = "3.9.0" +stderrlog = "0.6.0" +triomphe = "0.1.13" +# Ideally, we'd like to pull this in via a relative path. +# However, our bazel/rust tooling chokes on this, c.f. https://github.com/bazelbuild/rules_rust/issues/1525 +# Therefore, we have a pretty bad hack in place instead, see README.md in the codeql-extractor-fake-crate directory. +codeql-extractor = { path = "../../shared/tree-sitter-extractor" } diff --git a/rust/extractor/src/archive.rs b/rust/extractor/src/archive.rs new file mode 100644 index 000000000000..cc1587ca9577 --- /dev/null +++ b/rust/extractor/src/archive.rs @@ -0,0 +1,29 @@ +use crate::path; +use log::{debug, warn}; +use std::fs; +use std::path::{Path, PathBuf}; + +pub struct Archiver { + pub root: PathBuf, +} + +impl Archiver { + pub fn archive(&self, source: &Path) { + if let Err(e) = self.try_archive(source) { + warn!("unable to archive {}: {e}", source.display()); + } + } + + fn try_archive(&self, source: &Path) -> std::io::Result<()> { + let mut dest = self.root.clone(); + dest.push(path::key(source)); + let parent = dest.parent().unwrap(); + if fs::metadata(&dest).is_ok() { + return Ok(()); + } + fs::create_dir_all(parent)?; + fs::copy(source, dest)?; + debug!("archived {}", source.display()); + Ok(()) + } +} diff --git a/rust/extractor/src/config.rs b/rust/extractor/src/config.rs new file mode 100644 index 000000000000..399c2bb9e7e7 --- /dev/null +++ b/rust/extractor/src/config.rs @@ -0,0 +1,81 @@ +use anyhow::Context; +use clap::{ArgAction, Parser, ValueEnum}; +use codeql_extractor::trap; +use figment::{ + providers::{Env, Serialized}, + Figment, +}; +use serde::{Deserialize, Serialize}; +use std::path::PathBuf; + +#[derive(Debug, PartialEq, Eq, Default, Serialize, Deserialize, Clone, Copy, ValueEnum)] +#[serde(rename_all = "lowercase")] +#[clap(rename_all = "lowercase")] +pub enum Compression { + #[default] // TODO make gzip default + None, + Gzip, +} + +impl From for trap::Compression { + fn from(val: Compression) -> Self { + match val { + Compression::None => Self::None, + Compression::Gzip => Self::Gzip, + } + } +} + +#[serde_with::apply(_ => #[serde(default)])] +#[derive(Debug, Deserialize, Default)] +pub struct Config { + pub scratch_dir: PathBuf, + pub trap_dir: PathBuf, + pub source_archive_dir: PathBuf, + pub extract_dependencies: bool, + pub verbose: u8, + pub compression: Compression, + pub inputs: Vec, +} + +#[serde_with::apply(_ => #[serde(skip_serializing_if = "is_default")])] +#[derive(clap::Parser, Serialize)] +#[command(about, long_about = None)] +struct CliArgs { + #[arg(long)] + scratch_dir: Option, + #[arg(long)] + trap_dir: Option, + #[arg(long)] + source_archive_dir: Option, + #[arg(long)] + compression: Option, + #[arg(short, long, action = ArgAction::Count)] + verbose: u8, + #[arg(long)] + inputs_file: Option, + + inputs: Vec, +} + +fn is_default(t: &T) -> bool { + *t == Default::default() +} + +impl Config { + pub fn extract() -> anyhow::Result { + let mut cli_args = CliArgs::parse(); + if let Some(inputs_file) = cli_args.inputs_file.take() { + let inputs_list = std::fs::read_to_string(inputs_file).context("reading file list")?; + cli_args + .inputs + .extend(inputs_list.split_terminator("\n").map(PathBuf::from)); + } + Figment::new() + .merge(Env::prefixed("CODEQL_EXTRACTOR_RUST_")) + .merge(Env::prefixed("CODEQL_EXTRACTOR_RUST_OPTION_")) + .merge(Serialized::defaults(cli_args)) + .extract() + .context("loading configuration") + } +} diff --git a/rust/extractor/src/generated/.generated.list b/rust/extractor/src/generated/.generated.list new file mode 100644 index 000000000000..e97b3eb02c8d --- /dev/null +++ b/rust/extractor/src/generated/.generated.list @@ -0,0 +1,2 @@ +mod.rs 7cdfedcd68cf8e41134daf810c1af78624082b0c3e8be6570339b1a69a5d457e 7cdfedcd68cf8e41134daf810c1af78624082b0c3e8be6570339b1a69a5d457e +top.rs 569909061b9a993481764765a014327d143939778f2dbc79836e7496cdb83e1f 569909061b9a993481764765a014327d143939778f2dbc79836e7496cdb83e1f diff --git a/rust/extractor/src/generated/.gitattributes b/rust/extractor/src/generated/.gitattributes new file mode 100644 index 000000000000..25bb20a99113 --- /dev/null +++ b/rust/extractor/src/generated/.gitattributes @@ -0,0 +1,4 @@ +/.generated.list linguist-generated +/.gitattributes linguist-generated +/mod.rs linguist-generated +/top.rs linguist-generated diff --git a/rust/extractor/src/generated/mod.rs b/rust/extractor/src/generated/mod.rs new file mode 100644 index 000000000000..1d605f8a0b0b --- /dev/null +++ b/rust/extractor/src/generated/mod.rs @@ -0,0 +1,4 @@ +// generated by codegen + +mod top; +pub use top::*; diff --git a/rust/extractor/src/generated/top.rs b/rust/extractor/src/generated/top.rs new file mode 100644 index 000000000000..48ca548386be --- /dev/null +++ b/rust/extractor/src/generated/top.rs @@ -0,0 +1,1505 @@ +// generated by codegen + +#![cfg_attr(any(), rustfmt::skip)] + +use crate::trap::{TrapId, TrapEntry}; +use codeql_extractor::trap; + +#[derive(Debug)] +pub struct DbFile { + pub id: TrapId, + pub name: String, +} + +impl TrapEntry for DbFile { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("db_files", vec![trap::Arg::Label(id)]); + out.add_tuple("files", vec![trap::Arg::Label(id), self.name.into()]); + } +} + +#[derive(Debug)] +pub struct DbLocation { + pub id: TrapId, + pub file: trap::Label, + pub start_line: usize, + pub start_column: usize, + pub end_line: usize, + pub end_column: usize, +} + +impl TrapEntry for DbLocation { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("db_locations", vec![trap::Arg::Label(id)]); + out.add_tuple("locations", vec![trap::Arg::Label(id), self.file.into(), self.start_line.into(), self.start_column.into(), self.end_line.into(), self.end_column.into()]); + } +} + +#[derive(Debug)] +pub struct Label { + pub id: TrapId, + pub location: Option, + pub name: String, +} + +impl TrapEntry for Label { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("labels", vec![trap::Arg::Label(id), self.name.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct MatchArm { + pub id: TrapId, + pub location: Option, + pub pat: trap::Label, + pub guard: Option, + pub expr: trap::Label, +} + +impl TrapEntry for MatchArm { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("match_arms", vec![trap::Arg::Label(id), self.pat.into(), self.expr.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.guard { + out.add_tuple("match_arm_guards", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct RecordFieldPat { + pub id: TrapId, + pub location: Option, + pub name: String, + pub pat: trap::Label, +} + +impl TrapEntry for RecordFieldPat { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("record_field_pats", vec![trap::Arg::Label(id), self.name.into(), self.pat.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct RecordLitField { + pub id: TrapId, + pub location: Option, + pub name: String, + pub expr: trap::Label, +} + +impl TrapEntry for RecordLitField { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("record_lit_fields", vec![trap::Arg::Label(id), self.name.into(), self.expr.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct TypeRef { + pub id: TrapId, + pub location: Option, +} + +impl TrapEntry for TypeRef { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("type_refs", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct Unimplemented { + pub id: TrapId, + pub location: Option, +} + +impl TrapEntry for Unimplemented { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("unimplementeds", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct AwaitExpr { + pub id: TrapId, + pub location: Option, + pub expr: trap::Label, +} + +impl TrapEntry for AwaitExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("await_exprs", vec![trap::Arg::Label(id), self.expr.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct BecomeExpr { + pub id: TrapId, + pub location: Option, + pub expr: trap::Label, +} + +impl TrapEntry for BecomeExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("become_exprs", vec![trap::Arg::Label(id), self.expr.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct BinaryOpExpr { + pub id: TrapId, + pub location: Option, + pub lhs: trap::Label, + pub rhs: trap::Label, + pub op: Option, +} + +impl TrapEntry for BinaryOpExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("binary_op_exprs", vec![trap::Arg::Label(id), self.lhs.into(), self.rhs.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.op { + out.add_tuple("binary_op_expr_ops", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct BindPat { + pub id: TrapId, + pub location: Option, + pub binding_id: String, + pub subpat: Option, +} + +impl TrapEntry for BindPat { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("bind_pats", vec![trap::Arg::Label(id), self.binding_id.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.subpat { + out.add_tuple("bind_pat_subpats", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct BoxExpr { + pub id: TrapId, + pub location: Option, + pub expr: trap::Label, +} + +impl TrapEntry for BoxExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("box_exprs", vec![trap::Arg::Label(id), self.expr.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct BoxPat { + pub id: TrapId, + pub location: Option, + pub inner: trap::Label, +} + +impl TrapEntry for BoxPat { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("box_pats", vec![trap::Arg::Label(id), self.inner.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct BreakExpr { + pub id: TrapId, + pub location: Option, + pub expr: Option, + pub label: Option, +} + +impl TrapEntry for BreakExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("break_exprs", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.expr { + out.add_tuple("break_expr_exprs", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.label { + out.add_tuple("break_expr_labels", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct CallExpr { + pub id: TrapId, + pub location: Option, + pub callee: trap::Label, + pub args: Vec, + pub is_assignee_expr: bool, +} + +impl TrapEntry for CallExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("call_exprs", vec![trap::Arg::Label(id), self.callee.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.args.into_iter().enumerate() { + out.add_tuple("call_expr_args", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + if self.is_assignee_expr { + out.add_tuple("call_expr_is_assignee_expr", vec![trap::Arg::Label(id)]); + } + } +} + +#[derive(Debug)] +pub struct CastExpr { + pub id: TrapId, + pub location: Option, + pub expr: trap::Label, + pub type_ref: trap::Label, +} + +impl TrapEntry for CastExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("cast_exprs", vec![trap::Arg::Label(id), self.expr.into(), self.type_ref.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct ClosureExpr { + pub id: TrapId, + pub location: Option, + pub args: Vec, + pub arg_types: Vec>, + pub ret_type: Option, + pub body: trap::Label, + pub closure_kind: String, + pub is_move: bool, +} + +impl TrapEntry for ClosureExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("closure_exprs", vec![trap::Arg::Label(id), self.body.into(), self.closure_kind.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.args.into_iter().enumerate() { + out.add_tuple("closure_expr_args", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + for (i, v) in self.arg_types.into_iter().enumerate() { + if let Some(v) = v { + out.add_tuple("closure_expr_arg_types", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + } + if let Some(v) = self.ret_type { + out.add_tuple("closure_expr_ret_types", vec![trap::Arg::Label(id), v.into()]); + } + if self.is_move { + out.add_tuple("closure_expr_is_move", vec![trap::Arg::Label(id)]); + } + } +} + +#[derive(Debug)] +pub struct ConstBlockPat { + pub id: TrapId, + pub location: Option, + pub expr: trap::Label, +} + +impl TrapEntry for ConstBlockPat { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("const_block_pats", vec![trap::Arg::Label(id), self.expr.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct ConstExpr { + pub id: TrapId, + pub location: Option, + pub expr: trap::Label, +} + +impl TrapEntry for ConstExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("const_exprs", vec![trap::Arg::Label(id), self.expr.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct ContinueExpr { + pub id: TrapId, + pub location: Option, + pub label: Option, +} + +impl TrapEntry for ContinueExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("continue_exprs", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.label { + out.add_tuple("continue_expr_labels", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct ExprStmt { + pub id: TrapId, + pub location: Option, + pub expr: trap::Label, + pub has_semicolon: bool, +} + +impl TrapEntry for ExprStmt { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("expr_stmts", vec![trap::Arg::Label(id), self.expr.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if self.has_semicolon { + out.add_tuple("expr_stmt_has_semicolon", vec![trap::Arg::Label(id)]); + } + } +} + +#[derive(Debug)] +pub struct FieldExpr { + pub id: TrapId, + pub location: Option, + pub expr: trap::Label, + pub name: String, +} + +impl TrapEntry for FieldExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("field_exprs", vec![trap::Arg::Label(id), self.expr.into(), self.name.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct Function { + pub id: TrapId, + pub location: Option, + pub name: String, + pub body: trap::Label, +} + +impl TrapEntry for Function { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("functions", vec![trap::Arg::Label(id), self.name.into(), self.body.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct IfExpr { + pub id: TrapId, + pub location: Option, + pub condition: trap::Label, + pub then: trap::Label, + pub else_: Option, +} + +impl TrapEntry for IfExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("if_exprs", vec![trap::Arg::Label(id), self.condition.into(), self.then.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.else_ { + out.add_tuple("if_expr_elses", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct IndexExpr { + pub id: TrapId, + pub location: Option, + pub base: trap::Label, + pub index: trap::Label, + pub is_assignee_expr: bool, +} + +impl TrapEntry for IndexExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("index_exprs", vec![trap::Arg::Label(id), self.base.into(), self.index.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if self.is_assignee_expr { + out.add_tuple("index_expr_is_assignee_expr", vec![trap::Arg::Label(id)]); + } + } +} + +#[derive(Debug)] +pub struct InlineAsmExpr { + pub id: TrapId, + pub location: Option, + pub expr: trap::Label, +} + +impl TrapEntry for InlineAsmExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("inline_asm_exprs", vec![trap::Arg::Label(id), self.expr.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct ItemStmt { + pub id: TrapId, + pub location: Option, +} + +impl TrapEntry for ItemStmt { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("item_stmts", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct LetExpr { + pub id: TrapId, + pub location: Option, + pub pat: trap::Label, + pub expr: trap::Label, +} + +impl TrapEntry for LetExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("let_exprs", vec![trap::Arg::Label(id), self.pat.into(), self.expr.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct LetStmt { + pub id: TrapId, + pub location: Option, + pub pat: trap::Label, + pub type_ref: Option, + pub initializer: Option, + pub else_: Option, +} + +impl TrapEntry for LetStmt { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("let_stmts", vec![trap::Arg::Label(id), self.pat.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.type_ref { + out.add_tuple("let_stmt_type_refs", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.initializer { + out.add_tuple("let_stmt_initializers", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.else_ { + out.add_tuple("let_stmt_elses", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct LitPat { + pub id: TrapId, + pub location: Option, + pub expr: trap::Label, +} + +impl TrapEntry for LitPat { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("lit_pats", vec![trap::Arg::Label(id), self.expr.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct LiteralExpr { + pub id: TrapId, + pub location: Option, +} + +impl TrapEntry for LiteralExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("literal_exprs", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct LoopExpr { + pub id: TrapId, + pub location: Option, + pub body: trap::Label, + pub label: Option, +} + +impl TrapEntry for LoopExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("loop_exprs", vec![trap::Arg::Label(id), self.body.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.label { + out.add_tuple("loop_expr_labels", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct MatchExpr { + pub id: TrapId, + pub location: Option, + pub expr: trap::Label, + pub branches: Vec, +} + +impl TrapEntry for MatchExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("match_exprs", vec![trap::Arg::Label(id), self.expr.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.branches.into_iter().enumerate() { + out.add_tuple("match_expr_branches", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct MethodCallExpr { + pub id: TrapId, + pub location: Option, + pub receiver: trap::Label, + pub method_name: String, + pub args: Vec, + pub generic_args: Option, +} + +impl TrapEntry for MethodCallExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("method_call_exprs", vec![trap::Arg::Label(id), self.receiver.into(), self.method_name.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.args.into_iter().enumerate() { + out.add_tuple("method_call_expr_args", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + if let Some(v) = self.generic_args { + out.add_tuple("method_call_expr_generic_args", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct MissingExpr { + pub id: TrapId, + pub location: Option, +} + +impl TrapEntry for MissingExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("missing_exprs", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct MissingPat { + pub id: TrapId, + pub location: Option, +} + +impl TrapEntry for MissingPat { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("missing_pats", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct Module { + pub id: TrapId, + pub location: Option, + pub declarations: Vec, +} + +impl TrapEntry for Module { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("modules", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.declarations.into_iter().enumerate() { + out.add_tuple("module_declarations", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct OffsetOfExpr { + pub id: TrapId, + pub location: Option, + pub container: trap::Label, + pub fields: Vec, +} + +impl TrapEntry for OffsetOfExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("offset_of_exprs", vec![trap::Arg::Label(id), self.container.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.fields.into_iter().enumerate() { + out.add_tuple("offset_of_expr_fields", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct OrPat { + pub id: TrapId, + pub location: Option, + pub args: Vec, +} + +impl TrapEntry for OrPat { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("or_pats", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.args.into_iter().enumerate() { + out.add_tuple("or_pat_args", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct PathExpr { + pub id: TrapId, + pub location: Option, + pub path: trap::Label, +} + +impl TrapEntry for PathExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("path_exprs", vec![trap::Arg::Label(id), self.path.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct PathPat { + pub id: TrapId, + pub location: Option, + pub path: trap::Label, +} + +impl TrapEntry for PathPat { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("path_pats", vec![trap::Arg::Label(id), self.path.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct RangeExpr { + pub id: TrapId, + pub location: Option, + pub lhs: Option, + pub rhs: Option, + pub is_inclusive: bool, +} + +impl TrapEntry for RangeExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("range_exprs", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.lhs { + out.add_tuple("range_expr_lhs", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.rhs { + out.add_tuple("range_expr_rhs", vec![trap::Arg::Label(id), v.into()]); + } + if self.is_inclusive { + out.add_tuple("range_expr_is_inclusive", vec![trap::Arg::Label(id)]); + } + } +} + +#[derive(Debug)] +pub struct RangePat { + pub id: TrapId, + pub location: Option, + pub start: Option, + pub end: Option, +} + +impl TrapEntry for RangePat { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("range_pats", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.start { + out.add_tuple("range_pat_starts", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.end { + out.add_tuple("range_pat_ends", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct RecordLitExpr { + pub id: TrapId, + pub location: Option, + pub path: Option, + pub fields: Vec, + pub spread: Option, + pub has_ellipsis: bool, + pub is_assignee_expr: bool, +} + +impl TrapEntry for RecordLitExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("record_lit_exprs", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.path { + out.add_tuple("record_lit_expr_paths", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.fields.into_iter().enumerate() { + out.add_tuple("record_lit_expr_fields", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + if let Some(v) = self.spread { + out.add_tuple("record_lit_expr_spreads", vec![trap::Arg::Label(id), v.into()]); + } + if self.has_ellipsis { + out.add_tuple("record_lit_expr_has_ellipsis", vec![trap::Arg::Label(id)]); + } + if self.is_assignee_expr { + out.add_tuple("record_lit_expr_is_assignee_expr", vec![trap::Arg::Label(id)]); + } + } +} + +#[derive(Debug)] +pub struct RecordPat { + pub id: TrapId, + pub location: Option, + pub path: Option, + pub args: Vec, + pub has_ellipsis: bool, +} + +impl TrapEntry for RecordPat { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("record_pats", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.path { + out.add_tuple("record_pat_paths", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.args.into_iter().enumerate() { + out.add_tuple("record_pat_args", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + if self.has_ellipsis { + out.add_tuple("record_pat_has_ellipsis", vec![trap::Arg::Label(id)]); + } + } +} + +#[derive(Debug)] +pub struct RefExpr { + pub id: TrapId, + pub location: Option, + pub expr: trap::Label, + pub is_raw: bool, + pub is_mut: bool, +} + +impl TrapEntry for RefExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("ref_exprs", vec![trap::Arg::Label(id), self.expr.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if self.is_raw { + out.add_tuple("ref_expr_is_raw", vec![trap::Arg::Label(id)]); + } + if self.is_mut { + out.add_tuple("ref_expr_is_mut", vec![trap::Arg::Label(id)]); + } + } +} + +#[derive(Debug)] +pub struct RefPat { + pub id: TrapId, + pub location: Option, + pub pat: trap::Label, + pub is_mut: bool, +} + +impl TrapEntry for RefPat { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("ref_pats", vec![trap::Arg::Label(id), self.pat.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if self.is_mut { + out.add_tuple("ref_pat_is_mut", vec![trap::Arg::Label(id)]); + } + } +} + +#[derive(Debug)] +pub struct ReturnExpr { + pub id: TrapId, + pub location: Option, + pub expr: Option, +} + +impl TrapEntry for ReturnExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("return_exprs", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.expr { + out.add_tuple("return_expr_exprs", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct SlicePat { + pub id: TrapId, + pub location: Option, + pub prefix: Vec, + pub slice: Option, + pub suffix: Vec, +} + +impl TrapEntry for SlicePat { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("slice_pats", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.prefix.into_iter().enumerate() { + out.add_tuple("slice_pat_prefixes", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + if let Some(v) = self.slice { + out.add_tuple("slice_pat_slice", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.suffix.into_iter().enumerate() { + out.add_tuple("slice_pat_suffixes", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct TupleExpr { + pub id: TrapId, + pub location: Option, + pub exprs: Vec, + pub is_assignee_expr: bool, +} + +impl TrapEntry for TupleExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("tuple_exprs", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.exprs.into_iter().enumerate() { + out.add_tuple("tuple_expr_exprs", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + if self.is_assignee_expr { + out.add_tuple("tuple_expr_is_assignee_expr", vec![trap::Arg::Label(id)]); + } + } +} + +#[derive(Debug)] +pub struct TuplePat { + pub id: TrapId, + pub location: Option, + pub args: Vec, + pub ellipsis_index: Option, +} + +impl TrapEntry for TuplePat { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("tuple_pats", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.args.into_iter().enumerate() { + out.add_tuple("tuple_pat_args", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + if let Some(v) = self.ellipsis_index { + out.add_tuple("tuple_pat_ellipsis_indices", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct TupleStructPat { + pub id: TrapId, + pub location: Option, + pub path: Option, + pub args: Vec, + pub ellipsis_index: Option, +} + +impl TrapEntry for TupleStructPat { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("tuple_struct_pats", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.path { + out.add_tuple("tuple_struct_pat_paths", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.args.into_iter().enumerate() { + out.add_tuple("tuple_struct_pat_args", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + if let Some(v) = self.ellipsis_index { + out.add_tuple("tuple_struct_pat_ellipsis_indices", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct UnaryOpExpr { + pub id: TrapId, + pub location: Option, + pub expr: trap::Label, + pub op: String, +} + +impl TrapEntry for UnaryOpExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("unary_op_exprs", vec![trap::Arg::Label(id), self.expr.into(), self.op.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct UnderscoreExpr { + pub id: TrapId, + pub location: Option, +} + +impl TrapEntry for UnderscoreExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("underscore_exprs", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct WildPat { + pub id: TrapId, + pub location: Option, +} + +impl TrapEntry for WildPat { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("wild_pats", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct YeetExpr { + pub id: TrapId, + pub location: Option, + pub expr: Option, +} + +impl TrapEntry for YeetExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("yeet_exprs", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.expr { + out.add_tuple("yeet_expr_exprs", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct YieldExpr { + pub id: TrapId, + pub location: Option, + pub expr: Option, +} + +impl TrapEntry for YieldExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("yield_exprs", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.expr { + out.add_tuple("yield_expr_exprs", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct AsyncBlockExpr { + pub id: TrapId, + pub location: Option, + pub statements: Vec, + pub tail: Option, +} + +impl TrapEntry for AsyncBlockExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("async_block_exprs", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.statements.into_iter().enumerate() { + out.add_tuple("block_expr_base_statements", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + if let Some(v) = self.tail { + out.add_tuple("block_expr_base_tails", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct BlockExpr { + pub id: TrapId, + pub location: Option, + pub statements: Vec, + pub tail: Option, + pub label: Option, +} + +impl TrapEntry for BlockExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("block_exprs", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.statements.into_iter().enumerate() { + out.add_tuple("block_expr_base_statements", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + if let Some(v) = self.tail { + out.add_tuple("block_expr_base_tails", vec![trap::Arg::Label(id), v.into()]); + } + if let Some(v) = self.label { + out.add_tuple("block_expr_labels", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct ElementListExpr { + pub id: TrapId, + pub location: Option, + pub elements: Vec, + pub is_assignee_expr: bool, +} + +impl TrapEntry for ElementListExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("element_list_exprs", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.elements.into_iter().enumerate() { + out.add_tuple("element_list_expr_elements", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + if self.is_assignee_expr { + out.add_tuple("element_list_expr_is_assignee_expr", vec![trap::Arg::Label(id)]); + } + } +} + +#[derive(Debug)] +pub struct RepeatExpr { + pub id: TrapId, + pub location: Option, + pub initializer: trap::Label, + pub repeat: trap::Label, +} + +impl TrapEntry for RepeatExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("repeat_exprs", vec![trap::Arg::Label(id), self.initializer.into(), self.repeat.into()]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + } +} + +#[derive(Debug)] +pub struct UnsafeBlockExpr { + pub id: TrapId, + pub location: Option, + pub statements: Vec, + pub tail: Option, +} + +impl TrapEntry for UnsafeBlockExpr { + fn extract_id(&mut self) -> TrapId { + std::mem::replace(&mut self.id, TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("unsafe_block_exprs", vec![trap::Arg::Label(id)]); + if let Some(v) = self.location { + out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]); + } + for (i, v) in self.statements.into_iter().enumerate() { + out.add_tuple("block_expr_base_statements", vec![trap::Arg::Label(id), i.into(), v.into()]); + } + if let Some(v) = self.tail { + out.add_tuple("block_expr_base_tails", vec![trap::Arg::Label(id), v.into()]); + } + } +} diff --git a/rust/extractor/src/main.rs b/rust/extractor/src/main.rs new file mode 100644 index 000000000000..caac7d1243aa --- /dev/null +++ b/rust/extractor/src/main.rs @@ -0,0 +1,94 @@ +use crate::trap::TrapId; +use anyhow::Context; +use ra_ap_hir::db::DefDatabase; +use ra_ap_hir::Crate; +use ra_ap_load_cargo::{load_workspace_at, LoadCargoConfig, ProcMacroServerChoice}; +use ra_ap_project_model::CargoConfig; +use ra_ap_project_model::RustLibSource; +use ra_ap_vfs::AbsPathBuf; +use std::path::PathBuf; + +mod archive; +mod config; +pub mod generated; +pub mod path; +mod translate; +pub mod trap; + +fn find_project_manifests( + files: &[PathBuf], +) -> anyhow::Result> { + let current = std::env::current_dir()?; + let abs_files: Vec<_> = files + .iter() + .map(|path| AbsPathBuf::assert_utf8(current.join(path))) + .collect(); + Ok(ra_ap_project_model::ProjectManifest::discover_all( + &abs_files, + )) +} + +fn main() -> anyhow::Result<()> { + let cfg = config::Config::extract().context("failed to load configuration")?; + stderrlog::new() + .module(module_path!()) + .verbosity(2 + cfg.verbose as usize) + .init()?; + log::info!("{cfg:?}"); + let traps = trap::TrapFileProvider::new(&cfg).context("failed to set up trap files")?; + let archiver = archive::Archiver { + root: cfg.source_archive_dir, + }; + + let config = CargoConfig { + sysroot: Some(RustLibSource::Discover), + target_dir: ra_ap_paths::Utf8PathBuf::from_path_buf(cfg.scratch_dir) + .map(|x| x.join("target")) + .ok(), + ..Default::default() + }; + let progress = |t| (log::info!("progress: {}", t)); + let load_config = LoadCargoConfig { + load_out_dirs_from_check: true, + with_proc_macro_server: ProcMacroServerChoice::Sysroot, + prefill_caches: false, + }; + let projects = find_project_manifests(&cfg.inputs).context("loading inputs")?; + for project in projects { + let (db, vfs, _macro_server) = load_workspace_at( + project.manifest_path().as_ref(), + &config, + &load_config, + &progress, + )?; + + let crates = ::crate_graph(&db); + for crate_id in crates.iter() { + let krate = Crate::from(crate_id); + let name = krate.display_name(&db); + let crate_name = name + .as_ref() + .map(|n| n.canonical_name().as_str()) + .unwrap_or(""); + let trap = traps.create( + "crates", + &PathBuf::from(format!( + "/{}_{}", + crate_name, + crate_id.into_raw().into_u32() + )), + ); + translate::CrateTranslator::new( + &db, + trap, + &krate, + &vfs, + &archiver, + cfg.extract_dependencies, + ) + .emit_crate() + .context("writing trap file")?; + } + } + Ok(()) +} diff --git a/rust/extractor/src/path.rs b/rust/extractor/src/path.rs new file mode 100644 index 000000000000..0da1cb2932f4 --- /dev/null +++ b/rust/extractor/src/path.rs @@ -0,0 +1,10 @@ +use std::fs::canonicalize; +use std::path::{absolute, Path, PathBuf}; + +pub fn key(p: &Path) -> PathBuf { + let normalized = canonicalize(p) + .or_else(|_| absolute(p)) + .unwrap_or_else(|_| p.into()); + let root = normalized.ancestors().last().unwrap(); // ancestors always yields at least one + normalized.strip_prefix(root).unwrap().into() // stripping an ancestor always works +} diff --git a/rust/extractor/src/translate.rs b/rust/extractor/src/translate.rs new file mode 100644 index 000000000000..315cfc399109 --- /dev/null +++ b/rust/extractor/src/translate.rs @@ -0,0 +1,1031 @@ +use crate::archive::Archiver; +use crate::trap::{AsTrapKeyPart, TrapFile, TrapId}; +use crate::{generated, trap_key}; +use codeql_extractor::trap; +use ra_ap_hir::db::{DefDatabase, InternDatabase}; +use ra_ap_hir::HasSource; +use ra_ap_hir::TypeRef; +use ra_ap_hir::{Crate, Module, ModuleDef}; +use ra_ap_hir_def::body::{Body, BodySourceMap}; +use ra_ap_hir_def::hir::{ + CaptureBy, ExprId, LabelId, MatchArm, PatId, RecordFieldPat, RecordLitField, Statement, +}; +use ra_ap_hir_def::path::Path; +use ra_ap_ide_db::line_index::LineIndex; +use ra_ap_ide_db::{LineIndexDatabase, RootDatabase}; +use ra_ap_syntax::ast::RangeOp; +use ra_ap_syntax::{AstNode, Edition, TextRange, TextSize}; +use ra_ap_vfs::{FileId, Vfs}; +use std::collections::HashMap; +use std::fs; +use std::path::PathBuf; +use triomphe::Arc; + +#[derive(Clone)] +struct FileData { + label: trap::Label, + line_index: Arc, +} +pub struct CrateTranslator<'a> { + db: &'a RootDatabase, + trap: TrapFile, + krate: &'a Crate, + vfs: &'a Vfs, + archiver: &'a Archiver, + extract_dependencies: bool, + file_labels: HashMap, +} + +impl CrateTranslator<'_> { + pub fn new<'a>( + db: &'a RootDatabase, + trap: TrapFile, + krate: &'a Crate, + vfs: &'a Vfs, + archiver: &'a Archiver, + extract_dependencies: bool, + ) -> CrateTranslator<'a> { + CrateTranslator { + db, + trap, + krate, + vfs, + archiver, + extract_dependencies, + file_labels: HashMap::new(), + } + } + + fn emit_file(&mut self, file_id: FileId) -> Option { + self.vfs.file_path(file_id).as_path().and_then(|abs_path| { + let mut canonical = PathBuf::from(abs_path.as_str()); + if !self.file_labels.contains_key(&canonical) { + self.archiver.archive(&canonical); + canonical = fs::canonicalize(&canonical).unwrap_or(canonical); + let name = canonical.to_string_lossy(); + let label = self.trap.emit(generated::DbFile { + id: trap_key!["file;", name.as_ref()], + name: String::from(name), + }); + let line_index = ::line_index(self.db, file_id); + self.file_labels + .insert(canonical.clone(), FileData { label, line_index }); + } + self.file_labels.get(&canonical).cloned() + }) + } + + fn emit_location_for_ast_ptr( + &mut self, + source: ra_ap_hir::InFile>, + ) -> Option + where + T: AstNode, + { + source + .file_id + .file_id() + .map(|f| (f.file_id(), source)) + .and_then(|(file_id, source)| self.emit_file(file_id).map(|data| (data, source))) + .map(|(data, source)| { + let range = source.value.text_range(); + self.emit_location_for_textrange(data, range) + }) + } + + fn emit_location_for_expr( + &mut self, + expr: ra_ap_hir_def::hir::ExprId, + source_map: &BodySourceMap, + ) -> Option { + let source = source_map.expr_syntax(expr).ok()?; + self.emit_location_for_ast_ptr(source) + } + + fn emit_location_for_pat( + &mut self, + pat_id: ra_ap_hir_def::hir::PatId, + source_map: &BodySourceMap, + ) -> Option { + let source = source_map.pat_syntax(pat_id).ok()?; + self.emit_location_for_ast_ptr(source) + } + + fn emit_literal_or_const_pat( + &mut self, + pat: &ra_ap_hir_def::hir::LiteralOrConst, + location: Option, + body: &Body, + source_map: &BodySourceMap, + ) -> trap::Label { + match pat { + ra_ap_hir_def::hir::LiteralOrConst::Literal(_literal) => { + let expr = self.trap.emit(generated::LiteralExpr { + id: TrapId::Star, + location: None, + }); + self.trap.emit(generated::LitPat { + id: TrapId::Star, + location, + expr, + }) + } + ra_ap_hir_def::hir::LiteralOrConst::Const(inner) => { + self.emit_pat(*inner, body, source_map) + } + } + } + + fn emit_location_for_label( + &mut self, + label_id: ra_ap_hir_def::hir::LabelId, + source_map: &BodySourceMap, + ) -> Option { + // 'catch' a panic if the source map is incomplete + let source = std::panic::catch_unwind(|| source_map.label_syntax(label_id)).ok(); + source.and_then(|source| self.emit_location_for_ast_ptr(source)) + } + fn emit_location(&mut self, entity: T) -> Option + where + T::Ast: AstNode, + { + entity + .source(self.db) + .and_then(|source| source.file_id.file_id().map(|f| (f.file_id(), source))) + .and_then(|(file_id, source)| self.emit_file(file_id).map(|data| (data, source))) + .map(|(data, source)| { + let range = source.value.syntax().text_range(); + self.emit_location_for_textrange(data, range) + }) + } + fn emit_location_for_textrange(&mut self, data: FileData, range: TextRange) -> trap::Label { + let start = data.line_index.line_col(range.start()); + let end = data.line_index.line_col( + range + .end() + .checked_sub(TextSize::new(1)) + .unwrap_or(range.end()), + ); + self.trap.emit_location(data.label, start, end) + } + fn emit_label( + &mut self, + label_id: LabelId, + body: &Body, + source_map: &BodySourceMap, + ) -> trap::Label { + let location: Option = self.emit_location_for_label(label_id, source_map); + let label = &body.labels[label_id]; + self.trap.emit(generated::Label { + id: TrapId::Star, + location, + name: label.name.as_str().into(), + }) + } + + fn emit_unimplemented(&mut self, location: Option) -> trap::Label { + self.trap.emit(generated::Unimplemented { + id: TrapId::Star, + location, + }) + } + fn emit_path(&mut self, _path: &Path, location: Option) -> trap::Label { + self.emit_unimplemented(location) + } + + fn emit_record_field_pat( + &mut self, + field_pat: &RecordFieldPat, + body: &Body, + source_map: &BodySourceMap, + ) -> trap::Label { + let RecordFieldPat { name, pat } = field_pat; + let location = self.emit_location_for_pat(*pat, source_map); + let pat = self.emit_pat(*pat, body, source_map); + self.trap.emit(generated::RecordFieldPat { + id: TrapId::Star, + location, + name: name.as_str().into(), + pat, + }) + } + + fn emit_record_lit_field( + &mut self, + field_expr: &RecordLitField, + body: &Body, + source_map: &BodySourceMap, + ) -> trap::Label { + let RecordLitField { name, expr } = field_expr; + let location = self.emit_location_for_expr(*expr, source_map); + let expr = self.emit_expr(*expr, body, source_map); + self.trap.emit(generated::RecordLitField { + id: TrapId::Star, + location, + name: name.as_str().into(), + expr, + }) + } + fn emit_pat(&mut self, pat_id: PatId, body: &Body, source_map: &BodySourceMap) -> trap::Label { + let location: Option = self.emit_location_for_pat(pat_id, source_map); + let pat = &body.pats[pat_id]; + match pat { + ra_ap_hir_def::hir::Pat::Missing => self.trap.emit(generated::MissingPat { + id: TrapId::Star, + location, + }), + ra_ap_hir_def::hir::Pat::Wild => self.trap.emit(generated::WildPat { + id: TrapId::Star, + location, + }), + ra_ap_hir_def::hir::Pat::Tuple { args, ellipsis } => { + let args = args + .into_iter() + .map(|pat| self.emit_pat(*pat, body, source_map)) + .collect(); + let ellipsis_index = ellipsis.and_then(|x| x.try_into().ok()); + self.trap.emit(generated::TuplePat { + id: TrapId::Star, + location, + args, + ellipsis_index, + }) + } + ra_ap_hir_def::hir::Pat::Or(args) => { + let args = args + .into_iter() + .map(|pat| self.emit_pat(*pat, body, source_map)) + .collect(); + self.trap.emit(generated::OrPat { + id: TrapId::Star, + location, + args, + }) + } + ra_ap_hir_def::hir::Pat::Record { + path, + args, + ellipsis, + } => { + let path = path.as_ref().map(|path| self.emit_path(path, location)); + let args = args + .into_iter() + .map(|arg| self.emit_record_field_pat(arg, body, source_map)) + .collect(); + self.trap.emit(generated::RecordPat { + id: TrapId::Star, + location, + path, + args, + has_ellipsis: *ellipsis, + }) + } + ra_ap_hir_def::hir::Pat::Range { start, end } => { + let start = start + .as_ref() + .map(|x| self.emit_literal_or_const_pat(x, location, body, source_map)); + let end = end + .as_ref() + .map(|x| self.emit_literal_or_const_pat(x, location, body, source_map)); + self.trap.emit(generated::RangePat { + id: TrapId::Star, + location, + start, + end, + }) + } + ra_ap_hir_def::hir::Pat::Slice { + prefix, + slice, + suffix, + } => { + let prefix = prefix + .into_iter() + .map(|pat| self.emit_pat(*pat, body, source_map)) + .collect(); + let slice = slice.map(|pat| self.emit_pat(pat, body, source_map)); + let suffix = suffix + .into_iter() + .map(|pat| self.emit_pat(*pat, body, source_map)) + .collect(); + self.trap.emit(generated::SlicePat { + id: TrapId::Star, + location, + prefix, + slice, + suffix, + }) + } + ra_ap_hir_def::hir::Pat::Path(path) => { + let path = self.emit_path(path, location); + self.trap.emit(generated::PathPat { + id: TrapId::Star, + location, + path, + }) + } + ra_ap_hir_def::hir::Pat::Lit(expr) => { + let expr = self.emit_expr(*expr, body, source_map); + self.trap.emit(generated::LitPat { + id: TrapId::Star, + location, + expr, + }) + } + ra_ap_hir_def::hir::Pat::Bind { id, subpat } => { + let subpat = subpat.map(|pat| self.emit_pat(pat, body, source_map)); + self.trap.emit(generated::BindPat { + id: TrapId::Star, + location, + subpat, + binding_id: body.bindings[*id].name.as_str().into(), + }) + } + ra_ap_hir_def::hir::Pat::TupleStruct { + path, + args, + ellipsis, + } => { + let path = path.as_ref().map(|path| self.emit_path(path, location)); + let args = args + .into_iter() + .map(|arg| self.emit_pat(*arg, body, source_map)) + .collect(); + self.trap.emit(generated::TupleStructPat { + id: TrapId::Star, + location, + path, + args, + ellipsis_index: ellipsis.map(|x| x as usize), + }) + } + ra_ap_hir_def::hir::Pat::Ref { pat, mutability } => { + let pat = self.emit_pat(*pat, body, source_map); + self.trap.emit(generated::RefPat { + id: TrapId::Star, + location, + pat, + is_mut: mutability.is_mut(), + }) + } + ra_ap_hir_def::hir::Pat::Box { inner } => { + let inner = self.emit_pat(*inner, body, source_map); + self.trap.emit(generated::BoxPat { + id: TrapId::Star, + location, + inner, + }) + } + ra_ap_hir_def::hir::Pat::ConstBlock(expr) => { + let expr = self.emit_expr(*expr, body, source_map); + self.trap.emit(generated::ConstBlockPat { + id: TrapId::Star, + location, + expr, + }) + } + } + } + fn emit_type_ref(&mut self, _type_ref: &TypeRef) -> trap::Label { + self.emit_unimplemented(None) + } + fn emit_match_arm( + &mut self, + arm: &MatchArm, + body: &Body, + source_map: &BodySourceMap, + ) -> trap::Label { + let location: Option = self.emit_location_for_pat(arm.pat, source_map); + let pat = self.emit_pat(arm.pat, body, source_map); + let guard = arm.guard.map(|g| self.emit_expr(g, body, source_map)); + let expr = self.emit_expr(arm.expr, body, source_map); + self.trap.emit(generated::MatchArm { + id: TrapId::Star, + location, + pat, + guard, + expr, + }) + } + fn emit_stmt( + &mut self, + stmt: &Statement, + body: &Body, + source_map: &BodySourceMap, + ) -> trap::Label { + match stmt { + Statement::Let { + pat, + type_ref, + initializer, + else_branch, + } => { + // TODO: find a way to get the location of the entire statement + let location = self.emit_location_for_pat(*pat, source_map); + let pat = self.emit_pat(*pat, body, source_map); + let type_ref = type_ref + .as_ref() + .map(|type_ref| self.emit_type_ref(type_ref)); + let initializer = + initializer.map(|initializer| self.emit_expr(initializer, body, source_map)); + let else_ = else_branch.map(|else_| self.emit_expr(else_, body, source_map)); + + self.trap.emit(generated::LetStmt { + id: TrapId::Star, + location, + pat, + type_ref, + initializer, + else_, + }) + } + Statement::Expr { expr, has_semi } => { + let location = self.emit_location_for_expr(*expr, source_map); + let expr = self.emit_expr(*expr, body, source_map); + self.trap.emit(generated::ExprStmt { + id: TrapId::Star, + location, + expr, + has_semicolon: *has_semi, + }) + } + Statement::Item => self.trap.emit(generated::ItemStmt { + id: TrapId::Star, + location: None, + }), + } + } + fn emit_expr( + &mut self, + expr_id: ExprId, + body: &Body, + source_map: &BodySourceMap, + ) -> trap::Label { + let location: Option = self.emit_location_for_expr(expr_id, source_map); + let expr = &body[expr_id]; + match expr { + ra_ap_hir_def::hir::Expr::Missing => self.trap.emit(generated::MissingExpr { + id: TrapId::Star, + location, + }), + ra_ap_hir_def::hir::Expr::Path(path) => { + let path = self.emit_path(path, location); + self.trap.emit(generated::PathExpr { + id: TrapId::Star, + location, + path, + }) + } + ra_ap_hir_def::hir::Expr::If { + condition, + then_branch, + else_branch, + } => { + let condition = self.emit_expr(*condition, body, source_map); + let then = self.emit_expr(*then_branch, body, source_map); + let else_ = else_branch.map(|x| self.emit_expr(x, body, source_map)); + self.trap.emit(generated::IfExpr { + id: TrapId::Star, + location, + condition, + then, + else_, + }) + } + ra_ap_hir_def::hir::Expr::Let { pat, expr } => { + let pat = self.emit_pat(*pat, body, source_map); + let expr = self.emit_expr(*expr, body, source_map); + self.trap.emit(generated::LetExpr { + id: TrapId::Star, + location, + pat, + expr, + }) + } + ra_ap_hir_def::hir::Expr::Block { + id: _, + statements, + tail, + label, + } => { + let statements = statements + .into_iter() + .map(|stmt| self.emit_stmt(stmt, body, source_map)) + .collect(); + let tail = tail.map(|expr_id| self.emit_expr(expr_id, body, source_map)); + let label = label.map(|l| self.emit_label(l, body, source_map)); + self.trap.emit(generated::BlockExpr { + id: TrapId::Star, + location, + statements, + tail, + label, + }) + } + ra_ap_hir_def::hir::Expr::Async { + id: _, + statements, + tail, + } => { + let statements = statements + .into_iter() + .map(|stmt| self.emit_stmt(stmt, body, source_map)) + .collect(); + let tail = tail.map(|expr_id| self.emit_expr(expr_id, body, source_map)); + self.trap.emit(generated::AsyncBlockExpr { + id: TrapId::Star, + location, + statements, + tail, + }) + } + ra_ap_hir_def::hir::Expr::Const(const_block) => { + let expr_id = self.db.lookup_intern_anonymous_const(*const_block).root; + let expr = self.emit_expr(expr_id, body, source_map); + self.trap.emit(generated::ConstExpr { + id: TrapId::Star, + location, + expr, + }) + } + ra_ap_hir_def::hir::Expr::Unsafe { + id: _, + statements, + tail, + } => { + let statements = statements + .into_iter() + .map(|stmt| self.emit_stmt(stmt, body, source_map)) + .collect(); + let tail = tail.map(|expr_id| self.emit_expr(expr_id, body, source_map)); + self.trap.emit(generated::UnsafeBlockExpr { + id: TrapId::Star, + location, + statements, + tail, + }) + } + ra_ap_hir_def::hir::Expr::Loop { + body: loop_body, + label, + } => { + let loop_body = self.emit_expr(*loop_body, body, source_map); + let label = label.map(|l| self.emit_label(l, body, source_map)); + self.trap.emit(generated::LoopExpr { + id: TrapId::Star, + location, + body: loop_body, + label, + }) + } + ra_ap_hir_def::hir::Expr::Call { + callee, + args, + is_assignee_expr, + } => { + let callee = self.emit_expr(*callee, body, source_map); + let args = args + .into_iter() + .map(|e| self.emit_expr(*e, body, source_map)) + .collect(); + self.trap.emit(generated::CallExpr { + id: TrapId::Star, + location, + callee, + args, + is_assignee_expr: *is_assignee_expr, + }) + } + ra_ap_hir_def::hir::Expr::MethodCall { + receiver, + method_name, + args, + generic_args, + } => { + let receiver = self.emit_expr(*receiver, body, source_map); + let args = args + .into_iter() + .map(|e| self.emit_expr(*e, body, source_map)) + .collect(); + let generic_args = generic_args + .as_ref() + .map(|_args| self.emit_unimplemented(None)); + self.trap.emit(generated::MethodCallExpr { + id: TrapId::Star, + location, + receiver, + method_name: method_name.as_str().into(), + args, + generic_args, + }) + } + ra_ap_hir_def::hir::Expr::Match { expr, arms } => { + let expr = self.emit_expr(*expr, body, source_map); + let branches = arms + .into_iter() + .map(|e| self.emit_match_arm(e, body, source_map)) + .collect(); + + self.trap.emit(generated::MatchExpr { + id: TrapId::Star, + location, + expr, + branches, + }) + } + ra_ap_hir_def::hir::Expr::Continue { label } => { + let label = label.map(|l| self.emit_label(l, body, source_map)); + self.trap.emit(generated::ContinueExpr { + id: TrapId::Star, + location, + label, + }) + } + ra_ap_hir_def::hir::Expr::Break { expr, label } => { + let expr = expr.map(|e| self.emit_expr(e, body, source_map)); + let label = label.map(|l| self.emit_label(l, body, source_map)); + self.trap.emit(generated::BreakExpr { + id: TrapId::Star, + location, + expr, + label, + }) + } + ra_ap_hir_def::hir::Expr::Return { expr } => { + let expr = expr.map(|e| self.emit_expr(e, body, source_map)); + self.trap.emit(generated::ReturnExpr { + id: TrapId::Star, + location, + expr, + }) + } + ra_ap_hir_def::hir::Expr::Become { expr } => { + let expr = self.emit_expr(*expr, body, source_map); + self.trap.emit(generated::BecomeExpr { + id: TrapId::Star, + location, + expr, + }) + } + ra_ap_hir_def::hir::Expr::Yield { expr } => { + let expr = expr.map(|e| self.emit_expr(e, body, source_map)); + self.trap.emit(generated::YieldExpr { + id: TrapId::Star, + location, + expr, + }) + } + ra_ap_hir_def::hir::Expr::Yeet { expr } => { + let expr = expr.map(|e| self.emit_expr(e, body, source_map)); + self.trap.emit(generated::YeetExpr { + id: TrapId::Star, + location, + expr, + }) + } + ra_ap_hir_def::hir::Expr::RecordLit { + path, //TODO + fields, + spread, + ellipsis, + is_assignee_expr, + } => { + let path = path.as_ref().map(|path| self.emit_path(path, location)); + let fields = fields + .into_iter() + .map(|field| self.emit_record_lit_field(field, body, source_map)) + .collect(); + let spread = spread.map(|expr_id| self.emit_expr(expr_id, body, source_map)); + self.trap.emit(generated::RecordLitExpr { + id: TrapId::Star, + location, + path, + fields, + spread, + has_ellipsis: *ellipsis, + is_assignee_expr: *is_assignee_expr, + }) + } + ra_ap_hir_def::hir::Expr::Field { expr, name } => { + let expr = self.emit_expr(*expr, body, source_map); + self.trap.emit(generated::FieldExpr { + id: TrapId::Star, + location, + expr, + name: name.as_str().into(), + }) + } + ra_ap_hir_def::hir::Expr::Await { expr } => { + let expr = self.emit_expr(*expr, body, source_map); + self.trap.emit(generated::AwaitExpr { + id: TrapId::Star, + location, + expr, + }) + } + ra_ap_hir_def::hir::Expr::Cast { expr, type_ref } => { + let expr: trap::Label = self.emit_expr(*expr, body, source_map); + let type_ref: trap::Label = self.emit_type_ref(type_ref.as_ref()); + self.trap.emit(generated::CastExpr { + id: TrapId::Star, + location, + expr, + type_ref, + }) + } + ra_ap_hir_def::hir::Expr::Ref { + expr, + rawness, + mutability, + } => { + let expr = self.emit_expr(*expr, body, source_map); + self.trap.emit(generated::RefExpr { + id: TrapId::Star, + location, + expr, + is_mut: mutability.is_mut(), + is_raw: rawness.is_raw(), + }) + } + ra_ap_hir_def::hir::Expr::Box { expr } => { + let expr = self.emit_expr(*expr, body, source_map); + self.trap.emit(generated::BoxExpr { + id: TrapId::Star, + location, + expr, + }) + } + ra_ap_hir_def::hir::Expr::UnaryOp { expr, op } => { + let expr = self.emit_expr(*expr, body, source_map); + let op = match op { + ra_ap_syntax::ast::UnaryOp::Deref => "*", + ra_ap_syntax::ast::UnaryOp::Not => "!", + ra_ap_syntax::ast::UnaryOp::Neg => "-", + }; + self.trap.emit(generated::UnaryOpExpr { + id: TrapId::Star, + location, + expr, + op: op.into(), + }) + } + ra_ap_hir_def::hir::Expr::BinaryOp { lhs, rhs, op } => { + let lhs = self.emit_expr(*lhs, body, source_map); + let rhs = self.emit_expr(*rhs, body, source_map); + let op = op.map(|op| format!("{op}")); + self.trap.emit(generated::BinaryOpExpr { + id: TrapId::Star, + location, + lhs, + rhs, + op, + }) + } + ra_ap_hir_def::hir::Expr::Range { + lhs, + rhs, + range_type, + } => { + let lhs = lhs.map(|lhs| self.emit_expr(lhs, body, source_map)); + let rhs = rhs.map(|rhs| self.emit_expr(rhs, body, source_map)); + self.trap.emit(generated::RangeExpr { + id: TrapId::Star, + location, + lhs, + rhs, + is_inclusive: *range_type == RangeOp::Inclusive, + }) + } + ra_ap_hir_def::hir::Expr::Index { + base, + index, + is_assignee_expr, + } => { + let base = self.emit_expr(*base, body, source_map); + let index = self.emit_expr(*index, body, source_map); + self.trap.emit(generated::IndexExpr { + id: TrapId::Star, + location, + base, + index, + is_assignee_expr: *is_assignee_expr, + }) + } + ra_ap_hir_def::hir::Expr::Closure { + args, + arg_types, + ret_type, + body: expr, + closure_kind, //TODO: + capture_by, + } => { + let expr = self.emit_expr(*expr, body, source_map); + let args = args + .into_iter() + .map(|arg| self.emit_pat(*arg, body, source_map)) + .collect(); + let ret_type = ret_type + .as_ref() + .map(|ret_type| self.emit_type_ref(ret_type)); + let arg_types = arg_types + .into_iter() + .map(|arg_type| { + arg_type + .as_ref() + .map(|arg_type| self.emit_type_ref(arg_type)) + }) + .collect(); + self.trap.emit(generated::ClosureExpr { + id: TrapId::Star, + location, + args, + arg_types, + body: expr, + ret_type, + closure_kind: format!("{:?}", closure_kind), + is_move: *capture_by == CaptureBy::Value, + }) + } + ra_ap_hir_def::hir::Expr::Tuple { + exprs, + is_assignee_expr, + } => { + let exprs = exprs + .into_iter() + .map(|expr| self.emit_expr(*expr, body, source_map)) + .collect(); + self.trap.emit(generated::TupleExpr { + id: TrapId::Star, + location, + exprs, + is_assignee_expr: *is_assignee_expr, + }) + } + ra_ap_hir_def::hir::Expr::Array(ra_ap_hir_def::hir::Array::ElementList { + elements, + is_assignee_expr, + }) => { + let elements = elements + .into_iter() + .map(|expr| self.emit_expr(*expr, body, source_map)) + .collect(); + self.trap.emit(generated::ElementListExpr { + id: TrapId::Star, + location, + elements, + is_assignee_expr: *is_assignee_expr, + }) + } + ra_ap_hir_def::hir::Expr::Array(ra_ap_hir_def::hir::Array::Repeat { + initializer, + repeat, + }) => { + let initializer: trap::Label = self.emit_expr(*initializer, body, source_map); + let repeat: trap::Label = self.emit_expr(*repeat, body, source_map); + + self.trap.emit(generated::RepeatExpr { + id: TrapId::Star, + location, + initializer, + repeat, + }) + } + ra_ap_hir_def::hir::Expr::Literal(_literal) => self.trap.emit(generated::LiteralExpr { + id: TrapId::Star, + location, + }), + ra_ap_hir_def::hir::Expr::Underscore => self.trap.emit(generated::UnderscoreExpr { + id: TrapId::Star, + location, + }), + ra_ap_hir_def::hir::Expr::OffsetOf(offset) => { + let container = self.emit_type_ref(&offset.container); + let fields = offset.fields.iter().map(|x| x.as_str().into()).collect(); + self.trap.emit(generated::OffsetOfExpr { + id: TrapId::Star, + location, + container, + fields, + }) + } + ra_ap_hir_def::hir::Expr::InlineAsm(asm) => { + let expr = self.emit_expr(asm.e, body, source_map); + self.trap.emit(generated::InlineAsmExpr { + id: TrapId::Star, + location, + expr, + }) + } + } + } + + fn emit_definition( + &mut self, + module_label: trap::Label, + id: ModuleDef, + labels: &mut Vec, + ) { + match id { + ModuleDef::Module(_) => { + self.emit_unimplemented(None); + } + ModuleDef::Function(function) => { + let def: ra_ap_hir::DefWithBody = function.into(); + + let name = function.name(self.db); + let location = self.emit_location(function); + + let body = if self.extract_dependencies || self.krate.origin(self.db).is_local() { + let (body, source_map) = self.db.body_with_source_map(def.into()); + let txt = body.pretty_print(self.db, def.into(), Edition::Edition2021); + log::trace!("{}", &txt); + self.emit_expr(body.body_expr, &body, &source_map) + } else { + self.trap.emit(generated::MissingExpr { + id: TrapId::Star, + location: None, + }) + }; + labels.push(self.trap.emit(generated::Function { + id: trap_key![module_label, name.as_str()], + location, + name: name.as_str().into(), + body, + })) + } + ModuleDef::Adt(adt) => { + let location = self.emit_location(adt); + self.emit_unimplemented(location); + } + ModuleDef::Variant(variant) => { + let location = self.emit_location(variant); + self.emit_unimplemented(location); + } + ModuleDef::Const(const_) => { + let location = self.emit_location(const_); + self.emit_unimplemented(location); + } + ModuleDef::Static(static_) => { + let location = self.emit_location(static_); + self.emit_unimplemented(location); + } + ModuleDef::Trait(trait_) => { + let location = self.emit_location(trait_); + self.emit_unimplemented(location); + } + ModuleDef::TraitAlias(alias) => { + let location = self.emit_location(alias); + self.emit_unimplemented(location); + } + ModuleDef::TypeAlias(type_alias) => { + let location = self.emit_location(type_alias); + self.emit_unimplemented(location); + } + ModuleDef::BuiltinType(_builtin_type) => { + self.emit_unimplemented(None); + } + ModuleDef::Macro(macro_) => { + let location = self.emit_location(macro_); + self.emit_unimplemented(location); + } + } + } + + fn emit_module(&mut self, label: trap::Label, module: Module) { + let mut children = Vec::new(); + for id in module.declarations(self.db) { + self.emit_definition(label, id, &mut children); + } + self.trap.emit(generated::Module { + id: label.into(), + location: None, + declarations: children, + }); + } + + pub fn emit_crate(&mut self) -> std::io::Result<()> { + self.emit_file(self.krate.root_file(self.db)); + let mut map = HashMap::::new(); + for module in self.krate.modules(self.db) { + let mut key = String::new(); + if let Some(parent) = module.parent(self.db) { + // assumption: parent was already listed + let parent_label = *map.get(&parent).unwrap(); + key.push_str(&parent_label.as_key_part()); + } + let def = module.definition_source(self.db); + if let Some(file) = def.file_id.file_id() { + if let Some(data) = self.emit_file(file.file_id()) { + key.push_str(&data.label.as_key_part()); + } + } + if let Some(name) = module.name(self.db) { + key.push_str(name.as_str()); + } + let label = self.trap.label(TrapId::Key(key)); + map.insert(module, label); + self.emit_module(label, module); + } + self.trap.commit() + } +} diff --git a/rust/extractor/src/trap.rs b/rust/extractor/src/trap.rs new file mode 100644 index 000000000000..af56166cd051 --- /dev/null +++ b/rust/extractor/src/trap.rs @@ -0,0 +1,166 @@ +use crate::config::Compression; +use crate::generated; +use crate::{config, path}; +use codeql_extractor::trap; +use log::debug; +use ra_ap_ide_db::line_index::LineCol; +use std::ffi::OsString; +use std::fmt::Debug; +use std::path::{Path, PathBuf}; + +//TODO: typed labels +pub trait AsTrapKeyPart { + fn as_key_part(&self) -> String; +} + +impl AsTrapKeyPart for trap::Label { + fn as_key_part(&self) -> String { + format!("{{{}}}", self) + } +} + +impl AsTrapKeyPart for String { + fn as_key_part(&self) -> String { + self.clone() + } +} + +impl AsTrapKeyPart for &str { + fn as_key_part(&self) -> String { + String::from(*self) + } +} + +#[derive(Debug, Clone)] +pub enum TrapId { + Star, + Key(String), + Label(trap::Label), +} + +impl From for TrapId { + fn from(value: String) -> Self { + TrapId::Key(value) + } +} + +impl From<&str> for TrapId { + fn from(value: &str) -> Self { + TrapId::Key(value.into()) + } +} + +impl From for TrapId { + fn from(value: trap::Label) -> Self { + TrapId::Label(value) + } +} + +#[macro_export] +macro_rules! trap_key { + ($($x:expr),+ $(,)?) => {{ + let mut key = String::new(); + $( + key.push_str(&$x.as_key_part()); + )* + $crate::TrapId::Key(key) + }}; +} + +pub trait TrapEntry: std::fmt::Debug { + fn extract_id(&mut self) -> TrapId; + fn emit(self, id: trap::Label, out: &mut trap::Writer); +} + +pub struct TrapFile { + path: PathBuf, + writer: trap::Writer, + compression: Compression, +} + +impl TrapFile { + pub fn emit_location( + &mut self, + file_label: trap::Label, + start: LineCol, + end: LineCol, + ) -> trap::Label { + let start_line = 1 + start.line as usize; + let start_column = 1 + start.col as usize; + let end_line = 1 + end.line as usize; + let end_column = 1 + end.col as usize; + let (ret, _) = self.writer.location_label(trap::Location { + file_label, + start_line, + start_column, + end_line, + end_column, + }); + self.emit(generated::DbLocation { + id: ret.into(), + file: file_label, + start_line, + start_column, + end_line, + end_column, + }); + ret + } + + pub fn label(&mut self, id: TrapId) -> trap::Label { + match id { + TrapId::Star => self.writer.fresh_id(), + TrapId::Key(s) => self.writer.global_id(&s).0, + TrapId::Label(l) => l, + } + } + + pub fn emit(&mut self, mut e: T) -> trap::Label { + let label = self.label(e.extract_id()); + e.emit(label, &mut self.writer); + label + } + + pub fn commit(&self) -> std::io::Result<()> { + std::fs::create_dir_all(self.path.parent().unwrap())?; + self.writer + .write_to_file(&self.path, self.compression.into()) + } +} + +pub struct TrapFileProvider { + trap_dir: PathBuf, + compression: Compression, +} + +impl TrapFileProvider { + pub fn new(cfg: &config::Config) -> std::io::Result { + let trap_dir = cfg.trap_dir.clone(); + std::fs::create_dir_all(&trap_dir)?; + Ok(TrapFileProvider { + trap_dir, + compression: cfg.compression, + }) + } + + pub fn create(&self, category: &str, key: &Path) -> TrapFile { + let mut path = PathBuf::from(category); + path.push(path::key(key)); + path.set_extension( + path.extension() + .map(|e| { + let mut o: OsString = e.to_owned(); + o.push(".trap"); + o + }) + .unwrap_or("trap".into()), + ); + debug!("creating trap file {}", path.display()); + path = self.trap_dir.join(path); + TrapFile { + path, + writer: trap::Writer::new(), + compression: self.compression, + } + } +} diff --git a/rust/integration-tests/test.py b/rust/integration-tests/test.py new file mode 100644 index 000000000000..b2d446decd2e --- /dev/null +++ b/rust/integration-tests/test.py @@ -0,0 +1,4 @@ +# dummy test to get CI going + +def test(codeql, rust): + pass diff --git a/rust/lint.py b/rust/lint.py new file mode 100755 index 000000000000..1af2470dbbcf --- /dev/null +++ b/rust/lint.py @@ -0,0 +1,16 @@ +#!/bin/env python3 + +import subprocess +import pathlib +import shutil +import sys + +extractor_dir = pathlib.Path(__file__).resolve().parent / "extractor" + +cargo = shutil.which("cargo") +assert cargo, "no cargo binary found on `PATH`" + +fmt = subprocess.run([cargo, "fmt", "--quiet"], cwd=extractor_dir) +clippy = subprocess.run([cargo, "clippy", "--fix", "--allow-dirty", "--allow-staged", "--quiet"], + cwd=extractor_dir) +sys.exit(fmt.returncode or clippy.returncode) diff --git a/rust/prefix.dbscheme b/rust/prefix.dbscheme new file mode 100644 index 000000000000..b422464bb902 --- /dev/null +++ b/rust/prefix.dbscheme @@ -0,0 +1,6 @@ +/** + * The source location of the snapshot. + */ +sourceLocationPrefix( + string prefix: string ref +); diff --git a/rust/ql/.generated.list b/rust/ql/.generated.list new file mode 100644 index 000000000000..5c21f4e90510 --- /dev/null +++ b/rust/ql/.generated.list @@ -0,0 +1,223 @@ +lib/codeql/rust/elements/ArrayExpr.qll aa558ac94bb7c45145e4788ed1a92e2873c5f57f1a0c7b7faf341f40027cf455 874da62a3d6467af7ae11045229135f8f5229cff33f3edae5b01a5b9afe86dd7 +lib/codeql/rust/elements/AstNode.qll 2069047c779514867c12d845dcdf889db6f27fa6a9e484966a3c28a77973b7d4 e214616c81418b0018c0d36896ac2ec7273634e3213bc8257d8b172f396c00ee +lib/codeql/rust/elements/AsyncBlockExpr.qll ce6484a28403bc36e261ae6931b02a15db6fc54cc0c1bfc441e33d7284f6c74a e5b3c00f74543a6ceeaef053aaa1f00006026b8242efbeb7e1e9633e68cc4844 +lib/codeql/rust/elements/AsyncBlockExprConstructor.qll 2d7d22caca1984e850d723f9ddd581530734bf4c31c545ea598bc27144a32f1b bf2ff9edff95db8400017b7583d6881581c431755c70e0068a495787993010f9 +lib/codeql/rust/elements/AwaitExpr.qll 310cf2cf155bc472caed76f596d7f789e9fa19c24d73dc0235d601ff9f32de40 d4b53d79a12d4378eebe2211b37b0f819177620b86a3eabfbec4096adfd200c4 +lib/codeql/rust/elements/AwaitExprConstructor.qll af0dfdf36b300d412a7b8668f68e6594fe3338216cdf1aa420c9a58608aa86f5 cfa115902ccf070e34ee451bc2f89295c97e8418501359a8cdc646d16c4cc7cd +lib/codeql/rust/elements/BecomeExpr.qll 91e08545258ff3bed8b63cb0e719f71f04cf21af758688cdb39d4be56d104db7 ba381c94e998c2fa275ab84f1e785cfb6af5ab40ad690e6b429eb72897837ac4 +lib/codeql/rust/elements/BecomeExprConstructor.qll 0c206e657417066415850672a804a69e5fccc605c309bb8755737ae01e332f18 e70bd0c411ffc23c37b22a459455c95ff75a72fa2d179f751bff99866eeef2bc +lib/codeql/rust/elements/BinaryOpExpr.qll d85404c249175283d7ac7daada3951f47b19ef56b08749906c8bd3895959db9f 9e1d35061bab3517c716e3d0fe42654568e16b6577d6d26861b87576839a33be +lib/codeql/rust/elements/BinaryOpExprConstructor.qll efa89c084def020961641772f4829fc54bf718817831d4752b9bf403ce0e61dd d7937326ba08410fc3ba37e44b76530804f492177ef5e62dd416094e1e2f9bd6 +lib/codeql/rust/elements/BindPat.qll f0209f781d8a14ab7fbb4b4d6a654469aecb0ff1a8ff4810f18a90f3b171e1c3 9734b7907855e46eeded6c3f59912a16212f7e8639fba35c740bb04462240287 +lib/codeql/rust/elements/BindPatConstructor.qll 2bbcc296bcdcd945313d83294b90d327c51c9f1e96f92d37dd10bf0c32dfaf6a 612b4fc651f32129155727e866796edee8fff939614c6fd0b7baa1392930a38c +lib/codeql/rust/elements/BlockExpr.qll cd7a978d3ad15156467ee213d65ef0dcc806af43888d1de4635e875b2d76f5fb b0286039d03f2f554ab5c31b902386357e19127d35f70211b1373d591053ed8f +lib/codeql/rust/elements/BlockExprBase.qll 1b24ea5fd43dce0e240e1d7740a062228c19e8c704f6ce26503ddbd65c6f5282 d2e05a51d3840caf4de4cca6cdab9551f396df317c8ad1da661205aa822646cc +lib/codeql/rust/elements/BlockExprConstructor.qll 7fc9214582f0e6e8b4db06f7c6ac3712dc260abc12ff65f3e93bec5f210b0098 13bc676b67ed14b326e4bdaaa43b497ce486dc2c3145a76a25fe960c82a6ba54 +lib/codeql/rust/elements/BoxExpr.qll 02e6f063c8e2aa01b12eb3223783e8d88330f4faadd71fef253b5dd39af8b556 bda6357d99430b524de82be0da444cc180dde9ba1f3e08c1bd4c53143789fcf0 +lib/codeql/rust/elements/BoxExprConstructor.qll e30e71b88978b5d0f156152acaf7eaebe26232b7a5a562cf22f1bb9659ae5deb 3ca41494c5101ef73877737420fbc468483ac7ef215d11b431dac2dd6a08ecc5 +lib/codeql/rust/elements/BoxPat.qll 1df08d5443c63e21d40d25023da58da50bd6cf6e156b9f5dbd6d41a3193faee9 9837752be4d4a1c3f16d6438bd361c596b6b983d9ae4e486083651e8f4e090ff +lib/codeql/rust/elements/BoxPatConstructor.qll 20f79f18beb8b7eeec63b1e30302d9f2e514354a7b1ae077f240db3cda4ecc4c f41ca3fdafc70c6b972598a3af3434bf60687bc2f0252dd11ddd09ec874fe63c +lib/codeql/rust/elements/BreakExpr.qll b760b1f9ba612aa29c917a25d75143e90bbdb607d12ea4a49067ab44595292c1 ee0bf075f2b237c1513cdd03dd35666d4c9158dbf1216a30c5aec05db9e6d317 +lib/codeql/rust/elements/BreakExprConstructor.qll 48b71a034b7b6b0ecda47c72379696c6d4ebb9eadcd6403f9c001945855c5365 fbbccb6d1718393ad6ff3a2bd473dd51691c871db9181cb1e041b318f91d27a7 +lib/codeql/rust/elements/CallExpr.qll 7b76acfa945d7cc04bab4012fc8476f8e4f9970b7051ea02fe5b12ec57927897 57ebf163cd6db203f5dd05d629f68bc4e39666ebc4d1252ba1e09b88ffbe60ef +lib/codeql/rust/elements/CallExprConstructor.qll 9a7e9e780ff6604ddf0b9e5f27bfa43b720bb341673c7740148561c666ccd066 945804ba7c1dbfb9f221810be9d2fc3dbee3ce89dd9d08b3f3e719d31701ed98 +lib/codeql/rust/elements/CastExpr.qll cdd74a040d6b1aa44f6e2bdb2991e642f013848f32a17588291317a7abf38961 06f3228ac826fc452d75505345707b912426f05db78380a72f0ba586fa00c282 +lib/codeql/rust/elements/CastExprConstructor.qll cab6e9a9872006cc811620bda522fafde23fc4edb5151af06a5a0938747dbdfb 6d972faff70166c4b07392a0bc90c6d72c9466b58b55e7651ef6c3d06cf72873 +lib/codeql/rust/elements/ClosureExpr.qll 2a8b0a94e37b8406acee038ae0737604174b3062f3c12ecea27a3104ded3b2bb 904eed60004ad20c0d03965f91e1d2227cccf3b13ce29341c79d545aabe492f0 +lib/codeql/rust/elements/ClosureExprConstructor.qll 238dceb78082a5566276640d4aa31484041700852c0751130d139a69ac8bde46 7aae22930def4d438d742255731cc59b78a95b73a0b1d6334ae9965e083e03bc +lib/codeql/rust/elements/ConstBlockPat.qll af7f5f1a8de38266a12e92dee4a5ef5279baccf542cf2c52d982ed075d3bec27 1208223d97230a90d9377164b61454dcc6ca0f46a408e4a5ab2a82340bc92eb3 +lib/codeql/rust/elements/ConstBlockPatConstructor.qll 04aa8b4f218ce87157f0d6b10c9c04660c34c90af1f121b1432402de2e5114cd 34e2fecbe91ea9ac1626bc27121a7d5abe99855e3f49bdca12a1969b42ac0ba5 +lib/codeql/rust/elements/ConstExpr.qll df129a4a1f65c07076e15097571ffd12b91a63d3ded97bb3173b50a7f1279bb4 dd3b7a5230baf5d1a062d49324eeb6ee5a76f156944ec149da8bf46c982107b8 +lib/codeql/rust/elements/ConstExprConstructor.qll b4c96adc2878047c36d7ceaba2346ef66a2269b5260a56c3d7ff6e3a332bad75 ce15bbfd1448e47d3039e912363efa607cc2c29d44b8248ac91c307af7b57016 +lib/codeql/rust/elements/ContinueExpr.qll 46635ab257d8cc8ab3ba4b6786df7a2ff4d2e6360578bebde8bec1d6ae90b8c7 a0c60fb018ced67e1d6eed1c493b2c6d729636f1325b556ed5bcbcff072cd8d7 +lib/codeql/rust/elements/ContinueExprConstructor.qll adc5c5b4fda5dc5102cdace41c32a6c94fe07a2e2555ced6ee62a2d2551b90a2 9dc5045b0d91a3a28cc1c0d59c6fd40620257a6c18ea8480792183c4d802fd8a +lib/codeql/rust/elements/DbFile.qll 056d363e1ba5ec08cacb2e90b8a7a3b47f52ded5dc2289edd4e85921fc50f37e 18e6926f77265a3a6319ca2f3bf3d529d17d46cebdd2ef6753357fdc53c22c70 +lib/codeql/rust/elements/DbFileConstructor.qll ea93dc49b23b1c6d800ab9d0b9cacfa9dc661bfdb04b9e6efcad2bdb050fb0ab f7a891b1786604eee57a784733555b677e2580770d51d18073b59e7ca65df1d4 +lib/codeql/rust/elements/DbLocation.qll 1f694594e8e4ab65a8781cd443ad4f864447ca88e2cb65504aee5a779393c84d 003ec72275406eb8f5ddd6ccc2b258fb7c906d4bb2c0ef1ba235f291624321ca +lib/codeql/rust/elements/DbLocationConstructor.qll 8848abace985818a5d3a6eddfc4cb200795970146d282b037b4f22ae6230b894 44dba880e17bb1072fa12451ccaae4830fd04dcc61f7403d35510309fde6906e +lib/codeql/rust/elements/Declaration.qll d4ec5c83728f1837243caf2f27d06fd05ecdd2ca440112accff99bfd37b45e5f c1cd9b297be8b69207e75d24b29949b9f71c78406ee0ffd38d0b0810288d6140 +lib/codeql/rust/elements/ElementListExpr.qll ec535846c4f449a3e58bb3b8dc583960ef3b42a10836ad13a6c3091f625ab463 3797f92086ecab90406b7493953d78af27b0b5c68199e2f37abc15f3d1cf88ed +lib/codeql/rust/elements/ElementListExprConstructor.qll 12b06597e0700cd0eac70e42cbdc1a2d410e0ffcd05c21a213812a488b5b236b 7adb2e442f1bc362c44824aaba0ab4a7fb4a4bc550a3c96f963dc03bed582d39 +lib/codeql/rust/elements/Expr.qll a0c2cb3ff9628e5dd1a7900d2413390faa433dcef114bdc85279a3a2bf2fc4d8 a0e8e5693ead91b62da5531e070e11a2105ee49046cb69e63b8747eeafc27651 +lib/codeql/rust/elements/ExprStmt.qll afe41d6d05ed9d94b3c8529dad743bdf3e2a0e68bed84a80da4dd6df0257451d c1f0c7c1a3c62baffb7d3bb69cc4bc828e6fbbbabe8f87342ec67d8744fcbe7e +lib/codeql/rust/elements/ExprStmtConstructor.qll 28e37020abdfce5a8666b0c9a3147c339c7a90d9de527f97fc7d36df2bb921ba 5333db932a2edb791ec3c8f2c215f4c74e825a362f45ee901949d81e328bc7fd +lib/codeql/rust/elements/FieldExpr.qll 1e3d84c3eeeeefa1837b5359f7289c0f03122848b6f95fdb362cfd947304e107 28a6f8201b435b87705afcb8088d017fa699f60be3aefe03dd56f978ac7954d7 +lib/codeql/rust/elements/FieldExprConstructor.qll 75bd0526fae157460750f3ea1e087c857cc703fca03d34f1f478b57ee8051590 1e5555910c643235e34b73f9844e894e51f357c3f7aba8165c47caa147336c53 +lib/codeql/rust/elements/FunctionConstructor.qll a9269b37182c0bf432f9b2b015691da5dbd64819b9bd25445af229d873014a91 69107a7503af14a51e091e6918094a4e9fc316a72de2e1514f001872ce0f2c0c +lib/codeql/rust/elements/IfExpr.qll d5461ea0370765b9dd0c5aae298e53c9b3d84bacc783991fb9dceee44c87e8fb 90c5f959144c767bc8f10b322489264b076c33f19af0d19e97a08d083f76913b +lib/codeql/rust/elements/IfExprConstructor.qll 961ac42fe811db7c56c9d85e98724a87571e8543265c0424a7b61f26ef41b369 43d9412a22908a7e5c38f1f5e8f88162367407b71037f469dfb7d8dfdc3a063f +lib/codeql/rust/elements/IndexExpr.qll 0729277577ffe82d6dbc8fd275a70de59a3926aafea730e622ecbbca7b84e313 c9bc5616664e072fbaef2b89d4047f5f7e28d002cca2fa17333f29db80adb284 +lib/codeql/rust/elements/IndexExprConstructor.qll 37e70c773123d775b6281514a2727e133e02fa87e774076f857a676697a1f2ba da2ed2819a13ab7c526b74c1c375ab2fce63ed17f61d5b29e4212343d6b77d06 +lib/codeql/rust/elements/InlineAsmExpr.qll 5883542b068a11c22917bd46e44eda2f5e4a9de67f5346acfaa2334f73ee63ad 9a8823c91daff1337aa60cbd6bf3b6e96ad1e8603dfe79dcf404636de2693a5f +lib/codeql/rust/elements/InlineAsmExprConstructor.qll 5a3eb5162805366dcc2aea00714c1a0880c31b614b73b69f1638ff4f088cdb11 89c54b68b0246fe5d86f119c1892149746d7fe22d6ef8b625c9ab64398d19d26 +lib/codeql/rust/elements/ItemStmt.qll 70fc3f9df9794dc78199dfd81b8136701d4ca0c9b3c6e88ecec42f75fbc41f32 df122241e3868b1c376e2d2501328ad47020a0837826f165c7e54640bc018156 +lib/codeql/rust/elements/ItemStmtConstructor.qll cd27051f73ab2897b1f7a725313f97d36507fc9f5e0dd7b2ad8bd1caaf8c42ad 67596c97386fbe6cb9e5e6abc45b674158f411d927297345cb25359587380bcd +lib/codeql/rust/elements/Label.qll f48209b24876d581e95120bc548c44033b6552a7875eea73ce44aa57b675eeb3 d17163f3adc9f94a462269f565153aa2822533d03487e521d9c5d5e72afaa1ac +lib/codeql/rust/elements/LabelConstructor.qll 0625a149cb34b9f603b76efd76e679bb63808d47f9fa529959784347d8e7d447 2115bc7de878af444777f96247bc0a775161f3766e38c3c4d363c2f59b2144da +lib/codeql/rust/elements/LetExpr.qll 986598132db0cbc861adc641e633a54b7651ff5f3bc52b5e2f4e84733b774fb5 e61ed80a6732fb344498c8eedf3b787546eaa38f203265e9a3195e93d3534a19 +lib/codeql/rust/elements/LetExprConstructor.qll 8904b25d70fd0e6f3db74d2e09bb3e3fee407282ee45030fdaeac31b6111db70 36dcc877f6c1810228d593d914cffa7b04ecf0afe13c4c122aca72f33d03f566 +lib/codeql/rust/elements/LetStmt.qll f9e28ca0123e2a6e1f6115821282440397cf2647577b4bfc4d00cbb4312d8eea c65442707090461035160ce830c4c0a85d1fe626f03026c13ebc4be06ec96905 +lib/codeql/rust/elements/LetStmtConstructor.qll 5882f0e4379d07e8281a955c9eed7dd907b610750887de3dd6451cd1c8d104d4 68b0890d8a493dcca74190904b00f05b0e58aacfe5a2aa63e5ead1ba366d3c38 +lib/codeql/rust/elements/LitPat.qll 539b414883b0b86ff446fa81254f2c71f467e5ea0bda21dc3bd66cf3abf95b13 d54eeb618cfb8f0c4a48ce5ab1922fca2622f4a0c703760aa344028172f37642 +lib/codeql/rust/elements/LitPatConstructor.qll 1a1c5f711b04bfc9b8b9a197564cc8acfeeaff1a9c8b30d57657747d84138fce 19cfa7386fd1f4ad8ba1ffe8b14bc547b9884dc98e731b6935afd11ceac6b5fe +lib/codeql/rust/elements/LiteralExpr.qll c5abad970feff4cb2719cc4774aedcfbc494a68fe15e13c36eeb2516d26a88cb fdb399d9a6162be54c3cbdd83654b9736faee9b15aa111f1bbd6f333d332c87a +lib/codeql/rust/elements/LiteralExprConstructor.qll 1a6aa25d6700ab9c85bd7b721e4818064a3a092386589ecdc2018b8b8c2464dc 6d6b50e2dabfa671110454d64f0903336563ee4be1dc6751071a801ac2fcb8e8 +lib/codeql/rust/elements/LoopExpr.qll 6596e1d8ef1e9479785871321021930244dfb7736111801aeacd08446f4d2238 5895e4a5d4187fcd852528f0cea99fa378d60d279c7896b221eca8e65109fb96 +lib/codeql/rust/elements/LoopExprConstructor.qll 635348fe22fb47c7e59bed02a8ed6420be5a9ce92a7d9bf4475465ee170c917b 2bcfe70247c55659b3a3e09562da52fc645cc3166748f268c5a38b35fca24233 +lib/codeql/rust/elements/MatchArm.qll f91def96700dd8521c11aef100f494d2d44777186e771b306ec9579b01c882af 021b298096cd88d3de81c2c012102e5b5ce5159d6dbca2bbd32b266593df335d +lib/codeql/rust/elements/MatchArmConstructor.qll 49d134823a445a1ee995ebf5637fd0d736b9ab7f2b141026712f231ec4ed3389 f16e8adc8375e6a7334589d5732dcbe10f5ada9de7a12c549c55be3f028ec628 +lib/codeql/rust/elements/MatchExpr.qll 87eea89af08e7b9e4dc958aae0d35035fa8cee5fa7108f59cd0d3050dc70eb29 ceb061ce32c20c9aa12e6376474ea1ce1b8bb9c9b0e58b67abeb4bb666a18676 +lib/codeql/rust/elements/MatchExprConstructor.qll 74df937d7d8bfbfb02bdbf095595eb3f2129ed4c0854bae6d73b5b38d4fc902d 5c388c02f02462d843945111b72de12bce33c7c332d55993d903aeb250213407 +lib/codeql/rust/elements/MethodCallExpr.qll 2dd115a2e5ac298d9a81cab2718b7abdbe52825938ea88115913c82a0f2f7751 9733c353b9e6703ef812eb8b6395db49d6d656460c575dbd75d67fa96784a33c +lib/codeql/rust/elements/MethodCallExprConstructor.qll c9e1137ba6b76eabd941ecaa27a5b43b6fc3ff445ad46d3f625ad086de0e0af6 47bc4c30182b891c7009ba536edad7393dc068b72d9dfc16b26174b15d49748e +lib/codeql/rust/elements/MissingExpr.qll 2158f064d027975e3faba6a858b8e469c324544ae0923319b149fd5ec6548448 500ef109ceb36f5da72040fc733c7e98f94920f51d53d90fff3d86f85da0aad3 +lib/codeql/rust/elements/MissingExprConstructor.qll c51f4f6e897ef2107a27bd91ecf31ce875611b29a5a12238d5312b9489a35b8d b9ea3fdae459aba6c7ed9eb48edbc5bdbdb4cb41220fff81ed4cd256648612e0 +lib/codeql/rust/elements/MissingPat.qll eacee2eaede4adb8452a41c14c95c310d0731c2c60fdb818b3e94e34f418aed4 9f81567e8e9c02be0994764a082a2135a6bec952456c2413295f2b0a16e5eb5d +lib/codeql/rust/elements/MissingPatConstructor.qll 7bff2fb7fe96388dd703cca5f0bb1d04cea5d1f0729bb54c6604b58e338c7d6b eec9fea46593b3850da111658848cb54cfa9992286eeee313a55def184cf7ec5 +lib/codeql/rust/elements/Module.qll d8995b361cc672f86a314bd53bd3e4d1ddb26b6afde62eb7c380923810785af0 3c10180c812d89a8116ac6e32cbd4d7ac2f549c8a76d327ed75c764b09251d52 +lib/codeql/rust/elements/ModuleConstructor.qll 109ed8c1b5c61cc1d3e8613aa8bb8c168dc1943c93b5b622fa79665751b78318 601526c7f56578883d261d14653fdad08329f80fea71de14a5ac5ce671a8d436 +lib/codeql/rust/elements/OffsetOfExpr.qll 1076421d48a639191b52ca36701e760ea20a6ed1c8ff8f0cf1607f557b9f9a58 9cadc919b51ef5b223ce2c827005acf879309c9cdb971e8479477f0646e7c70b +lib/codeql/rust/elements/OffsetOfExprConstructor.qll 8034eb1d3510dffe9e38cdfcb57a0235ee01bb50e1fbaa6e5601e0e232c1977d 6e3b7c20a17fe4c45d503ba32264aea8f6dfdc69ccd95905a5bfb1e8b0cc91d0 +lib/codeql/rust/elements/OrPat.qll 9b5cf68d55c57c262a5d630852ff2e842f0caa3aca2a0b4491d601340917db63 c965eb43675b135f3ce11c1e8762af0b764c6d4c262f002f8b9a512ae59e8a03 +lib/codeql/rust/elements/OrPatConstructor.qll 9a24cc095adc55ae8ea66f68c695f42de0181a43e23d70e210c63351b47e2586 1f773ae88276289672d93708f4ae9f8c95199e7370a0c610a52c92b5e018e632 +lib/codeql/rust/elements/Pat.qll 197aa86d5f317669e38230a20460b271c1d82e830b84150dac65afb67059fa2a ed3e8c74e42ffd5df14dd88711d79660982170a42f9a605704a274298dbbfc41 +lib/codeql/rust/elements/PathExpr.qll 15d12b039c117e78fde972b098e22ce247e5a6df4f52685173241d76f6c18368 8e8222767d49c022b6a69ae8902e86a5be9ac3803301c6c9b409f265546da520 +lib/codeql/rust/elements/PathExprConstructor.qll 9db3d3ad160d897b65b8b8a62f3243f7ff80d8e2d27875b3cd2c2b046fb0f9b6 26c2ba19a04fba61af8aa0cd72602f7b02bf0e1b693ac9cd14c7ff6066412f75 +lib/codeql/rust/elements/PathPat.qll a49036bca0f3f023917fec3547876759987a34747e16b9a15ebb99c82ca9234c b4f77e6e29300f02cb845ab79d4a64edb654a398fe3d6c1a2306423e1c0a237b +lib/codeql/rust/elements/PathPatConstructor.qll 476a38723c63bbfa2565946725c90f1224ac2c5283fde79bf14dcefce6f500ca e9e9b000cac44851772bd9ca519edc89e8518e89a0930df21af14a69f5b0e864 +lib/codeql/rust/elements/RangeExpr.qll 05a56b149adf83006243335be90c23eca71e981aea33c2d81dc8ad5cdef757bd 602bc5ec0ab5e7eaf9f1debbb80d2861d53b6de5d10011b50fa71208a6491cd2 +lib/codeql/rust/elements/RangeExprConstructor.qll a04153bf88dd71c3f516418bdb7377ded9db21c07f7ee6dd245ed8b44719d8f3 2d578f8dbc49da98694676d6a59bb9d58c6d2a200ffc893ffa90dca77878e38a +lib/codeql/rust/elements/RangePat.qll 02f3e4647932553481c4d8b1e2d2da3551662a17d75f26f2fb7e9d77ef1d579d e2546bc74035d03c92aa7beab2abca73a587049c95710eb9b59f916363df1552 +lib/codeql/rust/elements/RangePatConstructor.qll c391431118ed6ce16f7b7126c5d43e61f07b98fab7b8bc48e9dfe22f7e21ed19 bbafe1c9595b0b004f7b27999a14df27d0710d5b058e7ab14dddd2fae058fc31 +lib/codeql/rust/elements/RecordFieldPat.qll e3f69b2c59d50807393928ef9be0b51af016f209cbae68cfde0fdf02b287f353 b24e256f850d1f0bbacea74c4879fee8bcedf47f65db091d7858302355751fa3 +lib/codeql/rust/elements/RecordFieldPatConstructor.qll 36859753aa70086c540a1700495fe6c414521553877bfdd56800f586eb577743 1b31233a5e6da0bf88aaf40c52fa08cfbca5b44088cd3f91957ce8c96f4aeaea +lib/codeql/rust/elements/RecordLitExpr.qll f5c0377f0a1805d824052acbcaad393ba10b0f994a5ea6b6f60b5eec2c417c21 e61bb3750d19dad5c4e59dd0bb3a65430879f58909b735f7c28f378cd2217221 +lib/codeql/rust/elements/RecordLitExprConstructor.qll 7b676a8e0fd9ba5a932988e613fe3dda8b6b0430feed8791ef5585fd9cd81767 f7811928dd8269138d75f0a6dd1c60f70d18806227bd2caaa5cd4cc1341e9286 +lib/codeql/rust/elements/RecordLitField.qll 27bbc256f61f4428578155da47b1a1b3eef43fb5d4d98f168c66fa85337bde24 880aa885f2ba3d1866c6023360a206dc5095385adb908e953ce792beae90b2ca +lib/codeql/rust/elements/RecordLitFieldConstructor.qll 0f83c9dc00937d90ee0d64d157458145078f5f3c87c9c0484600fdcc830ab207 e2852d5bc4f0174d94b90a2ee34fae1e6c4b24d5d8ccb58a51c520b12adf8512 +lib/codeql/rust/elements/RecordPat.qll 50f4a2401dc579f3900188043d412ccdd6c57c1da6636c105221cfe243307d32 7812f0e10ce1a8e70c8c45d0c87e52539f6b29469157463456d06c566e86c2dd +lib/codeql/rust/elements/RecordPatConstructor.qll 93c794efa5050b86c458470224de7f3206c1a004b46ef374780f080a8e9a4ce0 157800f342de96095e118dbcfa20f8e65cc79ccae712e8e37bff1ba92a227fda +lib/codeql/rust/elements/RefExpr.qll ed47e1a834f2af93197ceda685a368465f7eea59704c2b7df3ef59326e53c0e1 5676825b036eb4cb560238d86c8d1fac48a4e59d91110da0dc75eacd542bcc8e +lib/codeql/rust/elements/RefExprConstructor.qll 4a2b9dd4ec2638a5ccfca268ba377980aab3179b27177e34e44e0e9dc6653b36 752f6f298369b8c0f59d49ca9e729c20aceb3559df68be416c7bbf65f578489d +lib/codeql/rust/elements/RefPat.qll 00b2c32e09a02b336d516b7812aa7ffe6202bd1dcdf4ec2060a74ee7a4b1c5c3 90a4b3da60aec10b5d56f6364d0a022c1d7db5fe8cbb65a78f55651d23f9abe7 +lib/codeql/rust/elements/RefPatConstructor.qll 98497e0ef76bec0390a23aede2fc6f80050ad2d00bb60f1d473362111a53d4dd e4fde4e3e88c33daee90ab6d90ef2e38b36faedcfe1b6d6304f4eed92980b5b1 +lib/codeql/rust/elements/RepeatExpr.qll 24ae3d83a83fc40bcdc6ba5c397a31da388c9137308cecce7da6fc8ac622031a c8114ad0ca7197aa791ae76d1d42b53ebd6f6b98378a779c59727d4e4ec5dbf6 +lib/codeql/rust/elements/RepeatExprConstructor.qll 7e141ed538f1dd5debd83de045eadc74ef032acc8a64ee2e8ac760da60ede525 d20206b72b14d03f8a41571948210619ad7d7dc438ba04ae45d929776a11915d +lib/codeql/rust/elements/ReturnExpr.qll b36dc07c367af16c5df6276b10e36d85dbaa500092c555679463f8db817bf6a4 4f95cc9d88bbb8403e35b270897a1ee9ddb4c8bef393b06d7a014d914ca5fdec +lib/codeql/rust/elements/ReturnExprConstructor.qll 825501a55f7b5556ded49fc3c43d45b7d8325e3a1790a2af738a46df33b569a7 ef06e95f1919952e537027861660a4d7c79b832fdbe802bfa5bdc29ba0192f31 +lib/codeql/rust/elements/SlicePat.qll 3e88657bd488dcb1ce2fa6f4bf72a9f76c7bfbf64b695070efa0ad89a6af407b ad60e3d0eee368c21c46acb439b599d8867c82193c7279777fea10f3205bd272 +lib/codeql/rust/elements/SlicePatConstructor.qll b2885e663932f68ffecf87b4532f533e9177beddd715765474f454a9804afc8b ade153522a4773eb769f4f4d96fa07add34089f131b41a74534b28fbfd2bbb60 +lib/codeql/rust/elements/Stmt.qll bbe8414d75bdcfda90f47b853a04fc618f4d0b6d6cd3b662bb15d3a9e5cc7bda 714c6f8eba9882363bf1594f48c75d1a885f6e93adadbdecbbd8169ce08f7b98 +lib/codeql/rust/elements/TupleExpr.qll efcdda11afbbeeb237a9b7f84a5a59ca3a98b541bc660b58a41f1b1cdea56efb f416c57e7190e91bb36d4235ae017cdfa8e68f69b38c55c6e7a71eaff35e5bd3 +lib/codeql/rust/elements/TupleExprConstructor.qll e7cfe2da7457339e99263030e74715e5ca44828d74ea3f462b90a7e72c1e9302 b45006d9cc7664a5a659e7c74f415142e2397dc33fb1875ac3a6cf5ca39e709e +lib/codeql/rust/elements/TuplePat.qll 17bad5b6a0be8e9b61addbd9a17bb387709147e8d2fb8a93ca9255a8a11bb822 7e84df64d0baf1b5329d47f4977fa5e8471fc323b2eeca8e942df93a48e04cbf +lib/codeql/rust/elements/TuplePatConstructor.qll 505c4f440b47da576acd7e3fc69d6b49e8287f981a21e79919ded374200f2578 b295526303bcae982ddd8c6b544288c0b8b8d62984d6986319e7f17baeb7a19b +lib/codeql/rust/elements/TupleStructPat.qll 50b7d89498dbe6737d97325037156c7689fd8d7e776d66fef9551f173fa3f2d6 f42edcf42be877424ecf2f11c90166a90f485249b24d73ed302294299d6a9bcd +lib/codeql/rust/elements/TupleStructPatConstructor.qll 15a15362572ac2dc98ed3257f195f20bb8dfe34a1fe203cf2a1a193ce16c406f 9e590b50cf865f6bc573b6fc17acea073f0d9389be241b01e820d9f3f8f14acb +lib/codeql/rust/elements/TypeRef.qll 223844544eab3e07b6edda805c6344fa8b486aeea7bbe62e4b98e235ce2008d8 7517748b0e7a57c925168f5ce7a31ecc1b59f7521a2095578f599b8d9045a4e5 +lib/codeql/rust/elements/TypeRefConstructor.qll f8b2e5ef15517890a8b2d56643f471ae64cc74c420187049e33b182417e72e4f 683611e732b842756e301a77625b385bca0c4969971020c9e11220a1aa665a29 +lib/codeql/rust/elements/UnaryOpExpr.qll 32e637510c03653cc28cb9a25a2873e9bf346aeb63ad2d7a571bfcbda45c59ce 044b22dd35491f9eafc6488fff5bc929aed12e2f36ac55883925c876978bf7cf +lib/codeql/rust/elements/UnaryOpExprConstructor.qll 43db7afbd3535b7edc801d99d772233a734f4ed31eeee2ca74e7ab26cae33e87 7345f8d4cb958ee2fa83d3634285f12829bdd1cbac2697236d6fae062313ab6d +lib/codeql/rust/elements/UnderscoreExpr.qll cd49049149e268524412a17394daaef696ddca63f1f452b369172b9643e94d82 228568c12efc7c055f2ff7cc08c2d0ae150f6356f77ccea98b7f8be3d6bb4806 +lib/codeql/rust/elements/UnderscoreExprConstructor.qll ea9f93fa6529ec4e5bf5c4a98959b2e013e83fce4a74ebfc476b10bce2b331b2 bc36b62fd4fec6fb388d82e2af2aafe0099138d54b7672be81e84fc511fdcc8f +lib/codeql/rust/elements/Unimplemented.qll 60387a9def0ea3cb9534311ace088106800af0acb89883c5bc9b26d8d8d61718 9d869f83e73915bbeb5af27ea30b69f20c344cd7d7f253cb7dab74de20baa0a6 +lib/codeql/rust/elements/UnimplementedConstructor.qll ee024d4944aebe619ee3ea0ce4f84da0f4fca706baed250c8a65464a8d77979a f95966e3a63cbf2b466241f55bb47c23125645fad206ebd758236465afa4f97d +lib/codeql/rust/elements/UnsafeBlockExpr.qll d708ee1e3e238fc0bc51b045d8364a1f0fd174570c1e6416242f79655d1c1e38 8f67954791bbe9e127ddd4ada533ba97f5cfac9894a979410366b6747fdd4519 +lib/codeql/rust/elements/UnsafeBlockExprConstructor.qll a089d89cb8f9542b3ee94c8eb7ca9ce0ced08c954802b26826f6aff12f8705dd d3919a40e13d97c48b19df647851f120b667300864d3a2178b1b01236c2dcbd4 +lib/codeql/rust/elements/WildPat.qll 9791bcd2b36516da82a81c10655fe6b4ef0f788d548cc99cb88578dd9c1278f0 03c192da4f92db637001854f904f5f0ea7406b74c02c1ce26cd375d9cfb26108 +lib/codeql/rust/elements/WildPatConstructor.qll 538cde83119510e0b3fc9728127cbf980d17f7f4a9371b4572de26329ab08341 66b96aee3862d5c314a2fbcc6930258f755189c4359394b432e8edb13a9d0eaf +lib/codeql/rust/elements/YeetExpr.qll 04a1f4f7b2bb697e30ab284720ed30c0c8e1377cacf787383518da1e882f3bd6 277a751f38830e92deb0abcde9cbd124bffc84b7d5a1bacb4f1844c6ebceb2ba +lib/codeql/rust/elements/YeetExprConstructor.qll f1871c6e0c966c52806e370dbe2956585bbfa1dcf0bd7ebfdb2bd39b7cfd0d7b a2333e80a325a921a66c34151401da12c250951952ccb0c81e5102dc62299503 +lib/codeql/rust/elements/YieldExpr.qll b0f238ba2e4b83b449b44224d766b6cf6b15523a413467f608f4a711d34edc01 355fcafe43915d69a07725ec3707e66abfefc6157bd7dc1c1fd846a965c6580d +lib/codeql/rust/elements/YieldExprConstructor.qll ff46ba17cc24abfcb0e310c7458d0539b704e7a771ad00853bd3a1844e4e6f82 1c13662ef01c88f1cf057d099eb46524036133e51a0e36ddf947f727ac6046bb +lib/codeql/rust/elements.qll c0e6bff934b1925ec03e55afc2b5b9127f51dc4a613e047e687bc83cdab4f196 c0e6bff934b1925ec03e55afc2b5b9127f51dc4a613e047e687bc83cdab4f196 +lib/codeql/rust/generated/ArrayExpr.qll b9778720acf4080c065897ba1471be185c0c35f3ea01c15594c0a3ee4029b231 cbc8c9dbcb805063c4b893e21ed0bf00312490a0c92ee126d49dbfff6978fa99 +lib/codeql/rust/generated/AstNode.qll 0598fac7859906f4103124270dfb2fbdb838387b1c45000bf50a4b62c797ec41 f47c84878c7c9676109e358073bddab92a1dbeb4d977d236ecc1eae44d81c894 +lib/codeql/rust/generated/AsyncBlockExpr.qll 1e9d3bcd5d5703bf61748f2746d3f9a4e2a12080268b29a2685b762d13c30555 1e9d3bcd5d5703bf61748f2746d3f9a4e2a12080268b29a2685b762d13c30555 +lib/codeql/rust/generated/AwaitExpr.qll 4b5fccfee29fe28dc85df19b4e6677bf565dacba92a0984bb7ca444650852970 0c0be7ea53e41c7708aa84b93d037fa9df2f72e5a676d78e217ca006f21b548f +lib/codeql/rust/generated/BecomeExpr.qll a4cde707b7372dd4c48f9b4a450b6ea710085f323878fc17c58f92cf7d50fef9 44f0fa714080eaf6dfe9fecc422b1aa161375b73eb5536ef8bb40b793d8f48ab +lib/codeql/rust/generated/BinaryOpExpr.qll fe0a286df10f5eaaaba60c74dfc5ef2c17736f24aadb718271e8a17eae736ba1 1f13e04bd6089b956db807e5e0ab974382ef7b5a7271f290a7ae5f75a857a30c +lib/codeql/rust/generated/BindPat.qll 15d3a33c5f56f7659a331f72735f00930fddd6066659e54c5c19d5e7eb8ef078 bc0a916622b2c426b71760caf15b8e005eed276e06e04d04cc5f19f4c31c34f6 +lib/codeql/rust/generated/BlockExpr.qll baf05a376d4c65505d3aa52eb893e1d8d02a8ef8b16bb40d4a59ee10c7d97b5f 789eccc236d0b4d3adf3dcde699a5f3097d333514455776f74b9184aa14fddb0 +lib/codeql/rust/generated/BlockExprBase.qll f651ce968170b6e05e555924f8004d55b85ff0ae59bce4fea0804691cef0cf66 6ece8056e83d047fc27cdf1110fac166c0d1ba0e26a8d4a7a7cffc05bd6b3b42 +lib/codeql/rust/generated/BoxExpr.qll 880f550a9a6c861efc6310a72830a50bbfdb11982e99f11b5d3f4c6d1fbe826d 380f021014738c86e5745b3320e65a8147ceb30511aa51526a7fab4278a1ecdc +lib/codeql/rust/generated/BoxPat.qll b69ba2bc341a1bf4c613279e45fb97a530619d4148d5ccc4f05436a316db29eb bf52730243bd1836d5890c745232aba50544c2046d00e80e7d22eebcd104f821 +lib/codeql/rust/generated/BreakExpr.qll d68990513e0b2c0021cccebcdc7dc9ecc1d5b5c7dd0df7014686d6ed8a909940 36875ae186581f10485c1c846c9f6d2bffea3b18375b7f05c2927ba23f08b6ef +lib/codeql/rust/generated/CallExpr.qll 3e29dc45480e3be1989c364bad0ff94deb322cff20e87a3378fc1a7e11237d61 3873462b8811c3e3ef92700045ed05f55869d320ac74eb72111776d3353095f2 +lib/codeql/rust/generated/CastExpr.qll 6ed07afb453706874d7ae7c4bb09ed35ffdd11e7aeb4cbef4d84dad11a203d0f 741d1c0ff092dc9273b0d588aea6b30f7e2c1c5b9d08f2c4722fe26c2cab33ab +lib/codeql/rust/generated/ClosureExpr.qll f0c7ce7aecc9da9663cbda3e285be73b23464f8baa6b966fb5aebb0bd0f0aca6 685d74b6a94052fc45aff83b7c525a83f9dfcc02c1bf7e7f7a0aed51ce2de945 +lib/codeql/rust/generated/ConstBlockPat.qll d0818fe4cee066f1e6d3439c82122942ae62941e69da686b7d5c399e820c395c 2fae5a2f0457bb7106d52ac7457afb597d7ac9658b8dcff8e76294f5fe34019a +lib/codeql/rust/generated/ConstExpr.qll dd851fb049429fe965569beb75957a6a596137b333a6cd7cd588d1c4d40412c4 824825bc46a393827d5df5ae30f622ef2a053ea1f5e338c3b957625a8542cfa5 +lib/codeql/rust/generated/ContinueExpr.qll 436847767d2f68f95d011df0eb8a175924c029ac747daf620a203596479b20b3 e362f28dde0bf3e6ff3b234e81a44bc5026b4c9ed38b8b7872954cca9565eece +lib/codeql/rust/generated/DbFile.qll 4dbf1931124291e0d6a958ae882f8aeef006642f72adc7ff86cffd3a4e9a970a 4dbf1931124291e0d6a958ae882f8aeef006642f72adc7ff86cffd3a4e9a970a +lib/codeql/rust/generated/DbLocation.qll 735d9351b5eb46a3231b528600dddec3a4122c18c210d4d632a8d4ceaf7f02e9 735d9351b5eb46a3231b528600dddec3a4122c18c210d4d632a8d4ceaf7f02e9 +lib/codeql/rust/generated/Declaration.qll bbf5ba3792797a829b0032c41fa99d22c26e4277d655099912cdbafb80f0c8cd c4666a71099b21ad5cd83ef6f991ba18f9bef03b3ffbcedfa10aec081d6501d5 +lib/codeql/rust/generated/Element.qll 21567fa7348dccdf69dd34e73cb6de7cc9c7e0f3f7bb419a1abd787f7dc851a1 21567fa7348dccdf69dd34e73cb6de7cc9c7e0f3f7bb419a1abd787f7dc851a1 +lib/codeql/rust/generated/ElementListExpr.qll 3f7e9c1f7249f7283406d2e59b00af750b6dea93b284d7f25af66fe4b3345fea d340242d6072e274fbafd6ff2a5455bf53b3b77ed91539e91563d67cf2ed48f0 +lib/codeql/rust/generated/Expr.qll 32cdd43d17e8b2fb7c73ec723eba89704d1e853e29d304db5eea3979fcdd2e0b 0b8382b0659afa1bd1d13d0cd492d7fbdc0fd7a5162fa658ca2973bc15ee6534 +lib/codeql/rust/generated/ExprStmt.qll f35543fe1481f768eb8abe3fd0d36e2dedf00f0d1adbc31562e6280ef291d0b6 0663097b4b539c5f35dab9b26ab55baee879c7ef543810581347a8951aee46d9 +lib/codeql/rust/generated/FieldExpr.qll 25dd7f15ee3fe1b0de4371cab9df83d3713c1612501e5496c9a15df8d093a755 3c75b0136d1849f6de1bbd14bda4285c52d51c8a6427984c7e5302c05d706e99 +lib/codeql/rust/generated/File.qll 2eff5c882d044d2e360fe6382fb55e5a45f6ccb9df323cfa1fae41eae9d2a47f 87e7a906b3a1b4de056952e288ddd7f69fa7cb1bd9dc7dd3972868a9002ac1e4 +lib/codeql/rust/generated/Function.qll 84a00eb88479efdfe70fe51c3b5cb27ae64a54b48dcca1f2e02f68691b7d907a cde5b965ab27e811f0d24eb4f12bca90c3e8aec3a4c1d9b8bd0023745dfab105 +lib/codeql/rust/generated/IfExpr.qll 7d8e5bd93bb8eda6d5d6551431b0389a2ec5893bd8c13276205d6677856c8341 935bf1be8f790a52e71a6a28456f2f1a5c5cbe6e64bf20fa8602980560899835 +lib/codeql/rust/generated/IndexExpr.qll d44004268aa2e7d79e29133eb593d748beef1d4612318ef469220b3c2252a057 86892c04c59936d33f0cfd5272a04a6ef726f477c2e8f4ef27dae7240af9c804 +lib/codeql/rust/generated/InlineAsmExpr.qll 246c4f255d963f20c8e71fdbd16b4555cb6243820da1d399543205010368ccaa 1ebe22203305195259963bfb90f9928a4255cae993067f6a6fcfbc62069e1b1a +lib/codeql/rust/generated/ItemStmt.qll b4d2a06fdd00ea90eed2742bacf0a5781b8ad69e24df794ec075d7305220afaa b4d2a06fdd00ea90eed2742bacf0a5781b8ad69e24df794ec075d7305220afaa +lib/codeql/rust/generated/Label.qll 7de504ea71f2847e305ab5ea3b30403cb0aafbaa0eb4cff3956a2931da6c024b 61e3c6a74b573aadcccefe0d4abe5d8e2542b1e5116c95f4e595b36efa3a86dc +lib/codeql/rust/generated/LetExpr.qll 896efc732db1ddc8be7281408dfeaf6f04f29d25ee1240738246e0cb31dfc2aa 14d5add4367164f4aa994cd2ae006e8b5918265dade20b41f363daf9537c6d7b +lib/codeql/rust/generated/LetStmt.qll 1f8fda11b71689fb1a1b9b25a2ce046c56f36f26cddb354805bd395a03e4db3d 80ad6ea6afb1891a02db434cfefdb95b0fb7d766af6246ff27129dc15cb48ace +lib/codeql/rust/generated/LitPat.qll 92c3c0f32ab9d5b08e246231e5465fe18536dee99351f73e158048bb007baf8a 6736a7824e5bdb0cc16de1231bdb5169d2f48251d5917bf2c31a36422b0bf2fd +lib/codeql/rust/generated/LiteralExpr.qll 9202e11f56a2c5e99fb98ed784c7ca043c1f5d80680b48ba4ea340dd689ebe55 9202e11f56a2c5e99fb98ed784c7ca043c1f5d80680b48ba4ea340dd689ebe55 +lib/codeql/rust/generated/Locatable.qll 9e9685bba50ad2220701f3465e63af9331f7f9dc548ad906ff954fc2ce0a4400 78c89b2cc78a357d682ab65310dd474603071f07c1eaaab07711714ce17549f2 +lib/codeql/rust/generated/Location.qll bce4c72988ec6fedd1439c60a37c45aa6147c962904709ef9f12206937174be4 d57000571771a2d997c50d9a43ef1c2f075960f847effa0e80ea91fd4c6b4d6c +lib/codeql/rust/generated/LoopExpr.qll e9304e282a97984e147b92ec7061c98fde238a8691e945e4cb775ccf34c27b0c 65b859e44e83bddb710d4ce9e5ab1346b98eaaa46509671776b75c9e8f1c1667 +lib/codeql/rust/generated/MatchArm.qll 5ad0dc254b6d58ccd856e4235b68ca0226a898c33f1f6b6fe7b48266a01ca627 f519af39f45e820eb3a70cefb0e4dfb541c3cf17952c00c6dd7e59f854a629bd +lib/codeql/rust/generated/MatchExpr.qll f8b422699337324c91ec9c55024630efe114ca617f4f088a18d180df132d5754 13169bde872f533f55aa196d7150761857c593a4657ab34051346dde14e736c7 +lib/codeql/rust/generated/MethodCallExpr.qll 499fa4c78bafbb8f3a6af645c26f1645c9a634976d409493d26d82dddd4b42a3 2dd18cb4868e96e38383c4ae3f8777637422e90b2363bb533f0e9e1c2692dc6e +lib/codeql/rust/generated/MissingExpr.qll 90b164567620c88b8e258fa229633365400abeafa4f4b0fcd1c856efc2f9b206 90b164567620c88b8e258fa229633365400abeafa4f4b0fcd1c856efc2f9b206 +lib/codeql/rust/generated/MissingPat.qll 0d8034cee20bacf07ebb9337c797f53a25686a149f163f801916cd6ec5484710 0d8034cee20bacf07ebb9337c797f53a25686a149f163f801916cd6ec5484710 +lib/codeql/rust/generated/Module.qll 2a931a4f2cdb2fee00ed83af045ea63d36b7dbd708e58c30445b5610feaae333 cd62add5c31a509f965aa294f44a1607ec7c62e3a9e3fe9ee063b3c814f4eb62 +lib/codeql/rust/generated/OffsetOfExpr.qll 58dfd632efcb48de7fe6ffbcb2192fcf95bfabdb407a751133f63a0e32ae7489 21ebb1b3d66849fc21c04083cfa751eb56c55809cd52664020bd61ccfbe5ea68 +lib/codeql/rust/generated/OrPat.qll f8fe5c7b83a08dabcc530484a696274930040ea13501ae20f1426faeec67bcf0 f3adb3148890531b698570a48740335983a5e81977ba4ac651778f940f184398 +lib/codeql/rust/generated/ParentChild.qll 956f55ac17d66926c59f76d391b75c30767d236b145d6ae402f4308fa22a7d01 dd3cabb5b4a9ba42be60345f445cde18b0d7be934aeb94d7312eeef122e148d2 +lib/codeql/rust/generated/Pat.qll fe1c72856442dbab5655eff93f86c2cbce8d69d9fa1f99a0f9203061ea1112a4 d85d86e8b6c48df733589d186f610b1cd9086629180701e017774bddc62402c7 +lib/codeql/rust/generated/PathExpr.qll 3664ed2ad08097e4446b0fdad148118c754f8203541ae588d967ba9d79b6bf21 0d987d2358fe9b42e57585e7ae906de80e9f4ccf7c20e1d9bb7624ffbad96941 +lib/codeql/rust/generated/PathPat.qll acc4dda795bae97626a8d0041538f3ba1f0b591c743fed381cf198a8b04653cb c3deee1b3bb9bd37ae3ed4761d8ee2f498384fe5e1f5e31c0f9b99dfd864a0d5 +lib/codeql/rust/generated/PureSynthConstructors.qll 5eb1fc4f6a04172c34ae31e4931e4bf1f8b72fbe414c5f644731a45372d13573 5eb1fc4f6a04172c34ae31e4931e4bf1f8b72fbe414c5f644731a45372d13573 +lib/codeql/rust/generated/RangeExpr.qll f499d8c1f260d6262a55c1f3640aaee832ed8c9aac922cb2e05fefbca4509053 a01563640bc23fbce9d33da756bc209fd16155dc76a7fed4ba325979723f48a5 +lib/codeql/rust/generated/RangePat.qll 6ec95f6cb9c4bd93b38990bb1e3b89b526624305ac6ee7b94e6fb0a2f3db28fc 0e193f3816a7587d5103dba421bc2bf22b869522353d4e3f43d49a792eac6cf4 +lib/codeql/rust/generated/Raw.qll 48d1e7d642bd2a7605dbafe3929c558560054a4e4e3e4b36925a8bfafb7536b9 3b881e64127e9b41fee7e091de725f5cd1cb1263e4a52c02adb1fb339fe36c3d +lib/codeql/rust/generated/RecordFieldPat.qll 26bed2285d849b9b7ac52d86131eacb40df912db350e423e81fb98c393c08a69 05ed735aecee90901a1bdfae05d9f85d7f6581616eca3a9262fdef6673222f9b +lib/codeql/rust/generated/RecordLitExpr.qll 1d3264446ff57e8b169f1ad6da150b2d457d6b60eda0ff63e2353eb8ef9e9113 f523dd5ce7f4bac0aafab7b27c6cfe766c72a9ee0c92d7a263347e67edf096df +lib/codeql/rust/generated/RecordLitField.qll bc704b56a986f3a399dc9c3dc2b61cca0d40cd389c694b9fe13374780835ffcc ab6b05a87f240a97cc2a8c15bb84a1338ad33ce367619125a8514e8815fd050e +lib/codeql/rust/generated/RecordPat.qll 5fd26e95dd23b07a847bd28c95a4206df62f7cc22c8d7b3bafa10e902e917d15 e264a96c2af4e2f64a394a119329b8b376d4b23ec6a3fc6d123c5631845bc4ef +lib/codeql/rust/generated/RefExpr.qll bb37b8bff64b0cf1f18de297487455692311b2006c45161f25969e131359c60f bfbc2b67b2b2ec66f3539e4972a947946b29e0ba527042593060eaf6b21e28ad +lib/codeql/rust/generated/RefPat.qll 3525331e8ba25a8612324e860423a39ddb29e8eb50a9f2bf62e49bf182d64b6d 804efbd32869f92e5515d34852fed6416288f99b0aab95b5be5cb5bdd1eea806 +lib/codeql/rust/generated/RepeatExpr.qll 43aff00e966e4550179d756489e4cbc30618d66c93c13530c45b031b9513b915 b91691445e6f7de67d61c787f41b36a383cf36da1a216c18767ac1d2ce5db34c +lib/codeql/rust/generated/ReturnExpr.qll 6160f3a14ff1cbd6a297edae015769f90e8e31201639828d8a9d0d6e38c1ef99 b8c8a12f78281e558d230c6959236780758e9645fe22aca697b948535c20f9be +lib/codeql/rust/generated/SlicePat.qll b4de6692eebf1205940e04da963adc20a07b15923c3c3a7a512a24e3bd8342c9 ee9b919983807f39d97cfe8ca66b76bdbfde76db02db5c93268ce22cbddf4213 +lib/codeql/rust/generated/Stmt.qll 55688c8f42f6e7fd1b871e572d75fac60d0543e38c4be4638abbb00187651d3d f978006a8453137f989249e849a7c935a090da3a9b0116145da80068760e12fd +lib/codeql/rust/generated/Synth.qll 03ecd0d7e89aca555d2393bbea8de1cde0476e28fb9f198ed3355a74f1b5c1c8 11855cc446c2d8a77503795a7c395e86ff149ea10d773a6e50e54b08dd438642 +lib/codeql/rust/generated/SynthConstructors.qll 07106a119dcfc7a839454d1fa66c0e65d6ab17eeace40cd5bc857a65dc7c859b 07106a119dcfc7a839454d1fa66c0e65d6ab17eeace40cd5bc857a65dc7c859b +lib/codeql/rust/generated/TupleExpr.qll 13e4dbc1afcabf388c793145cd399789f4014662f2eed1d49cbe96eeb8355413 bfa0708885c120bad24e29deb29641c69a5e5361654f3a144ead9543bfbd7197 +lib/codeql/rust/generated/TuplePat.qll 23911b2ac7ee2279df8ef40a6e447437ef0ed62518504b17874a7652bf5e3f4b fc4f6f7ea40754290de194ac55939f08549bd637104baf8dc84ca3938bcbd1f1 +lib/codeql/rust/generated/TupleStructPat.qll fff004cce780501eac94fe4b146619a84e02c85cae12ffeba5a4058e8c9738ea 738659f8208aa65d1d8cf601e0d92a90a890d6cbaec51cf04c81fc75a827e30b +lib/codeql/rust/generated/TypeRef.qll 7cc468c2f473ee13c11a97c4360100376560e8fc42f25a136f1500fe31a31533 7cc468c2f473ee13c11a97c4360100376560e8fc42f25a136f1500fe31a31533 +lib/codeql/rust/generated/UnaryOpExpr.qll fd55d4bc9cd1a49d1f38f02fef16771f29bb5fb2512abd18341d56665859d18c f271ef5036410c018f48d6f15b17cb9beaf4111a42fc638ac4ed3db974a5f870 +lib/codeql/rust/generated/UnderscoreExpr.qll cd7f615e41562b80d89e413c1c808048da7746fd445f0eb6ad8c5d9996b44d5d cd7f615e41562b80d89e413c1c808048da7746fd445f0eb6ad8c5d9996b44d5d +lib/codeql/rust/generated/Unimplemented.qll 375b7935b7f4103728ece3042282ae82d19e471d7a9fa58c8cbdea31ea0cb113 375b7935b7f4103728ece3042282ae82d19e471d7a9fa58c8cbdea31ea0cb113 +lib/codeql/rust/generated/UnknownFile.qll ec9d1a3f15ecbf1743d4e39cb3b2f217aa9b54951c93302c2c4c238c3f0ce595 ec9d1a3f15ecbf1743d4e39cb3b2f217aa9b54951c93302c2c4c238c3f0ce595 +lib/codeql/rust/generated/UnknownLocation.qll a19e2838c52d702d268ae530f3dbd6fcd8bb28a237a52636a960f225454103cf a19e2838c52d702d268ae530f3dbd6fcd8bb28a237a52636a960f225454103cf +lib/codeql/rust/generated/UnsafeBlockExpr.qll 8464597373ea46f6391394f02c4ceb93ffe8441b434e6e71907b0a3369f72d8e 8464597373ea46f6391394f02c4ceb93ffe8441b434e6e71907b0a3369f72d8e +lib/codeql/rust/generated/WildPat.qll 8a2cede00ac2941cb94e294ffa81ada9ae6e61d8d8a720ce4f288740345802f8 8a2cede00ac2941cb94e294ffa81ada9ae6e61d8d8a720ce4f288740345802f8 +lib/codeql/rust/generated/YeetExpr.qll 2b37cf55ec26958cf226885e99d81c8bbc6ece69fbe92d9fcc8884ee0bc4aad4 e371531507311ea8a9fbaac74442fe9994ae85f0acdb79cc870e5318af52aba9 +lib/codeql/rust/generated/YieldExpr.qll 70ca98e14b24f12a3cbfe690417543fdce45b162f241834e2f7f58543aa11bda 40fe1281107317a7d80c7141229eed9c6904805dff615dfd0141ede2457e2c57 +test/extractor-tests/generated/Expr/MISSING_SOURCE.txt cc7c395e7c651d62596826b1a0bedf10f35d01b8afeef47600b4ddaf804f406e cc7c395e7c651d62596826b1a0bedf10f35d01b8afeef47600b4ddaf804f406e +test/extractor-tests/generated/File/File.ql dec43be882fad904fab0c6447ca93633d801cb08ff8bec309befde7d2b9e5dda 74e1f1d698558c35fa03935cc34f4c8145d376b56d7657b18aeb338f5ca752cf +test/extractor-tests/generated/Function/Function.ql c49434420dbb6fc3d9e6294161dcd3d3b306fae5ba5c85b610e534b8b15ef74c fe02208b673b74eebed92b5cbb3a8a06c31c0681eb28f3e596515663f14fa9e2 +test/extractor-tests/generated/Module/MISSING_SOURCE.txt cc7c395e7c651d62596826b1a0bedf10f35d01b8afeef47600b4ddaf804f406e cc7c395e7c651d62596826b1a0bedf10f35d01b8afeef47600b4ddaf804f406e +test/extractor-tests/generated/Pat/MISSING_SOURCE.txt cc7c395e7c651d62596826b1a0bedf10f35d01b8afeef47600b4ddaf804f406e cc7c395e7c651d62596826b1a0bedf10f35d01b8afeef47600b4ddaf804f406e +test/extractor-tests/generated/RecordFieldPat/MISSING_SOURCE.txt cc7c395e7c651d62596826b1a0bedf10f35d01b8afeef47600b4ddaf804f406e cc7c395e7c651d62596826b1a0bedf10f35d01b8afeef47600b4ddaf804f406e +test/extractor-tests/generated/RecordLitField/MISSING_SOURCE.txt cc7c395e7c651d62596826b1a0bedf10f35d01b8afeef47600b4ddaf804f406e cc7c395e7c651d62596826b1a0bedf10f35d01b8afeef47600b4ddaf804f406e +test/extractor-tests/generated/Stmt/MISSING_SOURCE.txt cc7c395e7c651d62596826b1a0bedf10f35d01b8afeef47600b4ddaf804f406e cc7c395e7c651d62596826b1a0bedf10f35d01b8afeef47600b4ddaf804f406e +test/extractor-tests/generated/TypeRef/MISSING_SOURCE.txt cc7c395e7c651d62596826b1a0bedf10f35d01b8afeef47600b4ddaf804f406e cc7c395e7c651d62596826b1a0bedf10f35d01b8afeef47600b4ddaf804f406e diff --git a/rust/ql/.gitattributes b/rust/ql/.gitattributes new file mode 100644 index 000000000000..048e925f2742 --- /dev/null +++ b/rust/ql/.gitattributes @@ -0,0 +1,225 @@ +/.generated.list linguist-generated +/.gitattributes linguist-generated +/lib/codeql/rust/elements/ArrayExpr.qll linguist-generated +/lib/codeql/rust/elements/AstNode.qll linguist-generated +/lib/codeql/rust/elements/AsyncBlockExpr.qll linguist-generated +/lib/codeql/rust/elements/AsyncBlockExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/AwaitExpr.qll linguist-generated +/lib/codeql/rust/elements/AwaitExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/BecomeExpr.qll linguist-generated +/lib/codeql/rust/elements/BecomeExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/BinaryOpExpr.qll linguist-generated +/lib/codeql/rust/elements/BinaryOpExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/BindPat.qll linguist-generated +/lib/codeql/rust/elements/BindPatConstructor.qll linguist-generated +/lib/codeql/rust/elements/BlockExpr.qll linguist-generated +/lib/codeql/rust/elements/BlockExprBase.qll linguist-generated +/lib/codeql/rust/elements/BlockExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/BoxExpr.qll linguist-generated +/lib/codeql/rust/elements/BoxExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/BoxPat.qll linguist-generated +/lib/codeql/rust/elements/BoxPatConstructor.qll linguist-generated +/lib/codeql/rust/elements/BreakExpr.qll linguist-generated +/lib/codeql/rust/elements/BreakExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/CallExpr.qll linguist-generated +/lib/codeql/rust/elements/CallExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/CastExpr.qll linguist-generated +/lib/codeql/rust/elements/CastExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/ClosureExpr.qll linguist-generated +/lib/codeql/rust/elements/ClosureExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/ConstBlockPat.qll linguist-generated +/lib/codeql/rust/elements/ConstBlockPatConstructor.qll linguist-generated +/lib/codeql/rust/elements/ConstExpr.qll linguist-generated +/lib/codeql/rust/elements/ConstExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/ContinueExpr.qll linguist-generated +/lib/codeql/rust/elements/ContinueExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/DbFile.qll linguist-generated +/lib/codeql/rust/elements/DbFileConstructor.qll linguist-generated +/lib/codeql/rust/elements/DbLocation.qll linguist-generated +/lib/codeql/rust/elements/DbLocationConstructor.qll linguist-generated +/lib/codeql/rust/elements/Declaration.qll linguist-generated +/lib/codeql/rust/elements/ElementListExpr.qll linguist-generated +/lib/codeql/rust/elements/ElementListExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/Expr.qll linguist-generated +/lib/codeql/rust/elements/ExprStmt.qll linguist-generated +/lib/codeql/rust/elements/ExprStmtConstructor.qll linguist-generated +/lib/codeql/rust/elements/FieldExpr.qll linguist-generated +/lib/codeql/rust/elements/FieldExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/FunctionConstructor.qll linguist-generated +/lib/codeql/rust/elements/IfExpr.qll linguist-generated +/lib/codeql/rust/elements/IfExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/IndexExpr.qll linguist-generated +/lib/codeql/rust/elements/IndexExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/InlineAsmExpr.qll linguist-generated +/lib/codeql/rust/elements/InlineAsmExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/ItemStmt.qll linguist-generated +/lib/codeql/rust/elements/ItemStmtConstructor.qll linguist-generated +/lib/codeql/rust/elements/Label.qll linguist-generated +/lib/codeql/rust/elements/LabelConstructor.qll linguist-generated +/lib/codeql/rust/elements/LetExpr.qll linguist-generated +/lib/codeql/rust/elements/LetExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/LetStmt.qll linguist-generated +/lib/codeql/rust/elements/LetStmtConstructor.qll linguist-generated +/lib/codeql/rust/elements/LitPat.qll linguist-generated +/lib/codeql/rust/elements/LitPatConstructor.qll linguist-generated +/lib/codeql/rust/elements/LiteralExpr.qll linguist-generated +/lib/codeql/rust/elements/LiteralExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/LoopExpr.qll linguist-generated +/lib/codeql/rust/elements/LoopExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/MatchArm.qll linguist-generated +/lib/codeql/rust/elements/MatchArmConstructor.qll linguist-generated +/lib/codeql/rust/elements/MatchExpr.qll linguist-generated +/lib/codeql/rust/elements/MatchExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/MethodCallExpr.qll linguist-generated +/lib/codeql/rust/elements/MethodCallExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/MissingExpr.qll linguist-generated +/lib/codeql/rust/elements/MissingExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/MissingPat.qll linguist-generated +/lib/codeql/rust/elements/MissingPatConstructor.qll linguist-generated +/lib/codeql/rust/elements/Module.qll linguist-generated +/lib/codeql/rust/elements/ModuleConstructor.qll linguist-generated +/lib/codeql/rust/elements/OffsetOfExpr.qll linguist-generated +/lib/codeql/rust/elements/OffsetOfExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/OrPat.qll linguist-generated +/lib/codeql/rust/elements/OrPatConstructor.qll linguist-generated +/lib/codeql/rust/elements/Pat.qll linguist-generated +/lib/codeql/rust/elements/PathExpr.qll linguist-generated +/lib/codeql/rust/elements/PathExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/PathPat.qll linguist-generated +/lib/codeql/rust/elements/PathPatConstructor.qll linguist-generated +/lib/codeql/rust/elements/RangeExpr.qll linguist-generated +/lib/codeql/rust/elements/RangeExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/RangePat.qll linguist-generated +/lib/codeql/rust/elements/RangePatConstructor.qll linguist-generated +/lib/codeql/rust/elements/RecordFieldPat.qll linguist-generated +/lib/codeql/rust/elements/RecordFieldPatConstructor.qll linguist-generated +/lib/codeql/rust/elements/RecordLitExpr.qll linguist-generated +/lib/codeql/rust/elements/RecordLitExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/RecordLitField.qll linguist-generated +/lib/codeql/rust/elements/RecordLitFieldConstructor.qll linguist-generated +/lib/codeql/rust/elements/RecordPat.qll linguist-generated +/lib/codeql/rust/elements/RecordPatConstructor.qll linguist-generated +/lib/codeql/rust/elements/RefExpr.qll linguist-generated +/lib/codeql/rust/elements/RefExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/RefPat.qll linguist-generated +/lib/codeql/rust/elements/RefPatConstructor.qll linguist-generated +/lib/codeql/rust/elements/RepeatExpr.qll linguist-generated +/lib/codeql/rust/elements/RepeatExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/ReturnExpr.qll linguist-generated +/lib/codeql/rust/elements/ReturnExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/SlicePat.qll linguist-generated +/lib/codeql/rust/elements/SlicePatConstructor.qll linguist-generated +/lib/codeql/rust/elements/Stmt.qll linguist-generated +/lib/codeql/rust/elements/TupleExpr.qll linguist-generated +/lib/codeql/rust/elements/TupleExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/TuplePat.qll linguist-generated +/lib/codeql/rust/elements/TuplePatConstructor.qll linguist-generated +/lib/codeql/rust/elements/TupleStructPat.qll linguist-generated +/lib/codeql/rust/elements/TupleStructPatConstructor.qll linguist-generated +/lib/codeql/rust/elements/TypeRef.qll linguist-generated +/lib/codeql/rust/elements/TypeRefConstructor.qll linguist-generated +/lib/codeql/rust/elements/UnaryOpExpr.qll linguist-generated +/lib/codeql/rust/elements/UnaryOpExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/UnderscoreExpr.qll linguist-generated +/lib/codeql/rust/elements/UnderscoreExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/Unimplemented.qll linguist-generated +/lib/codeql/rust/elements/UnimplementedConstructor.qll linguist-generated +/lib/codeql/rust/elements/UnsafeBlockExpr.qll linguist-generated +/lib/codeql/rust/elements/UnsafeBlockExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/WildPat.qll linguist-generated +/lib/codeql/rust/elements/WildPatConstructor.qll linguist-generated +/lib/codeql/rust/elements/YeetExpr.qll linguist-generated +/lib/codeql/rust/elements/YeetExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/YieldExpr.qll linguist-generated +/lib/codeql/rust/elements/YieldExprConstructor.qll linguist-generated +/lib/codeql/rust/elements.qll linguist-generated +/lib/codeql/rust/generated/ArrayExpr.qll linguist-generated +/lib/codeql/rust/generated/AstNode.qll linguist-generated +/lib/codeql/rust/generated/AsyncBlockExpr.qll linguist-generated +/lib/codeql/rust/generated/AwaitExpr.qll linguist-generated +/lib/codeql/rust/generated/BecomeExpr.qll linguist-generated +/lib/codeql/rust/generated/BinaryOpExpr.qll linguist-generated +/lib/codeql/rust/generated/BindPat.qll linguist-generated +/lib/codeql/rust/generated/BlockExpr.qll linguist-generated +/lib/codeql/rust/generated/BlockExprBase.qll linguist-generated +/lib/codeql/rust/generated/BoxExpr.qll linguist-generated +/lib/codeql/rust/generated/BoxPat.qll linguist-generated +/lib/codeql/rust/generated/BreakExpr.qll linguist-generated +/lib/codeql/rust/generated/CallExpr.qll linguist-generated +/lib/codeql/rust/generated/CastExpr.qll linguist-generated +/lib/codeql/rust/generated/ClosureExpr.qll linguist-generated +/lib/codeql/rust/generated/ConstBlockPat.qll linguist-generated +/lib/codeql/rust/generated/ConstExpr.qll linguist-generated +/lib/codeql/rust/generated/ContinueExpr.qll linguist-generated +/lib/codeql/rust/generated/DbFile.qll linguist-generated +/lib/codeql/rust/generated/DbLocation.qll linguist-generated +/lib/codeql/rust/generated/Declaration.qll linguist-generated +/lib/codeql/rust/generated/Element.qll linguist-generated +/lib/codeql/rust/generated/ElementListExpr.qll linguist-generated +/lib/codeql/rust/generated/Expr.qll linguist-generated +/lib/codeql/rust/generated/ExprStmt.qll linguist-generated +/lib/codeql/rust/generated/FieldExpr.qll linguist-generated +/lib/codeql/rust/generated/File.qll linguist-generated +/lib/codeql/rust/generated/Function.qll linguist-generated +/lib/codeql/rust/generated/IfExpr.qll linguist-generated +/lib/codeql/rust/generated/IndexExpr.qll linguist-generated +/lib/codeql/rust/generated/InlineAsmExpr.qll linguist-generated +/lib/codeql/rust/generated/ItemStmt.qll linguist-generated +/lib/codeql/rust/generated/Label.qll linguist-generated +/lib/codeql/rust/generated/LetExpr.qll linguist-generated +/lib/codeql/rust/generated/LetStmt.qll linguist-generated +/lib/codeql/rust/generated/LitPat.qll linguist-generated +/lib/codeql/rust/generated/LiteralExpr.qll linguist-generated +/lib/codeql/rust/generated/Locatable.qll linguist-generated +/lib/codeql/rust/generated/Location.qll linguist-generated +/lib/codeql/rust/generated/LoopExpr.qll linguist-generated +/lib/codeql/rust/generated/MatchArm.qll linguist-generated +/lib/codeql/rust/generated/MatchExpr.qll linguist-generated +/lib/codeql/rust/generated/MethodCallExpr.qll linguist-generated +/lib/codeql/rust/generated/MissingExpr.qll linguist-generated +/lib/codeql/rust/generated/MissingPat.qll linguist-generated +/lib/codeql/rust/generated/Module.qll linguist-generated +/lib/codeql/rust/generated/OffsetOfExpr.qll linguist-generated +/lib/codeql/rust/generated/OrPat.qll linguist-generated +/lib/codeql/rust/generated/ParentChild.qll linguist-generated +/lib/codeql/rust/generated/Pat.qll linguist-generated +/lib/codeql/rust/generated/PathExpr.qll linguist-generated +/lib/codeql/rust/generated/PathPat.qll linguist-generated +/lib/codeql/rust/generated/PureSynthConstructors.qll linguist-generated +/lib/codeql/rust/generated/RangeExpr.qll linguist-generated +/lib/codeql/rust/generated/RangePat.qll linguist-generated +/lib/codeql/rust/generated/Raw.qll linguist-generated +/lib/codeql/rust/generated/RecordFieldPat.qll linguist-generated +/lib/codeql/rust/generated/RecordLitExpr.qll linguist-generated +/lib/codeql/rust/generated/RecordLitField.qll linguist-generated +/lib/codeql/rust/generated/RecordPat.qll linguist-generated +/lib/codeql/rust/generated/RefExpr.qll linguist-generated +/lib/codeql/rust/generated/RefPat.qll linguist-generated +/lib/codeql/rust/generated/RepeatExpr.qll linguist-generated +/lib/codeql/rust/generated/ReturnExpr.qll linguist-generated +/lib/codeql/rust/generated/SlicePat.qll linguist-generated +/lib/codeql/rust/generated/Stmt.qll linguist-generated +/lib/codeql/rust/generated/Synth.qll linguist-generated +/lib/codeql/rust/generated/SynthConstructors.qll linguist-generated +/lib/codeql/rust/generated/TupleExpr.qll linguist-generated +/lib/codeql/rust/generated/TuplePat.qll linguist-generated +/lib/codeql/rust/generated/TupleStructPat.qll linguist-generated +/lib/codeql/rust/generated/TypeRef.qll linguist-generated +/lib/codeql/rust/generated/UnaryOpExpr.qll linguist-generated +/lib/codeql/rust/generated/UnderscoreExpr.qll linguist-generated +/lib/codeql/rust/generated/Unimplemented.qll linguist-generated +/lib/codeql/rust/generated/UnknownFile.qll linguist-generated +/lib/codeql/rust/generated/UnknownLocation.qll linguist-generated +/lib/codeql/rust/generated/UnsafeBlockExpr.qll linguist-generated +/lib/codeql/rust/generated/WildPat.qll linguist-generated +/lib/codeql/rust/generated/YeetExpr.qll linguist-generated +/lib/codeql/rust/generated/YieldExpr.qll linguist-generated +/test/extractor-tests/generated/Expr/MISSING_SOURCE.txt linguist-generated +/test/extractor-tests/generated/File/File.ql linguist-generated +/test/extractor-tests/generated/Function/Function.ql linguist-generated +/test/extractor-tests/generated/Module/MISSING_SOURCE.txt linguist-generated +/test/extractor-tests/generated/Pat/MISSING_SOURCE.txt linguist-generated +/test/extractor-tests/generated/RecordFieldPat/MISSING_SOURCE.txt linguist-generated +/test/extractor-tests/generated/RecordLitField/MISSING_SOURCE.txt linguist-generated +/test/extractor-tests/generated/Stmt/MISSING_SOURCE.txt linguist-generated +/test/extractor-tests/generated/TypeRef/MISSING_SOURCE.txt linguist-generated diff --git a/rust/ql/lib/codeql/IDEContextual.qll b/rust/ql/lib/codeql/IDEContextual.qll new file mode 100644 index 000000000000..cfb127a36e7b --- /dev/null +++ b/rust/ql/lib/codeql/IDEContextual.qll @@ -0,0 +1,16 @@ +/** + * Provides shared predicates related to contextual queries in the code viewer. + */ + +private import codeql.rust.elements.File +private import codeql.util.FileSystem + +/** + * Returns an appropriately encoded version of a filename `name` + * passed by the VS Code extension in order to coincide with the + * output of `.getFile()` on locatable entities. + */ +cached +File getFileBySourceArchiveName(string name) { + result = IdeContextual::getFileBySourceArchiveName(name) +} diff --git a/rust/ql/lib/codeql/rust/controlflow/BasicBlocks.qll b/rust/ql/lib/codeql/rust/controlflow/BasicBlocks.qll new file mode 100644 index 000000000000..d5af73f2ba0f --- /dev/null +++ b/rust/ql/lib/codeql/rust/controlflow/BasicBlocks.qll @@ -0,0 +1,263 @@ +private import rust +private import ControlFlowGraph +private import internal.SuccessorType +private import internal.ControlFlowGraphImpl as Impl +private import codeql.rust.generated.Raw +private import codeql.rust.generated.Synth + +final class BasicBlock = BasicBlockImpl; + +/** + * A basic block, that is, a maximal straight-line sequence of control flow nodes + * without branches or joins. + */ +private class BasicBlockImpl extends TBasicBlockStart { + /** Gets the scope of this basic block. */ + CfgScope getScope() { result = this.getAPredecessor().getScope() } + + /** Gets an immediate successor of this basic block, if any. */ + BasicBlock getASuccessor() { result = this.getASuccessor(_) } + + /** Gets an immediate successor of this basic block of a given type, if any. */ + BasicBlock getASuccessor(SuccessorType t) { + result.getFirstNode() = this.getLastNode().getASuccessor(t) + } + + /** Gets an immediate predecessor of this basic block, if any. */ + BasicBlock getAPredecessor() { result.getASuccessor() = this } + + /** Gets an immediate predecessor of this basic block of a given type, if any. */ + BasicBlock getAPredecessor(SuccessorType t) { result.getASuccessor(t) = this } + + /** Gets the control flow node at a specific (zero-indexed) position in this basic block. */ + CfgNode getNode(int pos) { bbIndex(this.getFirstNode(), result, pos) } + + /** Gets a control flow node in this basic block. */ + CfgNode getANode() { result = this.getNode(_) } + + /** Gets the first control flow node in this basic block. */ + CfgNode getFirstNode() { this = TBasicBlockStart(result) } + + /** Gets the last control flow node in this basic block. */ + CfgNode getLastNode() { result = this.getNode(this.length() - 1) } + + /** Gets the length of this basic block. */ + int length() { result = strictcount(this.getANode()) } + + predicate immediatelyDominates(BasicBlock bb) { bbIDominates(this, bb) } + + predicate strictlyDominates(BasicBlock bb) { bbIDominates+(this, bb) } + + predicate dominates(BasicBlock bb) { + bb = this or + this.strictlyDominates(bb) + } + + predicate inDominanceFrontier(BasicBlock df) { + this.dominatesPredecessor(df) and + not this.strictlyDominates(df) + } + + /** + * Holds if this basic block dominates a predecessor of `df`. + */ + private predicate dominatesPredecessor(BasicBlock df) { this.dominates(df.getAPredecessor()) } + + BasicBlock getImmediateDominator() { bbIDominates(result, this) } + + predicate strictlyPostDominates(BasicBlock bb) { bbIPostDominates+(this, bb) } + + predicate postDominates(BasicBlock bb) { + this.strictlyPostDominates(bb) or + this = bb + } + + /** Holds if this basic block is in a loop in the control flow graph. */ + predicate inLoop() { this.getASuccessor+() = this } + + /** Gets a textual representation of this basic block. */ + string toString() { result = this.getFirstNode().toString() } + + /** Gets the location of this basic block. */ + Location getLocation() { result = this.getFirstNode().getLocation() } +} + +cached +private module Cached { + /** Internal representation of basic blocks. */ + cached + newtype TBasicBlock = TBasicBlockStart(CfgNode cfn) { startsBB(cfn) } + + /** Holds if `cfn` starts a new basic block. */ + private predicate startsBB(CfgNode cfn) { + not exists(cfn.getAPredecessor()) and exists(cfn.getASuccessor()) + or + cfn.isJoin() + or + cfn.getAPredecessor().isBranch() + } + + /** + * Holds if `succ` is a control flow successor of `pred` within + * the same basic block. + */ + private predicate intraBBSucc(CfgNode pred, CfgNode succ) { + succ = pred.getASuccessor() and + not startsBB(succ) + } + + /** + * Holds if `cfn` is the `i`th node in basic block `bb`. + * + * In other words, `i` is the shortest distance from a node `bb` + * that starts a basic block to `cfn` along the `intraBBSucc` relation. + */ + cached + predicate bbIndex(CfgNode bbStart, CfgNode cfn, int i) = + shortestDistances(startsBB/1, intraBBSucc/2)(bbStart, cfn, i) + + /** + * Holds if the first node of basic block `succ` is a control flow + * successor of the last node of basic block `pred`. + */ + private predicate succBB(BasicBlock pred, BasicBlock succ) { succ = pred.getASuccessor() } + + /** Holds if `dom` is an immediate dominator of `bb`. */ + cached + predicate bbIDominates(BasicBlock dom, BasicBlock bb) = + idominance(entryBB/1, succBB/2)(_, dom, bb) + + /** Holds if `pred` is a basic block predecessor of `succ`. */ + private predicate predBB(BasicBlock succ, BasicBlock pred) { succBB(pred, succ) } + + /** Holds if `bb` is an exit basic block that represents normal exit. */ + private predicate normalExitBB(BasicBlock bb) { + bb.getANode().(Impl::AnnotatedExitNode).isNormal() + } + + /** Holds if `dom` is an immediate post-dominator of `bb`. */ + cached + predicate bbIPostDominates(BasicBlock dom, BasicBlock bb) = + idominance(normalExitBB/1, predBB/2)(_, dom, bb) + + /** + * Gets the `i`th predecessor of join block `jb`, with respect to some + * arbitrary order. + */ + cached + JoinBlockPredecessor getJoinBlockPredecessor(JoinBlock jb, int i) { + result = + rank[i + 1](JoinBlockPredecessor jbp | + jbp = jb.getAPredecessor() + | + jbp order by JoinBlockPredecessors::getId(jbp), JoinBlockPredecessors::getSplitString(jbp) + ) + } +} + +private import Cached + +/** Holds if `bb` is an entry basic block. */ +private predicate entryBB(BasicBlock bb) { bb.getFirstNode() instanceof Impl::EntryNode } + +/** + * An entry basic block, that is, a basic block whose first node is + * an entry node. + */ +class EntryBasicBlock extends BasicBlockImpl { + EntryBasicBlock() { entryBB(this) } + + override CfgScope getScope() { + this.getFirstNode() = any(Impl::EntryNode node | node.getScope() = result) + } +} + +/** + * An annotated exit basic block, that is, a basic block whose last node is + * an annotated exit node. + */ +class AnnotatedExitBasicBlock extends BasicBlockImpl { + private boolean normal; + + AnnotatedExitBasicBlock() { + exists(Impl::AnnotatedExitNode n | + n = this.getANode() and + if n.isNormal() then normal = true else normal = false + ) + } + + /** Holds if this block represent a normal exit. */ + final predicate isNormal() { normal = true } +} + +/** + * An exit basic block, that is, a basic block whose last node is + * an exit node. + */ +class ExitBasicBlock extends BasicBlockImpl { + ExitBasicBlock() { this.getLastNode() instanceof Impl::ExitNode } +} + +private module JoinBlockPredecessors { + private predicate id(Raw::AstNode x, Raw::AstNode y) { x = y } + + private predicate idOfDbAstNode(Raw::AstNode x, int y) = equivalenceRelation(id/2)(x, y) + + // TODO: does not work if fresh ipa entities (`ipa: on:`) turn out to be first of the block + private predicate idOf(AstNode x, int y) { idOfDbAstNode(Synth::convertAstNodeToRaw(x), y) } + + int getId(JoinBlockPredecessor jbp) { + idOf(jbp.getFirstNode().(Impl::AstCfgNode).getAstNode(), result) + or + idOf(jbp.(EntryBasicBlock).getScope(), result) + } + + string getSplitString(JoinBlockPredecessor jbp) { + result = jbp.getFirstNode().(Impl::AstCfgNode).getSplitsString() + or + not exists(jbp.getFirstNode().(Impl::AstCfgNode).getSplitsString()) and + result = "" + } +} + +/** A basic block with more than one predecessor. */ +class JoinBlock extends BasicBlockImpl { + JoinBlock() { this.getFirstNode().isJoin() } + + /** + * Gets the `i`th predecessor of this join block, with respect to some + * arbitrary order. + */ + JoinBlockPredecessor getJoinBlockPredecessor(int i) { result = getJoinBlockPredecessor(this, i) } +} + +/** A basic block that is an immediate predecessor of a join block. */ +class JoinBlockPredecessor extends BasicBlockImpl { + JoinBlockPredecessor() { this.getASuccessor() instanceof JoinBlock } +} + +/** A basic block that terminates in a condition, splitting the subsequent control flow. */ +class ConditionBlock extends BasicBlockImpl { + ConditionBlock() { this.getLastNode().isCondition() } + + /** + * Holds if basic block `succ` is immediately controlled by this basic + * block with conditional value `s`. That is, `succ` is an immediate + * successor of this block, and `succ` can only be reached from + * the callable entry point by going via the `s` edge out of this basic block. + */ + pragma[nomagic] + predicate immediatelyControls(BasicBlock succ, SuccessorType s) { + succ = this.getASuccessor(s) and + forall(BasicBlock pred | pred = succ.getAPredecessor() and pred != this | succ.dominates(pred)) + } + + /** + * Holds if basic block `controlled` is controlled by this basic block with + * conditional value `s`. That is, `controlled` can only be reached from + * the callable entry point by going via the `s` edge out of this basic block. + */ + predicate controls(BasicBlock controlled, BooleanSuccessor s) { + exists(BasicBlock succ | this.immediatelyControls(succ, s) | succ.dominates(controlled)) + } +} diff --git a/rust/ql/lib/codeql/rust/controlflow/ControlFlowGraph.qll b/rust/ql/lib/codeql/rust/controlflow/ControlFlowGraph.qll new file mode 100644 index 000000000000..e8e6e5f98c9d --- /dev/null +++ b/rust/ql/lib/codeql/rust/controlflow/ControlFlowGraph.qll @@ -0,0 +1,38 @@ +/** Provides classes representing the control flow graph. */ + +private import rust +private import internal.ControlFlowGraphImpl +private import internal.Completion +private import internal.SuccessorType +private import internal.Scope as Scope +private import BasicBlocks + +final class CfgScope = Scope::CfgScope; + +/** + * A control flow node. + * + * A control flow node is a node in the control flow graph (CFG). There is a + * many-to-one relationship between CFG nodes and AST nodes. + * + * Only nodes that can be reached from an entry point are included in the CFG. + */ +final class CfgNode extends Node { + /** Gets the file of this control flow node. */ + File getFile() { result = this.getLocation().getFile() } + + /** Gets a successor node of a given type, if any. */ + CfgNode getASuccessor(SuccessorType t) { result = super.getASuccessor(t) } + + /** Gets an immediate successor, if any. */ + CfgNode getASuccessor() { result = this.getASuccessor(_) } + + /** Gets an immediate predecessor node of a given flow type, if any. */ + CfgNode getAPredecessor(SuccessorType t) { result.getASuccessor(t) = this } + + /** Gets an immediate predecessor, if any. */ + CfgNode getAPredecessor() { result = this.getAPredecessor(_) } + + /** Gets the basic block that this control flow node belongs to. */ + BasicBlock getBasicBlock() { result.getANode() = this } +} diff --git a/rust/ql/lib/codeql/rust/controlflow/internal/Completion.qll b/rust/ql/lib/codeql/rust/controlflow/internal/Completion.qll new file mode 100644 index 000000000000..088866f7ea92 --- /dev/null +++ b/rust/ql/lib/codeql/rust/controlflow/internal/Completion.qll @@ -0,0 +1,93 @@ +private import codeql.util.Boolean +private import codeql.rust.controlflow.ControlFlowGraph +private import rust +private import SuccessorType + +private newtype TCompletion = + TSimpleCompletion() or + TBooleanCompletion(Boolean b) or + TReturnCompletion() + +/** A completion of a statement or an expression. */ +abstract class Completion extends TCompletion { + /** Gets a textual representation of this completion. */ + abstract string toString(); + + predicate isValidForSpecific(AstNode e) { none() } + + predicate isValidFor(AstNode e) { this.isValidForSpecific(e) } + + /** Gets a successor type that matches this completion. */ + abstract SuccessorType getAMatchingSuccessorType(); +} + +/** + * A completion that represents normal evaluation of a statement or an + * expression. + */ +abstract class NormalCompletion extends Completion { } + +/** A simple (normal) completion. */ +class SimpleCompletion extends NormalCompletion, TSimpleCompletion { + override NormalSuccessor getAMatchingSuccessorType() { any() } + + // `SimpleCompletion` is the "default" completion type, thus it is valid for + // any node where there isn't another more specific completion type. + override predicate isValidFor(AstNode e) { not any(Completion c).isValidForSpecific(e) } + + override string toString() { result = "simple" } +} + +/** + * A completion that represents evaluation of an expression, whose value + * determines the successor. + */ +abstract class ConditionalCompletion extends NormalCompletion { + boolean value; + + bindingset[value] + ConditionalCompletion() { any() } + + /** Gets the Boolean value of this conditional completion. */ + final boolean getValue() { result = value } + + /** Gets the dual completion. */ + abstract ConditionalCompletion getDual(); +} + +/** + * A completion that represents evaluation of an expression + * with a Boolean value. + */ +class BooleanCompletion extends ConditionalCompletion, TBooleanCompletion { + BooleanCompletion() { this = TBooleanCompletion(value) } + + override predicate isValidForSpecific(AstNode e) { e = any(IfExpr c).getCondition() } + + /** Gets the dual Boolean completion. */ + override BooleanCompletion getDual() { result = TBooleanCompletion(value.booleanNot()) } + + override BooleanSuccessor getAMatchingSuccessorType() { result.getValue() = value } + + override string toString() { result = "boolean(" + value + ")" } +} + +/** + * A completion that represents a return. + */ +class ReturnCompletion extends TReturnCompletion, Completion { + override ReturnSuccessor getAMatchingSuccessorType() { any() } + + override predicate isValidForSpecific(AstNode e) { e instanceof ReturnExpr } + + override string toString() { result = "return" } +} + +/** Hold if `c` represents normal evaluation of a statement or an expression. */ +predicate completionIsNormal(Completion c) { c instanceof NormalCompletion } + +/** Hold if `c` represents simple and normal evaluation of a statement or an expression. */ +predicate completionIsSimple(Completion c) { c instanceof SimpleCompletion } + +/** Holds if `c` is a valid completion for `n`. */ +predicate completionIsValidFor(Completion c, AstNode n) { c.isValidFor(n) } diff --git a/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll b/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll new file mode 100644 index 000000000000..1370362bf0f0 --- /dev/null +++ b/rust/ql/lib/codeql/rust/controlflow/internal/ControlFlowGraphImpl.qll @@ -0,0 +1,129 @@ +private import rust +import codeql.controlflow.Cfg +import Completion +import codeql.controlflow.Cfg +private import SuccessorType as ST +private import Scope as Scope + +module CfgInput implements InputSig { + private import rust as Rust + private import Completion as C + private import Splitting as S + + class AstNode = Rust::AstNode; + + class Completion = C::Completion; + + predicate completionIsNormal = C::completionIsNormal/1; + + predicate completionIsSimple = C::completionIsSimple/1; + + predicate completionIsValidFor = C::completionIsValidFor/2; + + /** An AST node with an associated control-flow graph. */ + class CfgScope = Scope::CfgScope; + + CfgScope getCfgScope(AstNode n) { result = Scope::scopeOfAst(n) } + + class SplitKindBase = S::TSplitKind; + + class Split = S::Split; + + class SuccessorType = ST::SuccessorType; + + /** Gets a successor type that matches completion `c`. */ + SuccessorType getAMatchingSuccessorType(Completion c) { result = c.getAMatchingSuccessorType() } + + /** + * Hold if `c` represents simple (normal) evaluation of a statement or an expression. + */ + predicate successorTypeIsSimple(SuccessorType t) { t instanceof ST::NormalSuccessor } + + /** Holds if `t` is an abnormal exit type out of a CFG scope. */ + predicate isAbnormalExitType(SuccessorType t) { none() } + + /** Hold if `t` represents a conditional successor type. */ + predicate successorTypeIsCondition(SuccessorType t) { t instanceof ST::BooleanSuccessor } + + /** Gets the maximum number of splits allowed for a given node. */ + int maxSplits() { result = 0 } + + /** Holds if `first` is first executed when entering `scope`. */ + predicate scopeFirst(CfgScope scope, AstNode first) { + scope.(CfgImpl::ControlFlowTree).first(first) + } + + /** Holds if `scope` is exited when `last` finishes with completion `c`. */ + predicate scopeLast(CfgScope scope, AstNode last, Completion c) { + scope.(CfgImpl::ControlFlowTree).last(last, c) + } +} + +module CfgImpl = Make; + +import CfgImpl + +class FunctionTree extends StandardPostOrderTree instanceof Function { + override ControlFlowTree getChildNode(int i) { i = 0 and result = super.getBody() } +} + +class BlockExprTree extends StandardPostOrderTree instanceof BlockExpr { + override ControlFlowTree getChildNode(int i) { + result = super.getStatement(i) + or + not exists(super.getStatement(i)) and + (exists(super.getStatement(i - 1)) or i = 0) and + result = super.getTail() + } +} + +class CallExprTree extends StandardPostOrderTree instanceof CallExpr { + override ControlFlowTree getChildNode(int i) { result = super.getArg(i) } +} + +class BinaryOpExprTree extends StandardPostOrderTree instanceof BinaryOpExpr { + override ControlFlowTree getChildNode(int i) { + i = 0 and result = super.getLhs() + or + i = 1 and result = super.getRhs() + } +} + +class IfExprTree extends PostOrderTree instanceof IfExpr { + override predicate first(AstNode node) { first(super.getCondition(), node) } + + override predicate propagatesAbnormal(AstNode child) { + child = [super.getCondition(), super.getThen(), super.getElse()] + } + + override predicate succ(AstNode pred, AstNode succ, Completion c) { + // Edges from the condition to each branch + last(super.getCondition(), pred, c) and + ( + first(super.getThen(), succ) and c.(BooleanCompletion).getValue() = true + or + first(super.getElse(), succ) and c.(BooleanCompletion).getValue() = false + ) + or + // An edge from the then branch to the last node + last(super.getThen(), pred, c) and + succ = this and + completionIsNormal(c) + or + // An edge from the else branch to the last node + last(super.getElse(), pred, c) and + succ = this and + completionIsNormal(c) + } +} + +class LetExprTree extends StandardPostOrderTree instanceof LetExpr { + override ControlFlowTree getChildNode(int i) { i = 0 and result = super.getExpr() } +} + +class LiteralExprTree extends LeafTree instanceof LiteralExpr { } + +class PathExprTree extends LeafTree instanceof PathExpr { } + +// A leaf tree for unimplemented nodes in the AST. +class UnimplementedTree extends LeafTree instanceof Unimplemented { } diff --git a/rust/ql/lib/codeql/rust/controlflow/internal/PrintCfg.ql b/rust/ql/lib/codeql/rust/controlflow/internal/PrintCfg.ql new file mode 100644 index 000000000000..d4db94ca22ae --- /dev/null +++ b/rust/ql/lib/codeql/rust/controlflow/internal/PrintCfg.ql @@ -0,0 +1,50 @@ +/** + * @name Print CFG + * @description Produces a representation of a file's Control Flow Graph. + * This query is used by the VS Code extension. + * @id rust/print-cfg + * @kind graph + * @tags ide-contextual-queries/print-cfg + */ + +private import codeql.rust.elements.File +private import codeql.rust.controlflow.internal.ControlFlowGraphImpl +private import codeql.rust.controlflow.ControlFlowGraph + +/** + * Gets the source file to generate a CFG from. + */ +external string selectedSourceFile(); + +private predicate selectedSourceFileAlias = selectedSourceFile/0; + +/** + * Gets the source line to generate a CFG from. + */ +external int selectedSourceLine(); + +private predicate selectedSourceLineAlias = selectedSourceLine/0; + +/** + * Gets the source column to generate a CFG from. + */ +external int selectedSourceColumn(); + +private predicate selectedSourceColumnAlias = selectedSourceColumn/0; + +private module ViewCfgQueryInput implements ViewCfgQueryInputSig { + predicate selectedSourceFile = selectedSourceFileAlias/0; + + predicate selectedSourceLine = selectedSourceLineAlias/0; + + predicate selectedSourceColumn = selectedSourceColumnAlias/0; + + predicate cfgScopeSpan( + CfgScope scope, File file, int startLine, int startColumn, int endLine, int endColumn + ) { + file = scope.getFile() and + scope.getLocation().hasLocationInfo(_, startLine, startColumn, endLine, endColumn) + } +} + +import ViewCfgQuery diff --git a/rust/ql/lib/codeql/rust/controlflow/internal/Scope.qll b/rust/ql/lib/codeql/rust/controlflow/internal/Scope.qll new file mode 100644 index 000000000000..c0729f853f77 --- /dev/null +++ b/rust/ql/lib/codeql/rust/controlflow/internal/Scope.qll @@ -0,0 +1,32 @@ +private import rust +private import Completion +private import codeql.rust.generated.ParentChild + +abstract class CfgScope extends AstNode { } + +class FunctionScope extends CfgScope, Function { } + +/** + * Gets the immediate parent of a non-`AstNode` element `e`. + * + * We restrict `e` to be a non-`AstNode` to skip past non-`AstNode` in + * the transitive closure computation in `getParentOfAst`. This is + * necessary because the parent of an `AstNode` is not necessarily an `AstNode`. + */ +private Element getParentOfAstStep(Element e) { + not e instanceof AstNode and + result = getImmediateParent(e) +} + +/** Gets the nearest enclosing parent of `ast` that is an `AstNode`. */ +private AstNode getParentOfAst(AstNode ast) { + result = getParentOfAstStep*(getImmediateParent(ast)) +} + +/** Gets the enclosing scope of a node */ +cached +AstNode scopeOfAst(AstNode n) { + exists(AstNode p | p = getParentOfAst(n) | + if p instanceof CfgScope then p = result else result = scopeOfAst(p) + ) +} diff --git a/rust/ql/lib/codeql/rust/controlflow/internal/Splitting.qll b/rust/ql/lib/codeql/rust/controlflow/internal/Splitting.qll new file mode 100644 index 000000000000..b4f0a060be6d --- /dev/null +++ b/rust/ql/lib/codeql/rust/controlflow/internal/Splitting.qll @@ -0,0 +1,17 @@ +cached +private module Cached { + // Not using CFG splitting, so the following are just placeholder types. + cached + newtype TSplitKind = TSplitKindUnit() + + cached + newtype TSplit = TSplitUnit() +} + +import Cached + +/** A split for a control flow node. */ +class Split extends TSplit { + /** Gets a textual representation of this split. */ + string toString() { none() } +} diff --git a/rust/ql/lib/codeql/rust/controlflow/internal/SuccessorType.qll b/rust/ql/lib/codeql/rust/controlflow/internal/SuccessorType.qll new file mode 100644 index 000000000000..5ea12fc8a5c5 --- /dev/null +++ b/rust/ql/lib/codeql/rust/controlflow/internal/SuccessorType.qll @@ -0,0 +1,45 @@ +private import codeql.util.Boolean + +cached +newtype TSuccessorType = + TSuccessorSuccessor() or + TBooleanSuccessor(Boolean b) or + TReturnSuccessor() + +/** The type of a control flow successor. */ +abstract private class SuccessorTypeImpl extends TSuccessorType { + /** Gets a textual representation of successor type. */ + abstract string toString(); +} + +final class SuccessorType = SuccessorTypeImpl; + +/** A normal control flow successor. */ +final class NormalSuccessor extends SuccessorTypeImpl, TSuccessorSuccessor { + final override string toString() { result = "successor" } +} + +/** A conditional control flow successor. */ +abstract private class ConditionalSuccessor extends SuccessorTypeImpl { + boolean value; + + bindingset[value] + ConditionalSuccessor() { any() } + + /** Gets the Boolean value of this successor. */ + final boolean getValue() { result = value } + + override string toString() { result = this.getValue().toString() } +} + +/** A Boolean control flow successor. */ +final class BooleanSuccessor extends ConditionalSuccessor, TBooleanSuccessor { + BooleanSuccessor() { this = TBooleanSuccessor(value) } +} + +/** + * A `return` control flow successor. + */ +final class ReturnSuccessor extends SuccessorTypeImpl, TReturnSuccessor { + final override string toString() { result = "return" } +} diff --git a/rust/ql/lib/codeql/rust/elements.qll b/rust/ql/lib/codeql/rust/elements.qll new file mode 100644 index 000000000000..efb06ae9eea2 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements.qll @@ -0,0 +1,81 @@ +// generated by codegen +/** + * This module exports all modules providing `Element` subclasses. + */ + +import codeql.rust.elements.ArrayExpr +import codeql.rust.elements.AstNode +import codeql.rust.elements.AsyncBlockExpr +import codeql.rust.elements.AwaitExpr +import codeql.rust.elements.BecomeExpr +import codeql.rust.elements.BinaryOpExpr +import codeql.rust.elements.BindPat +import codeql.rust.elements.BlockExpr +import codeql.rust.elements.BlockExprBase +import codeql.rust.elements.BoxExpr +import codeql.rust.elements.BoxPat +import codeql.rust.elements.BreakExpr +import codeql.rust.elements.CallExpr +import codeql.rust.elements.CastExpr +import codeql.rust.elements.ClosureExpr +import codeql.rust.elements.ConstBlockPat +import codeql.rust.elements.ConstExpr +import codeql.rust.elements.ContinueExpr +import codeql.rust.elements.DbFile +import codeql.rust.elements.DbLocation +import codeql.rust.elements.Declaration +import codeql.rust.elements.Element +import codeql.rust.elements.ElementListExpr +import codeql.rust.elements.Expr +import codeql.rust.elements.ExprStmt +import codeql.rust.elements.FieldExpr +import codeql.rust.elements.File +import codeql.rust.elements.Function +import codeql.rust.elements.IfExpr +import codeql.rust.elements.IndexExpr +import codeql.rust.elements.InlineAsmExpr +import codeql.rust.elements.ItemStmt +import codeql.rust.elements.Label +import codeql.rust.elements.LetExpr +import codeql.rust.elements.LetStmt +import codeql.rust.elements.LitPat +import codeql.rust.elements.LiteralExpr +import codeql.rust.elements.Locatable +import codeql.rust.elements.Location +import codeql.rust.elements.LoopExpr +import codeql.rust.elements.MatchArm +import codeql.rust.elements.MatchExpr +import codeql.rust.elements.MethodCallExpr +import codeql.rust.elements.MissingExpr +import codeql.rust.elements.MissingPat +import codeql.rust.elements.Module +import codeql.rust.elements.OffsetOfExpr +import codeql.rust.elements.OrPat +import codeql.rust.elements.Pat +import codeql.rust.elements.PathExpr +import codeql.rust.elements.PathPat +import codeql.rust.elements.RangeExpr +import codeql.rust.elements.RangePat +import codeql.rust.elements.RecordFieldPat +import codeql.rust.elements.RecordLitExpr +import codeql.rust.elements.RecordLitField +import codeql.rust.elements.RecordPat +import codeql.rust.elements.RefExpr +import codeql.rust.elements.RefPat +import codeql.rust.elements.RepeatExpr +import codeql.rust.elements.ReturnExpr +import codeql.rust.elements.SlicePat +import codeql.rust.elements.Stmt +import codeql.rust.elements.TupleExpr +import codeql.rust.elements.TuplePat +import codeql.rust.elements.TupleStructPat +import codeql.rust.elements.TypeRef +import codeql.rust.elements.UnaryOpExpr +import codeql.rust.elements.UnderscoreExpr +import codeql.rust.elements.Unimplemented +import codeql.rust.elements.UnknownFile +import codeql.rust.elements.UnknownLocation +import codeql.rust.elements.UnsafeBlockExpr +import codeql.rust.elements.WildPat +import codeql.rust.elements.YeetExpr +import codeql.rust.elements.YieldExpr diff --git a/rust/ql/lib/codeql/rust/elements/ArrayExpr.qll b/rust/ql/lib/codeql/rust/elements/ArrayExpr.qll new file mode 100644 index 000000000000..b0328ef9382b --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ArrayExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `ArrayExpr`. + */ + +private import codeql.rust.generated.ArrayExpr + +class ArrayExpr extends Generated::ArrayExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/AstNode.qll b/rust/ql/lib/codeql/rust/elements/AstNode.qll new file mode 100644 index 000000000000..f1edc4ac4932 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/AstNode.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `AstNode`. + */ + +private import codeql.rust.generated.AstNode + +class AstNode extends Generated::AstNode { } diff --git a/rust/ql/lib/codeql/rust/elements/AsyncBlockExpr.qll b/rust/ql/lib/codeql/rust/elements/AsyncBlockExpr.qll new file mode 100644 index 000000000000..e024eec6e920 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/AsyncBlockExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `AsyncBlockExpr`. + */ + +private import codeql.rust.generated.AsyncBlockExpr + +class AsyncBlockExpr extends Generated::AsyncBlockExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/AsyncBlockExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/AsyncBlockExprConstructor.qll new file mode 100644 index 000000000000..4339f499243c --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/AsyncBlockExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `AsyncBlockExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `AsyncBlockExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructAsyncBlockExpr(Raw::AsyncBlockExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/AwaitExpr.qll b/rust/ql/lib/codeql/rust/elements/AwaitExpr.qll new file mode 100644 index 000000000000..420be7dc8408 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/AwaitExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `AwaitExpr`. + */ + +private import codeql.rust.generated.AwaitExpr + +class AwaitExpr extends Generated::AwaitExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/AwaitExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/AwaitExprConstructor.qll new file mode 100644 index 000000000000..5bc5cca84f57 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/AwaitExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `AwaitExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `AwaitExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructAwaitExpr(Raw::AwaitExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/BecomeExpr.qll b/rust/ql/lib/codeql/rust/elements/BecomeExpr.qll new file mode 100644 index 000000000000..6893087ec0e4 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/BecomeExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `BecomeExpr`. + */ + +private import codeql.rust.generated.BecomeExpr + +class BecomeExpr extends Generated::BecomeExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/BecomeExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/BecomeExprConstructor.qll new file mode 100644 index 000000000000..768ed85d97ed --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/BecomeExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `BecomeExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `BecomeExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructBecomeExpr(Raw::BecomeExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/BinaryOpExpr.qll b/rust/ql/lib/codeql/rust/elements/BinaryOpExpr.qll new file mode 100644 index 000000000000..e5de5d9aa453 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/BinaryOpExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `BinaryOpExpr`. + */ + +private import codeql.rust.generated.BinaryOpExpr + +class BinaryOpExpr extends Generated::BinaryOpExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/BinaryOpExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/BinaryOpExprConstructor.qll new file mode 100644 index 000000000000..757b2f42e300 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/BinaryOpExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `BinaryOpExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `BinaryOpExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructBinaryOpExpr(Raw::BinaryOpExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/BindPat.qll b/rust/ql/lib/codeql/rust/elements/BindPat.qll new file mode 100644 index 000000000000..eb0d2b00448e --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/BindPat.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `BindPat`. + */ + +private import codeql.rust.generated.BindPat + +class BindPat extends Generated::BindPat { } diff --git a/rust/ql/lib/codeql/rust/elements/BindPatConstructor.qll b/rust/ql/lib/codeql/rust/elements/BindPatConstructor.qll new file mode 100644 index 000000000000..80445356bf0d --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/BindPatConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `BindPat` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `BindPat` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructBindPat(Raw::BindPat id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/BlockExpr.qll b/rust/ql/lib/codeql/rust/elements/BlockExpr.qll new file mode 100644 index 000000000000..0ba5e1a2eb8d --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/BlockExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `BlockExpr`. + */ + +private import codeql.rust.generated.BlockExpr + +class BlockExpr extends Generated::BlockExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/BlockExprBase.qll b/rust/ql/lib/codeql/rust/elements/BlockExprBase.qll new file mode 100644 index 000000000000..cf0236709b38 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/BlockExprBase.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `BlockExprBase`. + */ + +private import codeql.rust.generated.BlockExprBase + +class BlockExprBase extends Generated::BlockExprBase { } diff --git a/rust/ql/lib/codeql/rust/elements/BlockExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/BlockExprConstructor.qll new file mode 100644 index 000000000000..5db5b56c31f3 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/BlockExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `BlockExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `BlockExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructBlockExpr(Raw::BlockExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/BoxExpr.qll b/rust/ql/lib/codeql/rust/elements/BoxExpr.qll new file mode 100644 index 000000000000..1525f7796f58 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/BoxExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `BoxExpr`. + */ + +private import codeql.rust.generated.BoxExpr + +class BoxExpr extends Generated::BoxExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/BoxExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/BoxExprConstructor.qll new file mode 100644 index 000000000000..647127a347eb --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/BoxExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `BoxExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `BoxExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructBoxExpr(Raw::BoxExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/BoxPat.qll b/rust/ql/lib/codeql/rust/elements/BoxPat.qll new file mode 100644 index 000000000000..e2b1d9b7e779 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/BoxPat.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `BoxPat`. + */ + +private import codeql.rust.generated.BoxPat + +class BoxPat extends Generated::BoxPat { } diff --git a/rust/ql/lib/codeql/rust/elements/BoxPatConstructor.qll b/rust/ql/lib/codeql/rust/elements/BoxPatConstructor.qll new file mode 100644 index 000000000000..bcabb8c51660 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/BoxPatConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `BoxPat` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `BoxPat` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructBoxPat(Raw::BoxPat id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/BreakExpr.qll b/rust/ql/lib/codeql/rust/elements/BreakExpr.qll new file mode 100644 index 000000000000..cd98d7003a05 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/BreakExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `BreakExpr`. + */ + +private import codeql.rust.generated.BreakExpr + +class BreakExpr extends Generated::BreakExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/BreakExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/BreakExprConstructor.qll new file mode 100644 index 000000000000..88b661285669 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/BreakExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `BreakExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `BreakExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructBreakExpr(Raw::BreakExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/CallExpr.qll b/rust/ql/lib/codeql/rust/elements/CallExpr.qll new file mode 100644 index 000000000000..ee14b172e50c --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/CallExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `CallExpr`. + */ + +private import codeql.rust.generated.CallExpr + +class CallExpr extends Generated::CallExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/CallExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/CallExprConstructor.qll new file mode 100644 index 000000000000..b399667d9ce9 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/CallExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `CallExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `CallExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructCallExpr(Raw::CallExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/CastExpr.qll b/rust/ql/lib/codeql/rust/elements/CastExpr.qll new file mode 100644 index 000000000000..3b7b41955cd8 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/CastExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `CastExpr`. + */ + +private import codeql.rust.generated.CastExpr + +class CastExpr extends Generated::CastExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/CastExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/CastExprConstructor.qll new file mode 100644 index 000000000000..e67f17213889 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/CastExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `CastExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `CastExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructCastExpr(Raw::CastExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/ClosureExpr.qll b/rust/ql/lib/codeql/rust/elements/ClosureExpr.qll new file mode 100644 index 000000000000..661d98ce1b27 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ClosureExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `ClosureExpr`. + */ + +private import codeql.rust.generated.ClosureExpr + +class ClosureExpr extends Generated::ClosureExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/ClosureExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/ClosureExprConstructor.qll new file mode 100644 index 000000000000..f03e50649df0 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ClosureExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `ClosureExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `ClosureExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructClosureExpr(Raw::ClosureExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/ConstBlockPat.qll b/rust/ql/lib/codeql/rust/elements/ConstBlockPat.qll new file mode 100644 index 000000000000..80b48ac034e8 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ConstBlockPat.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `ConstBlockPat`. + */ + +private import codeql.rust.generated.ConstBlockPat + +class ConstBlockPat extends Generated::ConstBlockPat { } diff --git a/rust/ql/lib/codeql/rust/elements/ConstBlockPatConstructor.qll b/rust/ql/lib/codeql/rust/elements/ConstBlockPatConstructor.qll new file mode 100644 index 000000000000..84bbb6d598ec --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ConstBlockPatConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `ConstBlockPat` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `ConstBlockPat` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructConstBlockPat(Raw::ConstBlockPat id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/ConstExpr.qll b/rust/ql/lib/codeql/rust/elements/ConstExpr.qll new file mode 100644 index 000000000000..375e7dcc7fda --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ConstExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `ConstExpr`. + */ + +private import codeql.rust.generated.ConstExpr + +class ConstExpr extends Generated::ConstExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/ConstExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/ConstExprConstructor.qll new file mode 100644 index 000000000000..e6ab5baf27f4 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ConstExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `ConstExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `ConstExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructConstExpr(Raw::ConstExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/ContinueExpr.qll b/rust/ql/lib/codeql/rust/elements/ContinueExpr.qll new file mode 100644 index 000000000000..f23879671e33 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ContinueExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `ContinueExpr`. + */ + +private import codeql.rust.generated.ContinueExpr + +class ContinueExpr extends Generated::ContinueExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/ContinueExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/ContinueExprConstructor.qll new file mode 100644 index 000000000000..162e7de02394 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ContinueExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `ContinueExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `ContinueExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructContinueExpr(Raw::ContinueExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/DbFile.qll b/rust/ql/lib/codeql/rust/elements/DbFile.qll new file mode 100644 index 000000000000..d1659d5206dd --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/DbFile.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `DbFile`. + */ + +private import codeql.rust.generated.DbFile + +class DbFile extends Generated::DbFile { } diff --git a/rust/ql/lib/codeql/rust/elements/DbFileConstructor.qll b/rust/ql/lib/codeql/rust/elements/DbFileConstructor.qll new file mode 100644 index 000000000000..974a4f8ceefe --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/DbFileConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `DbFile` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `DbFile` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructDbFile(Raw::DbFile id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/DbLocation.qll b/rust/ql/lib/codeql/rust/elements/DbLocation.qll new file mode 100644 index 000000000000..727e4e8790f6 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/DbLocation.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `DbLocation`. + */ + +private import codeql.rust.generated.DbLocation + +class DbLocation extends Generated::DbLocation { } diff --git a/rust/ql/lib/codeql/rust/elements/DbLocationConstructor.qll b/rust/ql/lib/codeql/rust/elements/DbLocationConstructor.qll new file mode 100644 index 000000000000..af8518a06d21 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/DbLocationConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `DbLocation` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `DbLocation` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructDbLocation(Raw::DbLocation id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/Declaration.qll b/rust/ql/lib/codeql/rust/elements/Declaration.qll new file mode 100644 index 000000000000..b4e0971d591e --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/Declaration.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `Declaration`. + */ + +private import codeql.rust.generated.Declaration + +class Declaration extends Generated::Declaration { } diff --git a/rust/ql/lib/codeql/rust/elements/Element.qll b/rust/ql/lib/codeql/rust/elements/Element.qll new file mode 100644 index 000000000000..9c1f18767482 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/Element.qll @@ -0,0 +1,11 @@ +/** + * This module provides a hand-modifiable wrapper around the generated class `Element`. + */ + +private import codeql.rust.generated.Element + +class Element extends Generated::Element { + override string toString() { result = this.getAPrimaryQlClass() } + + predicate isUnknown() { none() } // compatibility with test generation, to be fixed +} diff --git a/rust/ql/lib/codeql/rust/elements/ElementListExpr.qll b/rust/ql/lib/codeql/rust/elements/ElementListExpr.qll new file mode 100644 index 000000000000..7513353fce3d --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ElementListExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `ElementListExpr`. + */ + +private import codeql.rust.generated.ElementListExpr + +class ElementListExpr extends Generated::ElementListExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/ElementListExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/ElementListExprConstructor.qll new file mode 100644 index 000000000000..aeafb10646f2 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ElementListExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `ElementListExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `ElementListExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructElementListExpr(Raw::ElementListExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/Expr.qll b/rust/ql/lib/codeql/rust/elements/Expr.qll new file mode 100644 index 000000000000..40a7beac2499 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/Expr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `Expr`. + */ + +private import codeql.rust.generated.Expr + +class Expr extends Generated::Expr { } diff --git a/rust/ql/lib/codeql/rust/elements/ExprStmt.qll b/rust/ql/lib/codeql/rust/elements/ExprStmt.qll new file mode 100644 index 000000000000..0ec9cdbc813d --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ExprStmt.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `ExprStmt`. + */ + +private import codeql.rust.generated.ExprStmt + +class ExprStmt extends Generated::ExprStmt { } diff --git a/rust/ql/lib/codeql/rust/elements/ExprStmtConstructor.qll b/rust/ql/lib/codeql/rust/elements/ExprStmtConstructor.qll new file mode 100644 index 000000000000..5493b1ccad4a --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ExprStmtConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `ExprStmt` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `ExprStmt` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructExprStmt(Raw::ExprStmt id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/FieldExpr.qll b/rust/ql/lib/codeql/rust/elements/FieldExpr.qll new file mode 100644 index 000000000000..656bd807afdb --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/FieldExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `FieldExpr`. + */ + +private import codeql.rust.generated.FieldExpr + +class FieldExpr extends Generated::FieldExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/FieldExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/FieldExprConstructor.qll new file mode 100644 index 000000000000..aff014159d36 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/FieldExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `FieldExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `FieldExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructFieldExpr(Raw::FieldExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/File.qll b/rust/ql/lib/codeql/rust/elements/File.qll new file mode 100644 index 000000000000..f9d2e62017fe --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/File.qll @@ -0,0 +1,111 @@ +/** + * This module provides a hand-modifiable wrapper around the generated class `File`. + */ + +private import codeql.rust.generated.File +private import codeql.rust.elements.Location +private import codeql.rust.elements.UnknownLocation + +class File extends Generated::File { + /** toString */ + override string toString() { result = this.getAbsolutePath() } + + /** Gets the absolute path of this file. */ + string getAbsolutePath() { result = this.getName() } + + /** Gets the full name of this file. */ + string getFullName() { result = this.getAbsolutePath() } + + /** Gets the URL of this file. */ + string getURL() { result = "file://" + this.getAbsolutePath() + ":0:0:0:0" } + + /** + * Holds if either, + * - `part` is the base name of this container and `i = 1`, or + * - `part` is the stem of this container and `i = 2`, or + * - `part` is the extension of this container and `i = 3`. + */ + cached + private predicate splitAbsolutePath(string part, int i) { + part = this.getAbsolutePath().regexpCapture(".*/(([^/]*?)(?:\\.([^.]*))?)", i) + } + + /** Gets the base name of this file. */ + string getBaseName() { this.splitAbsolutePath(result, 1) } + + /** + * Gets the extension of this container, that is, the suffix of its base name + * after the last dot character, if any. + * + * In particular, + * + * - if the name does not include a dot, there is no extension, so this + * predicate has no result; + * - if the name ends in a dot, the extension is the empty string; + * - if the name contains multiple dots, the extension follows the last dot. + * + * Here are some examples of absolute paths and the corresponding extensions + * (surrounded with quotes to avoid ambiguity): + * + * + * + * + * + * + * + * + *
Absolute pathExtension
"/tmp/tst.txt""txt"
"/tmp/.classpath""classpath"
"/bin/bash"not defined
"/tmp/tst2."""
"/tmp/x.tar.gz""gz"
+ */ + string getExtension() { this.splitAbsolutePath(result, 3) } + + /** + * Gets the stem of this container, that is, the prefix of its base name up to + * (but not including) the last dot character if there is one, or the entire + * base name if there is not. + * + * Here are some examples of absolute paths and the corresponding stems + * (surrounded with quotes to avoid ambiguity): + * + * + * + * + * + * + * + * + *
Absolute pathStem
"/tmp/tst.txt""tst"
"/tmp/.classpath"""
"/bin/bash""bash"
"/tmp/tst2.""tst2"
"/tmp/x.tar.gz""x.tar"
+ */ + string getStem() { this.splitAbsolutePath(result, 2) } + + /** + * Gets the number of lines containing code in this file. This value + * is approximate. + */ + int getNumberOfLinesOfCode() { + result = + count(int line | + exists(Location loc | + not loc instanceof UnknownLocation and loc.getFile() = this and loc.getStartLine() = line + ) + ) + } + + /** + * Gets the relative path of this file from the root folder of the + * analyzed source location. The relative path of the root folder itself + * would be the empty string. + * + * This has no result if the file is outside the source root, that is, + * if the root folder is not a reflexive, transitive parent of this file. + */ + string getRelativePath() { + exists(string absPath, string pref | + absPath = this.getAbsolutePath() and sourceLocationPrefix(pref) + | + absPath = pref and result = "" + or + absPath = pref.regexpReplaceAll("/$", "") + "/" + result and + not result.matches("/%") + ) + } +} diff --git a/rust/ql/lib/codeql/rust/elements/Function.qll b/rust/ql/lib/codeql/rust/elements/Function.qll new file mode 100644 index 000000000000..23531c2bbd1f --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/Function.qll @@ -0,0 +1,22 @@ +/** + * This module provides a hand-modifiable wrapper around the generated class `Function`. + */ + +private import codeql.rust.generated.Function + +// the following QLdoc is generated: if you need to edit it, do it in the schema file +/** + * A function declaration. For example + * ``` + * fn foo(x: u32) -> u64 { (x + 1).into() } + * ``` + * A function declaration within a trait might not have a body: + * ``` + * trait Trait { + * fn bar(); + * } + * ``` + */ +class Function extends Generated::Function { + override string toString() { result = this.getName() } +} diff --git a/rust/ql/lib/codeql/rust/elements/FunctionConstructor.qll b/rust/ql/lib/codeql/rust/elements/FunctionConstructor.qll new file mode 100644 index 000000000000..706a72d58ab0 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/FunctionConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `Function` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `Function` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructFunction(Raw::Function id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/IfExpr.qll b/rust/ql/lib/codeql/rust/elements/IfExpr.qll new file mode 100644 index 000000000000..c1500f592c07 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/IfExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `IfExpr`. + */ + +private import codeql.rust.generated.IfExpr + +class IfExpr extends Generated::IfExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/IfExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/IfExprConstructor.qll new file mode 100644 index 000000000000..b3331aeefc10 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/IfExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `IfExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `IfExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructIfExpr(Raw::IfExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/IndexExpr.qll b/rust/ql/lib/codeql/rust/elements/IndexExpr.qll new file mode 100644 index 000000000000..fde06bd4d916 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/IndexExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `IndexExpr`. + */ + +private import codeql.rust.generated.IndexExpr + +class IndexExpr extends Generated::IndexExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/IndexExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/IndexExprConstructor.qll new file mode 100644 index 000000000000..f7e43e91e744 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/IndexExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `IndexExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `IndexExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructIndexExpr(Raw::IndexExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/InlineAsmExpr.qll b/rust/ql/lib/codeql/rust/elements/InlineAsmExpr.qll new file mode 100644 index 000000000000..b89e49e3af36 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/InlineAsmExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `InlineAsmExpr`. + */ + +private import codeql.rust.generated.InlineAsmExpr + +class InlineAsmExpr extends Generated::InlineAsmExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/InlineAsmExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/InlineAsmExprConstructor.qll new file mode 100644 index 000000000000..9cf7d34d2467 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/InlineAsmExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `InlineAsmExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `InlineAsmExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructInlineAsmExpr(Raw::InlineAsmExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/ItemStmt.qll b/rust/ql/lib/codeql/rust/elements/ItemStmt.qll new file mode 100644 index 000000000000..de2a1b22f758 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ItemStmt.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `ItemStmt`. + */ + +private import codeql.rust.generated.ItemStmt + +class ItemStmt extends Generated::ItemStmt { } diff --git a/rust/ql/lib/codeql/rust/elements/ItemStmtConstructor.qll b/rust/ql/lib/codeql/rust/elements/ItemStmtConstructor.qll new file mode 100644 index 000000000000..1efff36b8040 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ItemStmtConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `ItemStmt` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `ItemStmt` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructItemStmt(Raw::ItemStmt id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/Label.qll b/rust/ql/lib/codeql/rust/elements/Label.qll new file mode 100644 index 000000000000..20a006754e9f --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/Label.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `Label`. + */ + +private import codeql.rust.generated.Label + +class Label extends Generated::Label { } diff --git a/rust/ql/lib/codeql/rust/elements/LabelConstructor.qll b/rust/ql/lib/codeql/rust/elements/LabelConstructor.qll new file mode 100644 index 000000000000..0d82f1eb1c91 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/LabelConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `Label` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `Label` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructLabel(Raw::Label id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/LetExpr.qll b/rust/ql/lib/codeql/rust/elements/LetExpr.qll new file mode 100644 index 000000000000..78862471d1bc --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/LetExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `LetExpr`. + */ + +private import codeql.rust.generated.LetExpr + +class LetExpr extends Generated::LetExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/LetExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/LetExprConstructor.qll new file mode 100644 index 000000000000..d64e839fb7f3 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/LetExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `LetExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `LetExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructLetExpr(Raw::LetExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/LetStmt.qll b/rust/ql/lib/codeql/rust/elements/LetStmt.qll new file mode 100644 index 000000000000..f01b81ceb305 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/LetStmt.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `LetStmt`. + */ + +private import codeql.rust.generated.LetStmt + +class LetStmt extends Generated::LetStmt { } diff --git a/rust/ql/lib/codeql/rust/elements/LetStmtConstructor.qll b/rust/ql/lib/codeql/rust/elements/LetStmtConstructor.qll new file mode 100644 index 000000000000..0813b339d0c7 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/LetStmtConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `LetStmt` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `LetStmt` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructLetStmt(Raw::LetStmt id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/LitPat.qll b/rust/ql/lib/codeql/rust/elements/LitPat.qll new file mode 100644 index 000000000000..0e8ac98c70d0 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/LitPat.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `LitPat`. + */ + +private import codeql.rust.generated.LitPat + +class LitPat extends Generated::LitPat { } diff --git a/rust/ql/lib/codeql/rust/elements/LitPatConstructor.qll b/rust/ql/lib/codeql/rust/elements/LitPatConstructor.qll new file mode 100644 index 000000000000..a72498ba0978 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/LitPatConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `LitPat` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `LitPat` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructLitPat(Raw::LitPat id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/LiteralExpr.qll b/rust/ql/lib/codeql/rust/elements/LiteralExpr.qll new file mode 100644 index 000000000000..d6f928693580 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/LiteralExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `LiteralExpr`. + */ + +private import codeql.rust.generated.LiteralExpr + +class LiteralExpr extends Generated::LiteralExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/LiteralExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/LiteralExprConstructor.qll new file mode 100644 index 000000000000..9363a2f628b9 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/LiteralExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `LiteralExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `LiteralExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructLiteralExpr(Raw::LiteralExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/Locatable.qll b/rust/ql/lib/codeql/rust/elements/Locatable.qll new file mode 100644 index 000000000000..f6df70bb0899 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/Locatable.qll @@ -0,0 +1,22 @@ +/** + * This module provides a hand-modifiable wrapper around the generated class `Locatable`. + */ + +private import codeql.rust.generated.Locatable +private import codeql.rust.elements.File +private import codeql.rust.elements.UnknownLocation + +class Locatable extends Generated::Locatable { + pragma[nomagic] + override Location getLocation() { + result = Generated::Locatable.super.getLocation() + or + not exists(Generated::Locatable.super.getLocation()) and + result instanceof UnknownLocation + } + + /** + * Gets the primary file where this element occurs. + */ + File getFile() { result = this.getLocation().getFile() } +} diff --git a/rust/ql/lib/codeql/rust/elements/Location.qll b/rust/ql/lib/codeql/rust/elements/Location.qll new file mode 100644 index 000000000000..a433422337d2 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/Location.qll @@ -0,0 +1,29 @@ +/** + * This module provides a hand-modifiable wrapper around the generated class `Location`. + */ + +private import codeql.rust.generated.Location + +class Location extends Generated::Location { + /** + * Holds if this location is described by `path`, `startLine`, `startColumn`, `endLine` and `endColumn`. + */ + predicate hasLocationInfo(string path, int startLine, int startColumn, int endLine, int endColumn) { + path = this.getFile().getFullName() and + startLine = this.getStartLine() and + startColumn = this.getStartColumn() and + endLine = this.getEndLine() and + endColumn = this.getEndColumn() + } + + /** + * Gets a textual representation of this location. + */ + override string toString() { + exists(string filePath, int startLine, int startColumn, int endLine, int endColumn | + this.hasLocationInfo(filePath, startLine, startColumn, endLine, endColumn) + | + toUrl(filePath, startLine, startColumn, endLine, endColumn, result) + ) + } +} diff --git a/rust/ql/lib/codeql/rust/elements/LoopExpr.qll b/rust/ql/lib/codeql/rust/elements/LoopExpr.qll new file mode 100644 index 000000000000..6f08d6648a21 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/LoopExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `LoopExpr`. + */ + +private import codeql.rust.generated.LoopExpr + +class LoopExpr extends Generated::LoopExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/LoopExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/LoopExprConstructor.qll new file mode 100644 index 000000000000..b0336e87ee4c --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/LoopExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `LoopExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `LoopExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructLoopExpr(Raw::LoopExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/MatchArm.qll b/rust/ql/lib/codeql/rust/elements/MatchArm.qll new file mode 100644 index 000000000000..914d70d35583 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/MatchArm.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `MatchArm`. + */ + +private import codeql.rust.generated.MatchArm + +class MatchArm extends Generated::MatchArm { } diff --git a/rust/ql/lib/codeql/rust/elements/MatchArmConstructor.qll b/rust/ql/lib/codeql/rust/elements/MatchArmConstructor.qll new file mode 100644 index 000000000000..3319e55fcd67 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/MatchArmConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `MatchArm` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `MatchArm` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructMatchArm(Raw::MatchArm id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/MatchExpr.qll b/rust/ql/lib/codeql/rust/elements/MatchExpr.qll new file mode 100644 index 000000000000..fcb352bc2b44 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/MatchExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `MatchExpr`. + */ + +private import codeql.rust.generated.MatchExpr + +class MatchExpr extends Generated::MatchExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/MatchExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/MatchExprConstructor.qll new file mode 100644 index 000000000000..920d7aae78df --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/MatchExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `MatchExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `MatchExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructMatchExpr(Raw::MatchExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/MethodCallExpr.qll b/rust/ql/lib/codeql/rust/elements/MethodCallExpr.qll new file mode 100644 index 000000000000..855035925c3b --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/MethodCallExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `MethodCallExpr`. + */ + +private import codeql.rust.generated.MethodCallExpr + +class MethodCallExpr extends Generated::MethodCallExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/MethodCallExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/MethodCallExprConstructor.qll new file mode 100644 index 000000000000..4279a7a81d02 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/MethodCallExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `MethodCallExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `MethodCallExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructMethodCallExpr(Raw::MethodCallExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/MissingExpr.qll b/rust/ql/lib/codeql/rust/elements/MissingExpr.qll new file mode 100644 index 000000000000..3ee2f3a6e4e8 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/MissingExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `MissingExpr`. + */ + +private import codeql.rust.generated.MissingExpr + +class MissingExpr extends Generated::MissingExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/MissingExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/MissingExprConstructor.qll new file mode 100644 index 000000000000..0cf8e7ff97ee --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/MissingExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `MissingExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `MissingExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructMissingExpr(Raw::MissingExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/MissingPat.qll b/rust/ql/lib/codeql/rust/elements/MissingPat.qll new file mode 100644 index 000000000000..88db4cdc7794 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/MissingPat.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `MissingPat`. + */ + +private import codeql.rust.generated.MissingPat + +class MissingPat extends Generated::MissingPat { } diff --git a/rust/ql/lib/codeql/rust/elements/MissingPatConstructor.qll b/rust/ql/lib/codeql/rust/elements/MissingPatConstructor.qll new file mode 100644 index 000000000000..6c6ed58ec27d --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/MissingPatConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `MissingPat` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `MissingPat` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructMissingPat(Raw::MissingPat id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/Module.qll b/rust/ql/lib/codeql/rust/elements/Module.qll new file mode 100644 index 000000000000..a001bb4edb8a --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/Module.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `Module`. + */ + +private import codeql.rust.generated.Module + +class Module extends Generated::Module { } diff --git a/rust/ql/lib/codeql/rust/elements/ModuleConstructor.qll b/rust/ql/lib/codeql/rust/elements/ModuleConstructor.qll new file mode 100644 index 000000000000..eb6258f95dcd --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ModuleConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `Module` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `Module` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructModule(Raw::Module id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/OffsetOfExpr.qll b/rust/ql/lib/codeql/rust/elements/OffsetOfExpr.qll new file mode 100644 index 000000000000..88097b2c34a6 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/OffsetOfExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `OffsetOfExpr`. + */ + +private import codeql.rust.generated.OffsetOfExpr + +class OffsetOfExpr extends Generated::OffsetOfExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/OffsetOfExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/OffsetOfExprConstructor.qll new file mode 100644 index 000000000000..c50f961f0b53 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/OffsetOfExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `OffsetOfExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `OffsetOfExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructOffsetOfExpr(Raw::OffsetOfExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/OrPat.qll b/rust/ql/lib/codeql/rust/elements/OrPat.qll new file mode 100644 index 000000000000..797060365a4e --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/OrPat.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `OrPat`. + */ + +private import codeql.rust.generated.OrPat + +class OrPat extends Generated::OrPat { } diff --git a/rust/ql/lib/codeql/rust/elements/OrPatConstructor.qll b/rust/ql/lib/codeql/rust/elements/OrPatConstructor.qll new file mode 100644 index 000000000000..1bb95e89cbdf --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/OrPatConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `OrPat` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `OrPat` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructOrPat(Raw::OrPat id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/Pat.qll b/rust/ql/lib/codeql/rust/elements/Pat.qll new file mode 100644 index 000000000000..7e3c032c05b5 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/Pat.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `Pat`. + */ + +private import codeql.rust.generated.Pat + +class Pat extends Generated::Pat { } diff --git a/rust/ql/lib/codeql/rust/elements/PathExpr.qll b/rust/ql/lib/codeql/rust/elements/PathExpr.qll new file mode 100644 index 000000000000..237ca6b71f1f --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/PathExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `PathExpr`. + */ + +private import codeql.rust.generated.PathExpr + +class PathExpr extends Generated::PathExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/PathExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/PathExprConstructor.qll new file mode 100644 index 000000000000..21adc61c62e5 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/PathExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `PathExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `PathExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructPathExpr(Raw::PathExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/PathPat.qll b/rust/ql/lib/codeql/rust/elements/PathPat.qll new file mode 100644 index 000000000000..92d794c658a7 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/PathPat.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `PathPat`. + */ + +private import codeql.rust.generated.PathPat + +class PathPat extends Generated::PathPat { } diff --git a/rust/ql/lib/codeql/rust/elements/PathPatConstructor.qll b/rust/ql/lib/codeql/rust/elements/PathPatConstructor.qll new file mode 100644 index 000000000000..6d5d2f566277 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/PathPatConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `PathPat` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `PathPat` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructPathPat(Raw::PathPat id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/RangeExpr.qll b/rust/ql/lib/codeql/rust/elements/RangeExpr.qll new file mode 100644 index 000000000000..67cd4b107217 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RangeExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `RangeExpr`. + */ + +private import codeql.rust.generated.RangeExpr + +class RangeExpr extends Generated::RangeExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/RangeExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/RangeExprConstructor.qll new file mode 100644 index 000000000000..2b5fd077a615 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RangeExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `RangeExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `RangeExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructRangeExpr(Raw::RangeExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/RangePat.qll b/rust/ql/lib/codeql/rust/elements/RangePat.qll new file mode 100644 index 000000000000..eeae9c8aec8b --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RangePat.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `RangePat`. + */ + +private import codeql.rust.generated.RangePat + +class RangePat extends Generated::RangePat { } diff --git a/rust/ql/lib/codeql/rust/elements/RangePatConstructor.qll b/rust/ql/lib/codeql/rust/elements/RangePatConstructor.qll new file mode 100644 index 000000000000..8b21ef73b3c4 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RangePatConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `RangePat` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `RangePat` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructRangePat(Raw::RangePat id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/RecordFieldPat.qll b/rust/ql/lib/codeql/rust/elements/RecordFieldPat.qll new file mode 100644 index 000000000000..2b892418c4fc --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RecordFieldPat.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `RecordFieldPat`. + */ + +private import codeql.rust.generated.RecordFieldPat + +class RecordFieldPat extends Generated::RecordFieldPat { } diff --git a/rust/ql/lib/codeql/rust/elements/RecordFieldPatConstructor.qll b/rust/ql/lib/codeql/rust/elements/RecordFieldPatConstructor.qll new file mode 100644 index 000000000000..4d0aa7f23279 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RecordFieldPatConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `RecordFieldPat` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `RecordFieldPat` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructRecordFieldPat(Raw::RecordFieldPat id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/RecordLitExpr.qll b/rust/ql/lib/codeql/rust/elements/RecordLitExpr.qll new file mode 100644 index 000000000000..87653911e1d0 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RecordLitExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `RecordLitExpr`. + */ + +private import codeql.rust.generated.RecordLitExpr + +class RecordLitExpr extends Generated::RecordLitExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/RecordLitExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/RecordLitExprConstructor.qll new file mode 100644 index 000000000000..f5d6c3d9fe30 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RecordLitExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `RecordLitExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `RecordLitExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructRecordLitExpr(Raw::RecordLitExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/RecordLitField.qll b/rust/ql/lib/codeql/rust/elements/RecordLitField.qll new file mode 100644 index 000000000000..1a30e1a1e91a --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RecordLitField.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `RecordLitField`. + */ + +private import codeql.rust.generated.RecordLitField + +class RecordLitField extends Generated::RecordLitField { } diff --git a/rust/ql/lib/codeql/rust/elements/RecordLitFieldConstructor.qll b/rust/ql/lib/codeql/rust/elements/RecordLitFieldConstructor.qll new file mode 100644 index 000000000000..537701fc7d5d --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RecordLitFieldConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `RecordLitField` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `RecordLitField` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructRecordLitField(Raw::RecordLitField id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/RecordPat.qll b/rust/ql/lib/codeql/rust/elements/RecordPat.qll new file mode 100644 index 000000000000..ac412f19d3d0 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RecordPat.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `RecordPat`. + */ + +private import codeql.rust.generated.RecordPat + +class RecordPat extends Generated::RecordPat { } diff --git a/rust/ql/lib/codeql/rust/elements/RecordPatConstructor.qll b/rust/ql/lib/codeql/rust/elements/RecordPatConstructor.qll new file mode 100644 index 000000000000..e52d3178b34d --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RecordPatConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `RecordPat` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `RecordPat` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructRecordPat(Raw::RecordPat id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/RefExpr.qll b/rust/ql/lib/codeql/rust/elements/RefExpr.qll new file mode 100644 index 000000000000..3916a8ad3bc9 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RefExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `RefExpr`. + */ + +private import codeql.rust.generated.RefExpr + +class RefExpr extends Generated::RefExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/RefExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/RefExprConstructor.qll new file mode 100644 index 000000000000..7b93739427ac --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RefExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `RefExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `RefExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructRefExpr(Raw::RefExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/RefPat.qll b/rust/ql/lib/codeql/rust/elements/RefPat.qll new file mode 100644 index 000000000000..3c9c59e88c5e --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RefPat.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `RefPat`. + */ + +private import codeql.rust.generated.RefPat + +class RefPat extends Generated::RefPat { } diff --git a/rust/ql/lib/codeql/rust/elements/RefPatConstructor.qll b/rust/ql/lib/codeql/rust/elements/RefPatConstructor.qll new file mode 100644 index 000000000000..095c9f64fc39 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RefPatConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `RefPat` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `RefPat` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructRefPat(Raw::RefPat id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/RepeatExpr.qll b/rust/ql/lib/codeql/rust/elements/RepeatExpr.qll new file mode 100644 index 000000000000..0f84446136b2 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RepeatExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `RepeatExpr`. + */ + +private import codeql.rust.generated.RepeatExpr + +class RepeatExpr extends Generated::RepeatExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/RepeatExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/RepeatExprConstructor.qll new file mode 100644 index 000000000000..7aa52b1e4a22 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/RepeatExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `RepeatExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `RepeatExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructRepeatExpr(Raw::RepeatExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/ReturnExpr.qll b/rust/ql/lib/codeql/rust/elements/ReturnExpr.qll new file mode 100644 index 000000000000..c8a26c595cd9 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ReturnExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `ReturnExpr`. + */ + +private import codeql.rust.generated.ReturnExpr + +class ReturnExpr extends Generated::ReturnExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/ReturnExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/ReturnExprConstructor.qll new file mode 100644 index 000000000000..f14613688d2a --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ReturnExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `ReturnExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `ReturnExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructReturnExpr(Raw::ReturnExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/SlicePat.qll b/rust/ql/lib/codeql/rust/elements/SlicePat.qll new file mode 100644 index 000000000000..d89f159a7a7b --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/SlicePat.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `SlicePat`. + */ + +private import codeql.rust.generated.SlicePat + +class SlicePat extends Generated::SlicePat { } diff --git a/rust/ql/lib/codeql/rust/elements/SlicePatConstructor.qll b/rust/ql/lib/codeql/rust/elements/SlicePatConstructor.qll new file mode 100644 index 000000000000..6953c3ca8b07 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/SlicePatConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `SlicePat` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `SlicePat` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructSlicePat(Raw::SlicePat id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/Stmt.qll b/rust/ql/lib/codeql/rust/elements/Stmt.qll new file mode 100644 index 000000000000..4b3bd89ea76f --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/Stmt.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `Stmt`. + */ + +private import codeql.rust.generated.Stmt + +class Stmt extends Generated::Stmt { } diff --git a/rust/ql/lib/codeql/rust/elements/TupleExpr.qll b/rust/ql/lib/codeql/rust/elements/TupleExpr.qll new file mode 100644 index 000000000000..b769d9532f65 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/TupleExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `TupleExpr`. + */ + +private import codeql.rust.generated.TupleExpr + +class TupleExpr extends Generated::TupleExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/TupleExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/TupleExprConstructor.qll new file mode 100644 index 000000000000..7c0499162e89 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/TupleExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `TupleExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `TupleExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructTupleExpr(Raw::TupleExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/TuplePat.qll b/rust/ql/lib/codeql/rust/elements/TuplePat.qll new file mode 100644 index 000000000000..f814215aec65 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/TuplePat.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `TuplePat`. + */ + +private import codeql.rust.generated.TuplePat + +class TuplePat extends Generated::TuplePat { } diff --git a/rust/ql/lib/codeql/rust/elements/TuplePatConstructor.qll b/rust/ql/lib/codeql/rust/elements/TuplePatConstructor.qll new file mode 100644 index 000000000000..40daddf318be --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/TuplePatConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `TuplePat` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `TuplePat` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructTuplePat(Raw::TuplePat id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/TupleStructPat.qll b/rust/ql/lib/codeql/rust/elements/TupleStructPat.qll new file mode 100644 index 000000000000..e4c4ffb24ec5 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/TupleStructPat.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `TupleStructPat`. + */ + +private import codeql.rust.generated.TupleStructPat + +class TupleStructPat extends Generated::TupleStructPat { } diff --git a/rust/ql/lib/codeql/rust/elements/TupleStructPatConstructor.qll b/rust/ql/lib/codeql/rust/elements/TupleStructPatConstructor.qll new file mode 100644 index 000000000000..0075d6eaf290 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/TupleStructPatConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `TupleStructPat` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `TupleStructPat` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructTupleStructPat(Raw::TupleStructPat id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/TypeRef.qll b/rust/ql/lib/codeql/rust/elements/TypeRef.qll new file mode 100644 index 000000000000..950ecbd9726a --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/TypeRef.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `TypeRef`. + */ + +private import codeql.rust.generated.TypeRef + +class TypeRef extends Generated::TypeRef { } diff --git a/rust/ql/lib/codeql/rust/elements/TypeRefConstructor.qll b/rust/ql/lib/codeql/rust/elements/TypeRefConstructor.qll new file mode 100644 index 000000000000..20b97fae70d2 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/TypeRefConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `TypeRef` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `TypeRef` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructTypeRef(Raw::TypeRef id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/UnaryOpExpr.qll b/rust/ql/lib/codeql/rust/elements/UnaryOpExpr.qll new file mode 100644 index 000000000000..b0b3608b0c78 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/UnaryOpExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `UnaryOpExpr`. + */ + +private import codeql.rust.generated.UnaryOpExpr + +class UnaryOpExpr extends Generated::UnaryOpExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/UnaryOpExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/UnaryOpExprConstructor.qll new file mode 100644 index 000000000000..bd155164de94 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/UnaryOpExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `UnaryOpExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `UnaryOpExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructUnaryOpExpr(Raw::UnaryOpExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/UnderscoreExpr.qll b/rust/ql/lib/codeql/rust/elements/UnderscoreExpr.qll new file mode 100644 index 000000000000..420d50244077 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/UnderscoreExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `UnderscoreExpr`. + */ + +private import codeql.rust.generated.UnderscoreExpr + +class UnderscoreExpr extends Generated::UnderscoreExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/UnderscoreExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/UnderscoreExprConstructor.qll new file mode 100644 index 000000000000..787db9662a55 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/UnderscoreExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `UnderscoreExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `UnderscoreExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructUnderscoreExpr(Raw::UnderscoreExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/Unimplemented.qll b/rust/ql/lib/codeql/rust/elements/Unimplemented.qll new file mode 100644 index 000000000000..272d9538a9c5 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/Unimplemented.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `Unimplemented`. + */ + +private import codeql.rust.generated.Unimplemented + +class Unimplemented extends Generated::Unimplemented { } diff --git a/rust/ql/lib/codeql/rust/elements/UnimplementedConstructor.qll b/rust/ql/lib/codeql/rust/elements/UnimplementedConstructor.qll new file mode 100644 index 000000000000..1216fd22ce58 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/UnimplementedConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `Unimplemented` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `Unimplemented` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructUnimplemented(Raw::Unimplemented id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/UnknownFile.qll b/rust/ql/lib/codeql/rust/elements/UnknownFile.qll new file mode 100644 index 000000000000..30c2ab8ba1c3 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/UnknownFile.qll @@ -0,0 +1,9 @@ +/** + * This module provides a hand-modifiable wrapper around the generated class `UnknownFile`. + */ + +private import codeql.rust.generated.UnknownFile + +class UnknownFile extends Generated::UnknownFile { + override string getName() { result = "" } +} diff --git a/rust/ql/lib/codeql/rust/elements/UnknownLocation.qll b/rust/ql/lib/codeql/rust/elements/UnknownLocation.qll new file mode 100644 index 000000000000..0374aa833b86 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/UnknownLocation.qll @@ -0,0 +1,21 @@ +/** + * This module provides a hand-modifiable wrapper around the generated class `UnknownLocation`. + */ + +private import codeql.rust.generated.UnknownLocation +private import codeql.rust.elements.File +private import codeql.rust.elements.UnknownFile + +class UnknownLocation extends Generated::UnknownLocation { + override File getFile() { result instanceof UnknownFile } + + override int getStartLine() { result = 0 } + + override int getStartColumn() { result = 0 } + + override int getEndLine() { result = 0 } + + override int getEndColumn() { result = 0 } + + override string toString() { result = "UnknownLocation" } +} diff --git a/rust/ql/lib/codeql/rust/elements/UnsafeBlockExpr.qll b/rust/ql/lib/codeql/rust/elements/UnsafeBlockExpr.qll new file mode 100644 index 000000000000..514cfeb0c97e --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/UnsafeBlockExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `UnsafeBlockExpr`. + */ + +private import codeql.rust.generated.UnsafeBlockExpr + +class UnsafeBlockExpr extends Generated::UnsafeBlockExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/UnsafeBlockExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/UnsafeBlockExprConstructor.qll new file mode 100644 index 000000000000..82050d3d73d6 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/UnsafeBlockExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `UnsafeBlockExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `UnsafeBlockExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructUnsafeBlockExpr(Raw::UnsafeBlockExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/WildPat.qll b/rust/ql/lib/codeql/rust/elements/WildPat.qll new file mode 100644 index 000000000000..346b61e8c2b0 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/WildPat.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `WildPat`. + */ + +private import codeql.rust.generated.WildPat + +class WildPat extends Generated::WildPat { } diff --git a/rust/ql/lib/codeql/rust/elements/WildPatConstructor.qll b/rust/ql/lib/codeql/rust/elements/WildPatConstructor.qll new file mode 100644 index 000000000000..13375a8d8aef --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/WildPatConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `WildPat` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `WildPat` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructWildPat(Raw::WildPat id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/YeetExpr.qll b/rust/ql/lib/codeql/rust/elements/YeetExpr.qll new file mode 100644 index 000000000000..8cab74bd9535 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/YeetExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `YeetExpr`. + */ + +private import codeql.rust.generated.YeetExpr + +class YeetExpr extends Generated::YeetExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/YeetExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/YeetExprConstructor.qll new file mode 100644 index 000000000000..7f83ccef7531 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/YeetExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `YeetExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `YeetExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructYeetExpr(Raw::YeetExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/YieldExpr.qll b/rust/ql/lib/codeql/rust/elements/YieldExpr.qll new file mode 100644 index 000000000000..f9aed8f7e1c1 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/YieldExpr.qll @@ -0,0 +1,8 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `YieldExpr`. + */ + +private import codeql.rust.generated.YieldExpr + +class YieldExpr extends Generated::YieldExpr { } diff --git a/rust/ql/lib/codeql/rust/elements/YieldExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/YieldExprConstructor.qll new file mode 100644 index 000000000000..c966a891b493 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/YieldExprConstructor.qll @@ -0,0 +1,14 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `YieldExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.generated.Raw + +/** + * The characteristic predicate of `YieldExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructYieldExpr(Raw::YieldExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/generated/ArrayExpr.qll b/rust/ql/lib/codeql/rust/generated/ArrayExpr.qll new file mode 100644 index 000000000000..50ec9dd97cad --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/ArrayExpr.qll @@ -0,0 +1,21 @@ +// generated by codegen +/** + * This module provides the generated definition of `ArrayExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `ArrayExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::ArrayExpr` class directly. + * Use the subclass `ArrayExpr`, where the following predicates are available. + */ + class ArrayExpr extends Synth::TArrayExpr, Expr { } +} diff --git a/rust/ql/lib/codeql/rust/generated/AstNode.qll b/rust/ql/lib/codeql/rust/generated/AstNode.qll new file mode 100644 index 000000000000..e4e922b64e2a --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/AstNode.qll @@ -0,0 +1,21 @@ +// generated by codegen +/** + * This module provides the generated definition of `AstNode`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Locatable + +/** + * INTERNAL: This module contains the fully generated definition of `AstNode` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::AstNode` class directly. + * Use the subclass `AstNode`, where the following predicates are available. + */ + class AstNode extends Synth::TAstNode, Locatable { } +} diff --git a/rust/ql/lib/codeql/rust/generated/AsyncBlockExpr.qll b/rust/ql/lib/codeql/rust/generated/AsyncBlockExpr.qll new file mode 100644 index 000000000000..17b7d1b630d6 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/AsyncBlockExpr.qll @@ -0,0 +1,23 @@ +// generated by codegen +/** + * This module provides the generated definition of `AsyncBlockExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.BlockExprBase + +/** + * INTERNAL: This module contains the fully generated definition of `AsyncBlockExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::AsyncBlockExpr` class directly. + * Use the subclass `AsyncBlockExpr`, where the following predicates are available. + */ + class AsyncBlockExpr extends Synth::TAsyncBlockExpr, BlockExprBase { + override string getAPrimaryQlClass() { result = "AsyncBlockExpr" } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/AwaitExpr.qll b/rust/ql/lib/codeql/rust/generated/AwaitExpr.qll new file mode 100644 index 000000000000..4c982b7c249e --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/AwaitExpr.qll @@ -0,0 +1,31 @@ +// generated by codegen +/** + * This module provides the generated definition of `AwaitExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `AwaitExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::AwaitExpr` class directly. + * Use the subclass `AwaitExpr`, where the following predicates are available. + */ + class AwaitExpr extends Synth::TAwaitExpr, Expr { + override string getAPrimaryQlClass() { result = "AwaitExpr" } + + /** + * Gets the expression of this await expression. + */ + Expr getExpr() { + result = + Synth::convertExprFromRaw(Synth::convertAwaitExprToRaw(this).(Raw::AwaitExpr).getExpr()) + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/BecomeExpr.qll b/rust/ql/lib/codeql/rust/generated/BecomeExpr.qll new file mode 100644 index 000000000000..5af91bbd3ff3 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/BecomeExpr.qll @@ -0,0 +1,31 @@ +// generated by codegen +/** + * This module provides the generated definition of `BecomeExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `BecomeExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::BecomeExpr` class directly. + * Use the subclass `BecomeExpr`, where the following predicates are available. + */ + class BecomeExpr extends Synth::TBecomeExpr, Expr { + override string getAPrimaryQlClass() { result = "BecomeExpr" } + + /** + * Gets the expression of this become expression. + */ + Expr getExpr() { + result = + Synth::convertExprFromRaw(Synth::convertBecomeExprToRaw(this).(Raw::BecomeExpr).getExpr()) + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/BinaryOpExpr.qll b/rust/ql/lib/codeql/rust/generated/BinaryOpExpr.qll new file mode 100644 index 000000000000..3f790dfec9a9 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/BinaryOpExpr.qll @@ -0,0 +1,49 @@ +// generated by codegen +/** + * This module provides the generated definition of `BinaryOpExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `BinaryOpExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::BinaryOpExpr` class directly. + * Use the subclass `BinaryOpExpr`, where the following predicates are available. + */ + class BinaryOpExpr extends Synth::TBinaryOpExpr, Expr { + override string getAPrimaryQlClass() { result = "BinaryOpExpr" } + + /** + * Gets the lhs of this binary op expression. + */ + Expr getLhs() { + result = + Synth::convertExprFromRaw(Synth::convertBinaryOpExprToRaw(this).(Raw::BinaryOpExpr).getLhs()) + } + + /** + * Gets the rhs of this binary op expression. + */ + Expr getRhs() { + result = + Synth::convertExprFromRaw(Synth::convertBinaryOpExprToRaw(this).(Raw::BinaryOpExpr).getRhs()) + } + + /** + * Gets the op of this binary op expression, if it exists. + */ + string getOp() { result = Synth::convertBinaryOpExprToRaw(this).(Raw::BinaryOpExpr).getOp() } + + /** + * Holds if `getOp()` exists. + */ + final predicate hasOp() { exists(this.getOp()) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/BindPat.qll b/rust/ql/lib/codeql/rust/generated/BindPat.qll new file mode 100644 index 000000000000..b58d24225851 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/BindPat.qll @@ -0,0 +1,42 @@ +// generated by codegen +/** + * This module provides the generated definition of `BindPat`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Pat + +/** + * INTERNAL: This module contains the fully generated definition of `BindPat` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::BindPat` class directly. + * Use the subclass `BindPat`, where the following predicates are available. + */ + class BindPat extends Synth::TBindPat, Pat { + override string getAPrimaryQlClass() { result = "BindPat" } + + /** + * Gets the binding of this bind pat. + */ + string getBindingId() { + result = Synth::convertBindPatToRaw(this).(Raw::BindPat).getBindingId() + } + + /** + * Gets the subpat of this bind pat, if it exists. + */ + Pat getSubpat() { + result = Synth::convertPatFromRaw(Synth::convertBindPatToRaw(this).(Raw::BindPat).getSubpat()) + } + + /** + * Holds if `getSubpat()` exists. + */ + final predicate hasSubpat() { exists(this.getSubpat()) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/BlockExpr.qll b/rust/ql/lib/codeql/rust/generated/BlockExpr.qll new file mode 100644 index 000000000000..52ca4526377d --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/BlockExpr.qll @@ -0,0 +1,37 @@ +// generated by codegen +/** + * This module provides the generated definition of `BlockExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.BlockExprBase +import codeql.rust.elements.Label + +/** + * INTERNAL: This module contains the fully generated definition of `BlockExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::BlockExpr` class directly. + * Use the subclass `BlockExpr`, where the following predicates are available. + */ + class BlockExpr extends Synth::TBlockExpr, BlockExprBase { + override string getAPrimaryQlClass() { result = "BlockExpr" } + + /** + * Gets the label of this block expression, if it exists. + */ + Label getLabel() { + result = + Synth::convertLabelFromRaw(Synth::convertBlockExprToRaw(this).(Raw::BlockExpr).getLabel()) + } + + /** + * Holds if `getLabel()` exists. + */ + final predicate hasLabel() { exists(this.getLabel()) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/BlockExprBase.qll b/rust/ql/lib/codeql/rust/generated/BlockExprBase.qll new file mode 100644 index 000000000000..3c565d285d5c --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/BlockExprBase.qll @@ -0,0 +1,57 @@ +// generated by codegen +/** + * This module provides the generated definition of `BlockExprBase`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr +import codeql.rust.elements.Stmt + +/** + * INTERNAL: This module contains the fully generated definition of `BlockExprBase` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::BlockExprBase` class directly. + * Use the subclass `BlockExprBase`, where the following predicates are available. + */ + class BlockExprBase extends Synth::TBlockExprBase, Expr { + /** + * Gets the `index`th statement of this block expression base (0-based). + */ + Stmt getStatement(int index) { + result = + Synth::convertStmtFromRaw(Synth::convertBlockExprBaseToRaw(this) + .(Raw::BlockExprBase) + .getStatement(index)) + } + + /** + * Gets any of the statements of this block expression base. + */ + final Stmt getAStatement() { result = this.getStatement(_) } + + /** + * Gets the number of statements of this block expression base. + */ + final int getNumberOfStatements() { result = count(int i | exists(this.getStatement(i))) } + + /** + * Gets the tail of this block expression base, if it exists. + */ + Expr getTail() { + result = + Synth::convertExprFromRaw(Synth::convertBlockExprBaseToRaw(this) + .(Raw::BlockExprBase) + .getTail()) + } + + /** + * Holds if `getTail()` exists. + */ + final predicate hasTail() { exists(this.getTail()) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/BoxExpr.qll b/rust/ql/lib/codeql/rust/generated/BoxExpr.qll new file mode 100644 index 000000000000..4a367bc7b2f7 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/BoxExpr.qll @@ -0,0 +1,30 @@ +// generated by codegen +/** + * This module provides the generated definition of `BoxExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `BoxExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::BoxExpr` class directly. + * Use the subclass `BoxExpr`, where the following predicates are available. + */ + class BoxExpr extends Synth::TBoxExpr, Expr { + override string getAPrimaryQlClass() { result = "BoxExpr" } + + /** + * Gets the expression of this box expression. + */ + Expr getExpr() { + result = Synth::convertExprFromRaw(Synth::convertBoxExprToRaw(this).(Raw::BoxExpr).getExpr()) + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/BoxPat.qll b/rust/ql/lib/codeql/rust/generated/BoxPat.qll new file mode 100644 index 000000000000..690fc5155d7c --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/BoxPat.qll @@ -0,0 +1,30 @@ +// generated by codegen +/** + * This module provides the generated definition of `BoxPat`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Pat + +/** + * INTERNAL: This module contains the fully generated definition of `BoxPat` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::BoxPat` class directly. + * Use the subclass `BoxPat`, where the following predicates are available. + */ + class BoxPat extends Synth::TBoxPat, Pat { + override string getAPrimaryQlClass() { result = "BoxPat" } + + /** + * Gets the inner of this box pat. + */ + Pat getInner() { + result = Synth::convertPatFromRaw(Synth::convertBoxPatToRaw(this).(Raw::BoxPat).getInner()) + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/BreakExpr.qll b/rust/ql/lib/codeql/rust/generated/BreakExpr.qll new file mode 100644 index 000000000000..9e4d90b4973e --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/BreakExpr.qll @@ -0,0 +1,50 @@ +// generated by codegen +/** + * This module provides the generated definition of `BreakExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr +import codeql.rust.elements.Label + +/** + * INTERNAL: This module contains the fully generated definition of `BreakExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::BreakExpr` class directly. + * Use the subclass `BreakExpr`, where the following predicates are available. + */ + class BreakExpr extends Synth::TBreakExpr, Expr { + override string getAPrimaryQlClass() { result = "BreakExpr" } + + /** + * Gets the expression of this break expression, if it exists. + */ + Expr getExpr() { + result = + Synth::convertExprFromRaw(Synth::convertBreakExprToRaw(this).(Raw::BreakExpr).getExpr()) + } + + /** + * Holds if `getExpr()` exists. + */ + final predicate hasExpr() { exists(this.getExpr()) } + + /** + * Gets the label of this break expression, if it exists. + */ + Label getLabel() { + result = + Synth::convertLabelFromRaw(Synth::convertBreakExprToRaw(this).(Raw::BreakExpr).getLabel()) + } + + /** + * Holds if `getLabel()` exists. + */ + final predicate hasLabel() { exists(this.getLabel()) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/CallExpr.qll b/rust/ql/lib/codeql/rust/generated/CallExpr.qll new file mode 100644 index 000000000000..0ca5f2b604d5 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/CallExpr.qll @@ -0,0 +1,56 @@ +// generated by codegen +/** + * This module provides the generated definition of `CallExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `CallExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::CallExpr` class directly. + * Use the subclass `CallExpr`, where the following predicates are available. + */ + class CallExpr extends Synth::TCallExpr, Expr { + override string getAPrimaryQlClass() { result = "CallExpr" } + + /** + * Gets the callee of this call expression. + */ + Expr getCallee() { + result = + Synth::convertExprFromRaw(Synth::convertCallExprToRaw(this).(Raw::CallExpr).getCallee()) + } + + /** + * Gets the `index`th argument of this call expression (0-based). + */ + Expr getArg(int index) { + result = + Synth::convertExprFromRaw(Synth::convertCallExprToRaw(this).(Raw::CallExpr).getArg(index)) + } + + /** + * Gets any of the arguments of this call expression. + */ + final Expr getAnArg() { result = this.getArg(_) } + + /** + * Gets the number of arguments of this call expression. + */ + final int getNumberOfArgs() { result = count(int i | exists(this.getArg(i))) } + + /** + * Holds if this call expression is assignee expression. + */ + predicate isAssigneeExpr() { + Synth::convertCallExprToRaw(this).(Raw::CallExpr).isAssigneeExpr() + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/CastExpr.qll b/rust/ql/lib/codeql/rust/generated/CastExpr.qll new file mode 100644 index 000000000000..f9b717f9114c --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/CastExpr.qll @@ -0,0 +1,40 @@ +// generated by codegen +/** + * This module provides the generated definition of `CastExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr +import codeql.rust.elements.TypeRef + +/** + * INTERNAL: This module contains the fully generated definition of `CastExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::CastExpr` class directly. + * Use the subclass `CastExpr`, where the following predicates are available. + */ + class CastExpr extends Synth::TCastExpr, Expr { + override string getAPrimaryQlClass() { result = "CastExpr" } + + /** + * Gets the expression of this cast expression. + */ + Expr getExpr() { + result = + Synth::convertExprFromRaw(Synth::convertCastExprToRaw(this).(Raw::CastExpr).getExpr()) + } + + /** + * Gets the type reference of this cast expression. + */ + TypeRef getTypeRef() { + result = + Synth::convertTypeRefFromRaw(Synth::convertCastExprToRaw(this).(Raw::CastExpr).getTypeRef()) + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/ClosureExpr.qll b/rust/ql/lib/codeql/rust/generated/ClosureExpr.qll new file mode 100644 index 000000000000..2c1b31af0264 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/ClosureExpr.qll @@ -0,0 +1,100 @@ +// generated by codegen +/** + * This module provides the generated definition of `ClosureExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr +import codeql.rust.elements.Pat +import codeql.rust.elements.TypeRef + +/** + * INTERNAL: This module contains the fully generated definition of `ClosureExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::ClosureExpr` class directly. + * Use the subclass `ClosureExpr`, where the following predicates are available. + */ + class ClosureExpr extends Synth::TClosureExpr, Expr { + override string getAPrimaryQlClass() { result = "ClosureExpr" } + + /** + * Gets the `index`th argument of this closure expression (0-based). + */ + Pat getArg(int index) { + result = + Synth::convertPatFromRaw(Synth::convertClosureExprToRaw(this) + .(Raw::ClosureExpr) + .getArg(index)) + } + + /** + * Gets any of the arguments of this closure expression. + */ + final Pat getAnArg() { result = this.getArg(_) } + + /** + * Gets the number of arguments of this closure expression. + */ + final int getNumberOfArgs() { result = count(int i | exists(this.getArg(i))) } + + /** + * Gets the `index`th argument type of this closure expression (0-based), if it exists. + */ + TypeRef getArgType(int index) { + result = + Synth::convertTypeRefFromRaw(Synth::convertClosureExprToRaw(this) + .(Raw::ClosureExpr) + .getArgType(index)) + } + + /** + * Holds if `getArgType(index)` exists. + */ + final predicate hasArgType(int index) { exists(this.getArgType(index)) } + + /** + * Gets any of the argument types of this closure expression. + */ + final TypeRef getAnArgType() { result = this.getArgType(_) } + + /** + * Gets the ret type of this closure expression, if it exists. + */ + TypeRef getRetType() { + result = + Synth::convertTypeRefFromRaw(Synth::convertClosureExprToRaw(this) + .(Raw::ClosureExpr) + .getRetType()) + } + + /** + * Holds if `getRetType()` exists. + */ + final predicate hasRetType() { exists(this.getRetType()) } + + /** + * Gets the body of this closure expression. + */ + Expr getBody() { + result = + Synth::convertExprFromRaw(Synth::convertClosureExprToRaw(this).(Raw::ClosureExpr).getBody()) + } + + /** + * Gets the closure kind of this closure expression. + */ + string getClosureKind() { + result = Synth::convertClosureExprToRaw(this).(Raw::ClosureExpr).getClosureKind() + } + + /** + * Holds if this closure expression is move. + */ + predicate isMove() { Synth::convertClosureExprToRaw(this).(Raw::ClosureExpr).isMove() } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/ConstBlockPat.qll b/rust/ql/lib/codeql/rust/generated/ConstBlockPat.qll new file mode 100644 index 000000000000..f741124f180c --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/ConstBlockPat.qll @@ -0,0 +1,34 @@ +// generated by codegen +/** + * This module provides the generated definition of `ConstBlockPat`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr +import codeql.rust.elements.Pat + +/** + * INTERNAL: This module contains the fully generated definition of `ConstBlockPat` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::ConstBlockPat` class directly. + * Use the subclass `ConstBlockPat`, where the following predicates are available. + */ + class ConstBlockPat extends Synth::TConstBlockPat, Pat { + override string getAPrimaryQlClass() { result = "ConstBlockPat" } + + /** + * Gets the expression of this const block pat. + */ + Expr getExpr() { + result = + Synth::convertExprFromRaw(Synth::convertConstBlockPatToRaw(this) + .(Raw::ConstBlockPat) + .getExpr()) + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/ConstExpr.qll b/rust/ql/lib/codeql/rust/generated/ConstExpr.qll new file mode 100644 index 000000000000..1c11dba419c1 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/ConstExpr.qll @@ -0,0 +1,31 @@ +// generated by codegen +/** + * This module provides the generated definition of `ConstExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `ConstExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::ConstExpr` class directly. + * Use the subclass `ConstExpr`, where the following predicates are available. + */ + class ConstExpr extends Synth::TConstExpr, Expr { + override string getAPrimaryQlClass() { result = "ConstExpr" } + + /** + * Gets the expression of this const expression. + */ + Expr getExpr() { + result = + Synth::convertExprFromRaw(Synth::convertConstExprToRaw(this).(Raw::ConstExpr).getExpr()) + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/ContinueExpr.qll b/rust/ql/lib/codeql/rust/generated/ContinueExpr.qll new file mode 100644 index 000000000000..b03aed387ae9 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/ContinueExpr.qll @@ -0,0 +1,39 @@ +// generated by codegen +/** + * This module provides the generated definition of `ContinueExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr +import codeql.rust.elements.Label + +/** + * INTERNAL: This module contains the fully generated definition of `ContinueExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::ContinueExpr` class directly. + * Use the subclass `ContinueExpr`, where the following predicates are available. + */ + class ContinueExpr extends Synth::TContinueExpr, Expr { + override string getAPrimaryQlClass() { result = "ContinueExpr" } + + /** + * Gets the label of this continue expression, if it exists. + */ + Label getLabel() { + result = + Synth::convertLabelFromRaw(Synth::convertContinueExprToRaw(this) + .(Raw::ContinueExpr) + .getLabel()) + } + + /** + * Holds if `getLabel()` exists. + */ + final predicate hasLabel() { exists(this.getLabel()) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/DbFile.qll b/rust/ql/lib/codeql/rust/generated/DbFile.qll new file mode 100644 index 000000000000..7128045152c2 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/DbFile.qll @@ -0,0 +1,23 @@ +// generated by codegen +/** + * This module provides the generated definition of `DbFile`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.File + +/** + * INTERNAL: This module contains the fully generated definition of `DbFile` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::DbFile` class directly. + * Use the subclass `DbFile`, where the following predicates are available. + */ + class DbFile extends Synth::TDbFile, File { + override string getAPrimaryQlClass() { result = "DbFile" } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/DbLocation.qll b/rust/ql/lib/codeql/rust/generated/DbLocation.qll new file mode 100644 index 000000000000..a0944fa4b6de --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/DbLocation.qll @@ -0,0 +1,23 @@ +// generated by codegen +/** + * This module provides the generated definition of `DbLocation`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Location + +/** + * INTERNAL: This module contains the fully generated definition of `DbLocation` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::DbLocation` class directly. + * Use the subclass `DbLocation`, where the following predicates are available. + */ + class DbLocation extends Synth::TDbLocation, Location { + override string getAPrimaryQlClass() { result = "DbLocation" } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/Declaration.qll b/rust/ql/lib/codeql/rust/generated/Declaration.qll new file mode 100644 index 000000000000..0cc2a30f178b --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/Declaration.qll @@ -0,0 +1,21 @@ +// generated by codegen +/** + * This module provides the generated definition of `Declaration`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.AstNode + +/** + * INTERNAL: This module contains the fully generated definition of `Declaration` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::Declaration` class directly. + * Use the subclass `Declaration`, where the following predicates are available. + */ + class Declaration extends Synth::TDeclaration, AstNode { } +} diff --git a/rust/ql/lib/codeql/rust/generated/Element.qll b/rust/ql/lib/codeql/rust/generated/Element.qll new file mode 100644 index 000000000000..19dbb9edb14c --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/Element.qll @@ -0,0 +1,57 @@ +// generated by codegen +/** + * This module provides the generated definition of `Element`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw + +/** + * INTERNAL: This module contains the fully generated definition of `Element` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::Element` class directly. + * Use the subclass `Element`, where the following predicates are available. + */ + class Element extends Synth::TElement { + /** + * Gets the string representation of this element. + */ + string toString() { none() } // overridden by subclasses + + /** + * Gets the name of a primary CodeQL class to which this element belongs. + * + * This is the most precise syntactic category to which they belong; for + * example, `CallExpr` is a primary class, but `ApplyExpr` is not. + * + * There might be some corner cases when this returns multiple classes, or none. + */ + string getAPrimaryQlClass() { none() } // overridden by subclasses + + /** + * Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs. + */ + final string getPrimaryQlClasses() { result = concat(this.getAPrimaryQlClass(), ",") } + + /** + * Gets the most immediate element that should substitute this element in the explicit AST, if any. + * Classes can override this to indicate this node should be in the "hidden" AST, mostly reserved + * for conversions and syntactic sugar nodes like parentheses. + */ + Element getResolveStep() { none() } // overridden by subclasses + + /** + * Gets the element that should substitute this element in the explicit AST, applying `getResolveStep` + * transitively. + */ + final Element resolve() { + not exists(this.getResolveStep()) and result = this + or + result = this.getResolveStep().resolve() + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/ElementListExpr.qll b/rust/ql/lib/codeql/rust/generated/ElementListExpr.qll new file mode 100644 index 000000000000..ae6ac160ef09 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/ElementListExpr.qll @@ -0,0 +1,51 @@ +// generated by codegen +/** + * This module provides the generated definition of `ElementListExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.ArrayExpr +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `ElementListExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::ElementListExpr` class directly. + * Use the subclass `ElementListExpr`, where the following predicates are available. + */ + class ElementListExpr extends Synth::TElementListExpr, ArrayExpr { + override string getAPrimaryQlClass() { result = "ElementListExpr" } + + /** + * Gets the `index`th element of this element list expression (0-based). + */ + Expr getElement(int index) { + result = + Synth::convertExprFromRaw(Synth::convertElementListExprToRaw(this) + .(Raw::ElementListExpr) + .getElement(index)) + } + + /** + * Gets any of the elements of this element list expression. + */ + final Expr getAnElement() { result = this.getElement(_) } + + /** + * Gets the number of elements of this element list expression. + */ + final int getNumberOfElements() { result = count(int i | exists(this.getElement(i))) } + + /** + * Holds if this element list expression is assignee expression. + */ + predicate isAssigneeExpr() { + Synth::convertElementListExprToRaw(this).(Raw::ElementListExpr).isAssigneeExpr() + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/Expr.qll b/rust/ql/lib/codeql/rust/generated/Expr.qll new file mode 100644 index 000000000000..f395ff11840e --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/Expr.qll @@ -0,0 +1,21 @@ +// generated by codegen +/** + * This module provides the generated definition of `Expr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.AstNode + +/** + * INTERNAL: This module contains the fully generated definition of `Expr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::Expr` class directly. + * Use the subclass `Expr`, where the following predicates are available. + */ + class Expr extends Synth::TExpr, AstNode { } +} diff --git a/rust/ql/lib/codeql/rust/generated/ExprStmt.qll b/rust/ql/lib/codeql/rust/generated/ExprStmt.qll new file mode 100644 index 000000000000..08d3dfc5a863 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/ExprStmt.qll @@ -0,0 +1,37 @@ +// generated by codegen +/** + * This module provides the generated definition of `ExprStmt`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr +import codeql.rust.elements.Stmt + +/** + * INTERNAL: This module contains the fully generated definition of `ExprStmt` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::ExprStmt` class directly. + * Use the subclass `ExprStmt`, where the following predicates are available. + */ + class ExprStmt extends Synth::TExprStmt, Stmt { + override string getAPrimaryQlClass() { result = "ExprStmt" } + + /** + * Gets the expression of this expression statement. + */ + Expr getExpr() { + result = + Synth::convertExprFromRaw(Synth::convertExprStmtToRaw(this).(Raw::ExprStmt).getExpr()) + } + + /** + * Holds if this expression statement has semicolon. + */ + predicate hasSemicolon() { Synth::convertExprStmtToRaw(this).(Raw::ExprStmt).hasSemicolon() } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/FieldExpr.qll b/rust/ql/lib/codeql/rust/generated/FieldExpr.qll new file mode 100644 index 000000000000..82688dbf44b4 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/FieldExpr.qll @@ -0,0 +1,36 @@ +// generated by codegen +/** + * This module provides the generated definition of `FieldExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `FieldExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::FieldExpr` class directly. + * Use the subclass `FieldExpr`, where the following predicates are available. + */ + class FieldExpr extends Synth::TFieldExpr, Expr { + override string getAPrimaryQlClass() { result = "FieldExpr" } + + /** + * Gets the expression of this field expression. + */ + Expr getExpr() { + result = + Synth::convertExprFromRaw(Synth::convertFieldExprToRaw(this).(Raw::FieldExpr).getExpr()) + } + + /** + * Gets the name of this field expression. + */ + string getName() { result = Synth::convertFieldExprToRaw(this).(Raw::FieldExpr).getName() } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/File.qll b/rust/ql/lib/codeql/rust/generated/File.qll new file mode 100644 index 000000000000..c5ebe20092c9 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/File.qll @@ -0,0 +1,26 @@ +// generated by codegen +/** + * This module provides the generated definition of `File`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Element + +/** + * INTERNAL: This module contains the fully generated definition of `File` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::File` class directly. + * Use the subclass `File`, where the following predicates are available. + */ + class File extends Synth::TFile, Element { + /** + * Gets the name of this file. + */ + string getName() { result = Synth::convertFileToRaw(this).(Raw::File).getName() } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/Function.qll b/rust/ql/lib/codeql/rust/generated/Function.qll new file mode 100644 index 000000000000..f0c053f97152 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/Function.qll @@ -0,0 +1,47 @@ +// generated by codegen +/** + * This module provides the generated definition of `Function`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Declaration +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `Function` and should not + * be referenced directly. + */ +module Generated { + /** + * A function declaration. For example + * ``` + * fn foo(x: u32) -> u64 { (x + 1).into() } + * ``` + * A function declaration within a trait might not have a body: + * ``` + * trait Trait { + * fn bar(); + * } + * ``` + * INTERNAL: Do not reference the `Generated::Function` class directly. + * Use the subclass `Function`, where the following predicates are available. + */ + class Function extends Synth::TFunction, Declaration { + override string getAPrimaryQlClass() { result = "Function" } + + /** + * Gets the name of this function. + */ + string getName() { result = Synth::convertFunctionToRaw(this).(Raw::Function).getName() } + + /** + * Gets the body of this function. + */ + Expr getBody() { + result = + Synth::convertExprFromRaw(Synth::convertFunctionToRaw(this).(Raw::Function).getBody()) + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/IfExpr.qll b/rust/ql/lib/codeql/rust/generated/IfExpr.qll new file mode 100644 index 000000000000..4b90ac9b50ac --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/IfExpr.qll @@ -0,0 +1,50 @@ +// generated by codegen +/** + * This module provides the generated definition of `IfExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `IfExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::IfExpr` class directly. + * Use the subclass `IfExpr`, where the following predicates are available. + */ + class IfExpr extends Synth::TIfExpr, Expr { + override string getAPrimaryQlClass() { result = "IfExpr" } + + /** + * Gets the condition of this if expression. + */ + Expr getCondition() { + result = + Synth::convertExprFromRaw(Synth::convertIfExprToRaw(this).(Raw::IfExpr).getCondition()) + } + + /** + * Gets the then of this if expression. + */ + Expr getThen() { + result = Synth::convertExprFromRaw(Synth::convertIfExprToRaw(this).(Raw::IfExpr).getThen()) + } + + /** + * Gets the else of this if expression, if it exists. + */ + Expr getElse() { + result = Synth::convertExprFromRaw(Synth::convertIfExprToRaw(this).(Raw::IfExpr).getElse()) + } + + /** + * Holds if `getElse()` exists. + */ + final predicate hasElse() { exists(this.getElse()) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/IndexExpr.qll b/rust/ql/lib/codeql/rust/generated/IndexExpr.qll new file mode 100644 index 000000000000..fd6021f30145 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/IndexExpr.qll @@ -0,0 +1,46 @@ +// generated by codegen +/** + * This module provides the generated definition of `IndexExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `IndexExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::IndexExpr` class directly. + * Use the subclass `IndexExpr`, where the following predicates are available. + */ + class IndexExpr extends Synth::TIndexExpr, Expr { + override string getAPrimaryQlClass() { result = "IndexExpr" } + + /** + * Gets the base of this index expression. + */ + Expr getBase() { + result = + Synth::convertExprFromRaw(Synth::convertIndexExprToRaw(this).(Raw::IndexExpr).getBase()) + } + + /** + * Gets the index of this index expression. + */ + Expr getIndex() { + result = + Synth::convertExprFromRaw(Synth::convertIndexExprToRaw(this).(Raw::IndexExpr).getIndex()) + } + + /** + * Holds if this index expression is assignee expression. + */ + predicate isAssigneeExpr() { + Synth::convertIndexExprToRaw(this).(Raw::IndexExpr).isAssigneeExpr() + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/InlineAsmExpr.qll b/rust/ql/lib/codeql/rust/generated/InlineAsmExpr.qll new file mode 100644 index 000000000000..4478cfee53b5 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/InlineAsmExpr.qll @@ -0,0 +1,33 @@ +// generated by codegen +/** + * This module provides the generated definition of `InlineAsmExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `InlineAsmExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::InlineAsmExpr` class directly. + * Use the subclass `InlineAsmExpr`, where the following predicates are available. + */ + class InlineAsmExpr extends Synth::TInlineAsmExpr, Expr { + override string getAPrimaryQlClass() { result = "InlineAsmExpr" } + + /** + * Gets the expression of this inline asm expression. + */ + Expr getExpr() { + result = + Synth::convertExprFromRaw(Synth::convertInlineAsmExprToRaw(this) + .(Raw::InlineAsmExpr) + .getExpr()) + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/ItemStmt.qll b/rust/ql/lib/codeql/rust/generated/ItemStmt.qll new file mode 100644 index 000000000000..2be48967c7cb --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/ItemStmt.qll @@ -0,0 +1,23 @@ +// generated by codegen +/** + * This module provides the generated definition of `ItemStmt`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Stmt + +/** + * INTERNAL: This module contains the fully generated definition of `ItemStmt` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::ItemStmt` class directly. + * Use the subclass `ItemStmt`, where the following predicates are available. + */ + class ItemStmt extends Synth::TItemStmt, Stmt { + override string getAPrimaryQlClass() { result = "ItemStmt" } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/Label.qll b/rust/ql/lib/codeql/rust/generated/Label.qll new file mode 100644 index 000000000000..6922dd193acd --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/Label.qll @@ -0,0 +1,28 @@ +// generated by codegen +/** + * This module provides the generated definition of `Label`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.AstNode + +/** + * INTERNAL: This module contains the fully generated definition of `Label` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::Label` class directly. + * Use the subclass `Label`, where the following predicates are available. + */ + class Label extends Synth::TLabel, AstNode { + override string getAPrimaryQlClass() { result = "Label" } + + /** + * Gets the name of this label. + */ + string getName() { result = Synth::convertLabelToRaw(this).(Raw::Label).getName() } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/LetExpr.qll b/rust/ql/lib/codeql/rust/generated/LetExpr.qll new file mode 100644 index 000000000000..a4dccae48760 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/LetExpr.qll @@ -0,0 +1,38 @@ +// generated by codegen +/** + * This module provides the generated definition of `LetExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr +import codeql.rust.elements.Pat + +/** + * INTERNAL: This module contains the fully generated definition of `LetExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::LetExpr` class directly. + * Use the subclass `LetExpr`, where the following predicates are available. + */ + class LetExpr extends Synth::TLetExpr, Expr { + override string getAPrimaryQlClass() { result = "LetExpr" } + + /** + * Gets the pat of this let expression. + */ + Pat getPat() { + result = Synth::convertPatFromRaw(Synth::convertLetExprToRaw(this).(Raw::LetExpr).getPat()) + } + + /** + * Gets the expression of this let expression. + */ + Expr getExpr() { + result = Synth::convertExprFromRaw(Synth::convertLetExprToRaw(this).(Raw::LetExpr).getExpr()) + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/LetStmt.qll b/rust/ql/lib/codeql/rust/generated/LetStmt.qll new file mode 100644 index 000000000000..8f52f441dfc7 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/LetStmt.qll @@ -0,0 +1,71 @@ +// generated by codegen +/** + * This module provides the generated definition of `LetStmt`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr +import codeql.rust.elements.Pat +import codeql.rust.elements.Stmt +import codeql.rust.elements.TypeRef + +/** + * INTERNAL: This module contains the fully generated definition of `LetStmt` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::LetStmt` class directly. + * Use the subclass `LetStmt`, where the following predicates are available. + */ + class LetStmt extends Synth::TLetStmt, Stmt { + override string getAPrimaryQlClass() { result = "LetStmt" } + + /** + * Gets the pat of this let statement. + */ + Pat getPat() { + result = Synth::convertPatFromRaw(Synth::convertLetStmtToRaw(this).(Raw::LetStmt).getPat()) + } + + /** + * Gets the type reference of this let statement, if it exists. + */ + TypeRef getTypeRef() { + result = + Synth::convertTypeRefFromRaw(Synth::convertLetStmtToRaw(this).(Raw::LetStmt).getTypeRef()) + } + + /** + * Holds if `getTypeRef()` exists. + */ + final predicate hasTypeRef() { exists(this.getTypeRef()) } + + /** + * Gets the initializer of this let statement, if it exists. + */ + Expr getInitializer() { + result = + Synth::convertExprFromRaw(Synth::convertLetStmtToRaw(this).(Raw::LetStmt).getInitializer()) + } + + /** + * Holds if `getInitializer()` exists. + */ + final predicate hasInitializer() { exists(this.getInitializer()) } + + /** + * Gets the else of this let statement, if it exists. + */ + Expr getElse() { + result = Synth::convertExprFromRaw(Synth::convertLetStmtToRaw(this).(Raw::LetStmt).getElse()) + } + + /** + * Holds if `getElse()` exists. + */ + final predicate hasElse() { exists(this.getElse()) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/LitPat.qll b/rust/ql/lib/codeql/rust/generated/LitPat.qll new file mode 100644 index 000000000000..1133ee3d1f1a --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/LitPat.qll @@ -0,0 +1,31 @@ +// generated by codegen +/** + * This module provides the generated definition of `LitPat`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr +import codeql.rust.elements.Pat + +/** + * INTERNAL: This module contains the fully generated definition of `LitPat` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::LitPat` class directly. + * Use the subclass `LitPat`, where the following predicates are available. + */ + class LitPat extends Synth::TLitPat, Pat { + override string getAPrimaryQlClass() { result = "LitPat" } + + /** + * Gets the expression of this lit pat. + */ + Expr getExpr() { + result = Synth::convertExprFromRaw(Synth::convertLitPatToRaw(this).(Raw::LitPat).getExpr()) + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/LiteralExpr.qll b/rust/ql/lib/codeql/rust/generated/LiteralExpr.qll new file mode 100644 index 000000000000..c54501545923 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/LiteralExpr.qll @@ -0,0 +1,23 @@ +// generated by codegen +/** + * This module provides the generated definition of `LiteralExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `LiteralExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::LiteralExpr` class directly. + * Use the subclass `LiteralExpr`, where the following predicates are available. + */ + class LiteralExpr extends Synth::TLiteralExpr, Expr { + override string getAPrimaryQlClass() { result = "LiteralExpr" } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/Locatable.qll b/rust/ql/lib/codeql/rust/generated/Locatable.qll new file mode 100644 index 000000000000..a0cdb9a007b5 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/Locatable.qll @@ -0,0 +1,37 @@ +// generated by codegen +/** + * This module provides the generated definition of `Locatable`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Element +import codeql.rust.elements.Location + +/** + * INTERNAL: This module contains the fully generated definition of `Locatable` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::Locatable` class directly. + * Use the subclass `Locatable`, where the following predicates are available. + */ + class Locatable extends Synth::TLocatable, Element { + /** + * Gets the location of this locatable, if it exists. + */ + Location getLocation() { + result = + Synth::convertLocationFromRaw(Synth::convertLocatableToRaw(this) + .(Raw::Locatable) + .getLocation()) + } + + /** + * Holds if `getLocation()` exists. + */ + final predicate hasLocation() { exists(this.getLocation()) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/Location.qll b/rust/ql/lib/codeql/rust/generated/Location.qll new file mode 100644 index 000000000000..dac13d4a4188 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/Location.qll @@ -0,0 +1,52 @@ +// generated by codegen +/** + * This module provides the generated definition of `Location`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Element +import codeql.rust.elements.File + +/** + * INTERNAL: This module contains the fully generated definition of `Location` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::Location` class directly. + * Use the subclass `Location`, where the following predicates are available. + */ + class Location extends Synth::TLocation, Element { + /** + * Gets the file of this location. + */ + File getFile() { + result = + Synth::convertFileFromRaw(Synth::convertLocationToRaw(this).(Raw::Location).getFile()) + } + + /** + * Gets the start line of this location. + */ + int getStartLine() { result = Synth::convertLocationToRaw(this).(Raw::Location).getStartLine() } + + /** + * Gets the start column of this location. + */ + int getStartColumn() { + result = Synth::convertLocationToRaw(this).(Raw::Location).getStartColumn() + } + + /** + * Gets the end line of this location. + */ + int getEndLine() { result = Synth::convertLocationToRaw(this).(Raw::Location).getEndLine() } + + /** + * Gets the end column of this location. + */ + int getEndColumn() { result = Synth::convertLocationToRaw(this).(Raw::Location).getEndColumn() } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/LoopExpr.qll b/rust/ql/lib/codeql/rust/generated/LoopExpr.qll new file mode 100644 index 000000000000..c4479efdb1af --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/LoopExpr.qll @@ -0,0 +1,45 @@ +// generated by codegen +/** + * This module provides the generated definition of `LoopExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr +import codeql.rust.elements.Label + +/** + * INTERNAL: This module contains the fully generated definition of `LoopExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::LoopExpr` class directly. + * Use the subclass `LoopExpr`, where the following predicates are available. + */ + class LoopExpr extends Synth::TLoopExpr, Expr { + override string getAPrimaryQlClass() { result = "LoopExpr" } + + /** + * Gets the body of this loop expression. + */ + Expr getBody() { + result = + Synth::convertExprFromRaw(Synth::convertLoopExprToRaw(this).(Raw::LoopExpr).getBody()) + } + + /** + * Gets the label of this loop expression, if it exists. + */ + Label getLabel() { + result = + Synth::convertLabelFromRaw(Synth::convertLoopExprToRaw(this).(Raw::LoopExpr).getLabel()) + } + + /** + * Holds if `getLabel()` exists. + */ + final predicate hasLabel() { exists(this.getLabel()) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/MatchArm.qll b/rust/ql/lib/codeql/rust/generated/MatchArm.qll new file mode 100644 index 000000000000..cec99d17c321 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/MatchArm.qll @@ -0,0 +1,53 @@ +// generated by codegen +/** + * This module provides the generated definition of `MatchArm`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.AstNode +import codeql.rust.elements.Expr +import codeql.rust.elements.Pat + +/** + * INTERNAL: This module contains the fully generated definition of `MatchArm` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::MatchArm` class directly. + * Use the subclass `MatchArm`, where the following predicates are available. + */ + class MatchArm extends Synth::TMatchArm, AstNode { + override string getAPrimaryQlClass() { result = "MatchArm" } + + /** + * Gets the pat of this match arm. + */ + Pat getPat() { + result = Synth::convertPatFromRaw(Synth::convertMatchArmToRaw(this).(Raw::MatchArm).getPat()) + } + + /** + * Gets the guard of this match arm, if it exists. + */ + Expr getGuard() { + result = + Synth::convertExprFromRaw(Synth::convertMatchArmToRaw(this).(Raw::MatchArm).getGuard()) + } + + /** + * Holds if `getGuard()` exists. + */ + final predicate hasGuard() { exists(this.getGuard()) } + + /** + * Gets the expression of this match arm. + */ + Expr getExpr() { + result = + Synth::convertExprFromRaw(Synth::convertMatchArmToRaw(this).(Raw::MatchArm).getExpr()) + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/MatchExpr.qll b/rust/ql/lib/codeql/rust/generated/MatchExpr.qll new file mode 100644 index 000000000000..87569d02ba02 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/MatchExpr.qll @@ -0,0 +1,52 @@ +// generated by codegen +/** + * This module provides the generated definition of `MatchExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr +import codeql.rust.elements.MatchArm + +/** + * INTERNAL: This module contains the fully generated definition of `MatchExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::MatchExpr` class directly. + * Use the subclass `MatchExpr`, where the following predicates are available. + */ + class MatchExpr extends Synth::TMatchExpr, Expr { + override string getAPrimaryQlClass() { result = "MatchExpr" } + + /** + * Gets the expression of this match expression. + */ + Expr getExpr() { + result = + Synth::convertExprFromRaw(Synth::convertMatchExprToRaw(this).(Raw::MatchExpr).getExpr()) + } + + /** + * Gets the `index`th branch of this match expression (0-based). + */ + MatchArm getBranch(int index) { + result = + Synth::convertMatchArmFromRaw(Synth::convertMatchExprToRaw(this) + .(Raw::MatchExpr) + .getBranch(index)) + } + + /** + * Gets any of the branches of this match expression. + */ + final MatchArm getABranch() { result = this.getBranch(_) } + + /** + * Gets the number of branches of this match expression. + */ + final int getNumberOfBranches() { result = count(int i | exists(this.getBranch(i))) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/MethodCallExpr.qll b/rust/ql/lib/codeql/rust/generated/MethodCallExpr.qll new file mode 100644 index 000000000000..18eacc9dc202 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/MethodCallExpr.qll @@ -0,0 +1,76 @@ +// generated by codegen +/** + * This module provides the generated definition of `MethodCallExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr +import codeql.rust.elements.Unimplemented + +/** + * INTERNAL: This module contains the fully generated definition of `MethodCallExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::MethodCallExpr` class directly. + * Use the subclass `MethodCallExpr`, where the following predicates are available. + */ + class MethodCallExpr extends Synth::TMethodCallExpr, Expr { + override string getAPrimaryQlClass() { result = "MethodCallExpr" } + + /** + * Gets the receiver of this method call expression. + */ + Expr getReceiver() { + result = + Synth::convertExprFromRaw(Synth::convertMethodCallExprToRaw(this) + .(Raw::MethodCallExpr) + .getReceiver()) + } + + /** + * Gets the method name of this method call expression. + */ + string getMethodName() { + result = Synth::convertMethodCallExprToRaw(this).(Raw::MethodCallExpr).getMethodName() + } + + /** + * Gets the `index`th argument of this method call expression (0-based). + */ + Expr getArg(int index) { + result = + Synth::convertExprFromRaw(Synth::convertMethodCallExprToRaw(this) + .(Raw::MethodCallExpr) + .getArg(index)) + } + + /** + * Gets any of the arguments of this method call expression. + */ + final Expr getAnArg() { result = this.getArg(_) } + + /** + * Gets the number of arguments of this method call expression. + */ + final int getNumberOfArgs() { result = count(int i | exists(this.getArg(i))) } + + /** + * Gets the generic arguments of this method call expression, if it exists. + */ + Unimplemented getGenericArgs() { + result = + Synth::convertUnimplementedFromRaw(Synth::convertMethodCallExprToRaw(this) + .(Raw::MethodCallExpr) + .getGenericArgs()) + } + + /** + * Holds if `getGenericArgs()` exists. + */ + final predicate hasGenericArgs() { exists(this.getGenericArgs()) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/MissingExpr.qll b/rust/ql/lib/codeql/rust/generated/MissingExpr.qll new file mode 100644 index 000000000000..250c639fbeb8 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/MissingExpr.qll @@ -0,0 +1,23 @@ +// generated by codegen +/** + * This module provides the generated definition of `MissingExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `MissingExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::MissingExpr` class directly. + * Use the subclass `MissingExpr`, where the following predicates are available. + */ + class MissingExpr extends Synth::TMissingExpr, Expr { + override string getAPrimaryQlClass() { result = "MissingExpr" } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/MissingPat.qll b/rust/ql/lib/codeql/rust/generated/MissingPat.qll new file mode 100644 index 000000000000..fb8af9f5f5b8 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/MissingPat.qll @@ -0,0 +1,23 @@ +// generated by codegen +/** + * This module provides the generated definition of `MissingPat`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Pat + +/** + * INTERNAL: This module contains the fully generated definition of `MissingPat` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::MissingPat` class directly. + * Use the subclass `MissingPat`, where the following predicates are available. + */ + class MissingPat extends Synth::TMissingPat, Pat { + override string getAPrimaryQlClass() { result = "MissingPat" } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/Module.qll b/rust/ql/lib/codeql/rust/generated/Module.qll new file mode 100644 index 000000000000..ae5100ee9d8f --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/Module.qll @@ -0,0 +1,43 @@ +// generated by codegen +/** + * This module provides the generated definition of `Module`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Declaration + +/** + * INTERNAL: This module contains the fully generated definition of `Module` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::Module` class directly. + * Use the subclass `Module`, where the following predicates are available. + */ + class Module extends Synth::TModule, Declaration { + override string getAPrimaryQlClass() { result = "Module" } + + /** + * Gets the `index`th declaration of this module (0-based). + */ + Declaration getDeclaration(int index) { + result = + Synth::convertDeclarationFromRaw(Synth::convertModuleToRaw(this) + .(Raw::Module) + .getDeclaration(index)) + } + + /** + * Gets any of the declarations of this module. + */ + final Declaration getADeclaration() { result = this.getDeclaration(_) } + + /** + * Gets the number of declarations of this module. + */ + final int getNumberOfDeclarations() { result = count(int i | exists(this.getDeclaration(i))) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/OffsetOfExpr.qll b/rust/ql/lib/codeql/rust/generated/OffsetOfExpr.qll new file mode 100644 index 000000000000..c481a52cff4a --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/OffsetOfExpr.qll @@ -0,0 +1,51 @@ +// generated by codegen +/** + * This module provides the generated definition of `OffsetOfExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr +import codeql.rust.elements.TypeRef + +/** + * INTERNAL: This module contains the fully generated definition of `OffsetOfExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::OffsetOfExpr` class directly. + * Use the subclass `OffsetOfExpr`, where the following predicates are available. + */ + class OffsetOfExpr extends Synth::TOffsetOfExpr, Expr { + override string getAPrimaryQlClass() { result = "OffsetOfExpr" } + + /** + * Gets the container of this offset of expression. + */ + TypeRef getContainer() { + result = + Synth::convertTypeRefFromRaw(Synth::convertOffsetOfExprToRaw(this) + .(Raw::OffsetOfExpr) + .getContainer()) + } + + /** + * Gets the `index`th field of this offset of expression (0-based). + */ + string getField(int index) { + result = Synth::convertOffsetOfExprToRaw(this).(Raw::OffsetOfExpr).getField(index) + } + + /** + * Gets any of the fields of this offset of expression. + */ + final string getAField() { result = this.getField(_) } + + /** + * Gets the number of fields of this offset of expression. + */ + final int getNumberOfFields() { result = count(int i | exists(this.getField(i))) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/OrPat.qll b/rust/ql/lib/codeql/rust/generated/OrPat.qll new file mode 100644 index 000000000000..8f1541ea9b31 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/OrPat.qll @@ -0,0 +1,40 @@ +// generated by codegen +/** + * This module provides the generated definition of `OrPat`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Pat + +/** + * INTERNAL: This module contains the fully generated definition of `OrPat` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::OrPat` class directly. + * Use the subclass `OrPat`, where the following predicates are available. + */ + class OrPat extends Synth::TOrPat, Pat { + override string getAPrimaryQlClass() { result = "OrPat" } + + /** + * Gets the `index`th argument of this or pat (0-based). + */ + Pat getArg(int index) { + result = Synth::convertPatFromRaw(Synth::convertOrPatToRaw(this).(Raw::OrPat).getArg(index)) + } + + /** + * Gets any of the arguments of this or pat. + */ + final Pat getAnArg() { result = this.getArg(_) } + + /** + * Gets the number of arguments of this or pat. + */ + final int getNumberOfArgs() { result = count(int i | exists(this.getArg(i))) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/ParentChild.qll b/rust/ql/lib/codeql/rust/generated/ParentChild.qll new file mode 100644 index 000000000000..a383e174b769 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/ParentChild.qll @@ -0,0 +1,1464 @@ +// generated by codegen +/** + * This module provides the generated parent/child relationship. + */ + +import codeql.rust.elements + +private module Impl { + private Element getImmediateChildOfElement(Element e, int index, string partialPredicateCall) { + none() + } + + private Element getImmediateChildOfFile(File e, int index, string partialPredicateCall) { + exists(int b, int bElement, int n | + b = 0 and + bElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfElement(e, i, _)) | i) and + n = bElement and + ( + none() + or + result = getImmediateChildOfElement(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfLocatable(Locatable e, int index, string partialPredicateCall) { + exists(int b, int bElement, int n | + b = 0 and + bElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfElement(e, i, _)) | i) and + n = bElement and + ( + none() + or + result = getImmediateChildOfElement(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfLocation(Location e, int index, string partialPredicateCall) { + exists(int b, int bElement, int n | + b = 0 and + bElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfElement(e, i, _)) | i) and + n = bElement and + ( + none() + or + result = getImmediateChildOfElement(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfAstNode(AstNode e, int index, string partialPredicateCall) { + exists(int b, int bLocatable, int n | + b = 0 and + bLocatable = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocatable(e, i, _)) | i) and + n = bLocatable and + ( + none() + or + result = getImmediateChildOfLocatable(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfDbFile(DbFile e, int index, string partialPredicateCall) { + exists(int b, int bFile, int n | + b = 0 and + bFile = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfFile(e, i, _)) | i) and + n = bFile and + ( + none() + or + result = getImmediateChildOfFile(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfDbLocation(DbLocation e, int index, string partialPredicateCall) { + exists(int b, int bLocation, int n | + b = 0 and + bLocation = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocation(e, i, _)) | i) and + n = bLocation and + ( + none() + or + result = getImmediateChildOfLocation(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfUnknownFile( + UnknownFile e, int index, string partialPredicateCall + ) { + exists(int b, int bFile, int n | + b = 0 and + bFile = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfFile(e, i, _)) | i) and + n = bFile and + ( + none() + or + result = getImmediateChildOfFile(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfUnknownLocation( + UnknownLocation e, int index, string partialPredicateCall + ) { + exists(int b, int bLocation, int n | + b = 0 and + bLocation = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocation(e, i, _)) | i) and + n = bLocation and + ( + none() + or + result = getImmediateChildOfLocation(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfDeclaration( + Declaration e, int index, string partialPredicateCall + ) { + exists(int b, int bAstNode, int n | + b = 0 and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and + n = bAstNode and + ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfExpr(Expr e, int index, string partialPredicateCall) { + exists(int b, int bAstNode, int n | + b = 0 and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and + n = bAstNode and + ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfLabel(Label e, int index, string partialPredicateCall) { + exists(int b, int bAstNode, int n | + b = 0 and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and + n = bAstNode and + ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfMatchArm(MatchArm e, int index, string partialPredicateCall) { + exists(int b, int bAstNode, int n, int nPat, int nGuard, int nExpr | + b = 0 and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and + n = bAstNode and + nPat = n + 1 and + nGuard = nPat + 1 and + nExpr = nGuard + 1 and + ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + or + index = n and result = e.getPat() and partialPredicateCall = "Pat()" + or + index = nPat and result = e.getGuard() and partialPredicateCall = "Guard()" + or + index = nGuard and result = e.getExpr() and partialPredicateCall = "Expr()" + ) + ) + } + + private Element getImmediateChildOfPat(Pat e, int index, string partialPredicateCall) { + exists(int b, int bAstNode, int n | + b = 0 and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and + n = bAstNode and + ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfRecordFieldPat( + RecordFieldPat e, int index, string partialPredicateCall + ) { + exists(int b, int bAstNode, int n, int nPat | + b = 0 and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and + n = bAstNode and + nPat = n + 1 and + ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + or + index = n and result = e.getPat() and partialPredicateCall = "Pat()" + ) + ) + } + + private Element getImmediateChildOfRecordLitField( + RecordLitField e, int index, string partialPredicateCall + ) { + exists(int b, int bAstNode, int n, int nExpr | + b = 0 and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and + n = bAstNode and + nExpr = n + 1 and + ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + ) + ) + } + + private Element getImmediateChildOfStmt(Stmt e, int index, string partialPredicateCall) { + exists(int b, int bAstNode, int n | + b = 0 and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and + n = bAstNode and + ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfTypeRef(TypeRef e, int index, string partialPredicateCall) { + exists(int b, int bAstNode, int n | + b = 0 and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and + n = bAstNode and + ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfUnimplemented( + Unimplemented e, int index, string partialPredicateCall + ) { + exists(int b, int bAstNode, int n | + b = 0 and + bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and + n = bAstNode and + ( + none() + or + result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfArrayExpr(ArrayExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfAwaitExpr(AwaitExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nExpr | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nExpr = n + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + ) + ) + } + + private Element getImmediateChildOfBecomeExpr(BecomeExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nExpr | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nExpr = n + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + ) + ) + } + + private Element getImmediateChildOfBinaryOpExpr( + BinaryOpExpr e, int index, string partialPredicateCall + ) { + exists(int b, int bExpr, int n, int nLhs, int nRhs | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nLhs = n + 1 and + nRhs = nLhs + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getLhs() and partialPredicateCall = "Lhs()" + or + index = nLhs and result = e.getRhs() and partialPredicateCall = "Rhs()" + ) + ) + } + + private Element getImmediateChildOfBindPat(BindPat e, int index, string partialPredicateCall) { + exists(int b, int bPat, int n, int nSubpat | + b = 0 and + bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and + n = bPat and + nSubpat = n + 1 and + ( + none() + or + result = getImmediateChildOfPat(e, index - b, partialPredicateCall) + or + index = n and result = e.getSubpat() and partialPredicateCall = "Subpat()" + ) + ) + } + + private Element getImmediateChildOfBlockExprBase( + BlockExprBase e, int index, string partialPredicateCall + ) { + exists(int b, int bExpr, int n, int nStatement, int nTail | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nStatement = n + 1 + max(int i | i = -1 or exists(e.getStatement(i)) | i) and + nTail = nStatement + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + result = e.getStatement(index - n) and + partialPredicateCall = "Statement(" + (index - n).toString() + ")" + or + index = nStatement and result = e.getTail() and partialPredicateCall = "Tail()" + ) + ) + } + + private Element getImmediateChildOfBoxExpr(BoxExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nExpr | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nExpr = n + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + ) + ) + } + + private Element getImmediateChildOfBoxPat(BoxPat e, int index, string partialPredicateCall) { + exists(int b, int bPat, int n, int nInner | + b = 0 and + bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and + n = bPat and + nInner = n + 1 and + ( + none() + or + result = getImmediateChildOfPat(e, index - b, partialPredicateCall) + or + index = n and result = e.getInner() and partialPredicateCall = "Inner()" + ) + ) + } + + private Element getImmediateChildOfBreakExpr(BreakExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nExpr, int nLabel | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nExpr = n + 1 and + nLabel = nExpr + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + or + index = nExpr and result = e.getLabel() and partialPredicateCall = "Label()" + ) + ) + } + + private Element getImmediateChildOfCallExpr(CallExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nCallee, int nArg | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nCallee = n + 1 and + nArg = nCallee + 1 + max(int i | i = -1 or exists(e.getArg(i)) | i) and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getCallee() and partialPredicateCall = "Callee()" + or + result = e.getArg(index - nCallee) and + partialPredicateCall = "Arg(" + (index - nCallee).toString() + ")" + ) + ) + } + + private Element getImmediateChildOfCastExpr(CastExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nExpr, int nTypeRef | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nExpr = n + 1 and + nTypeRef = nExpr + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + or + index = nExpr and result = e.getTypeRef() and partialPredicateCall = "TypeRef()" + ) + ) + } + + private Element getImmediateChildOfClosureExpr( + ClosureExpr e, int index, string partialPredicateCall + ) { + exists(int b, int bExpr, int n, int nArg, int nArgType, int nRetType, int nBody | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nArg = n + 1 + max(int i | i = -1 or exists(e.getArg(i)) | i) and + nArgType = nArg + 1 + max(int i | i = -1 or exists(e.getArgType(i)) | i) and + nRetType = nArgType + 1 and + nBody = nRetType + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + result = e.getArg(index - n) and + partialPredicateCall = "Arg(" + (index - n).toString() + ")" + or + result = e.getArgType(index - nArg) and + partialPredicateCall = "ArgType(" + (index - nArg).toString() + ")" + or + index = nArgType and result = e.getRetType() and partialPredicateCall = "RetType()" + or + index = nRetType and result = e.getBody() and partialPredicateCall = "Body()" + ) + ) + } + + private Element getImmediateChildOfConstBlockPat( + ConstBlockPat e, int index, string partialPredicateCall + ) { + exists(int b, int bPat, int n, int nExpr | + b = 0 and + bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and + n = bPat and + nExpr = n + 1 and + ( + none() + or + result = getImmediateChildOfPat(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + ) + ) + } + + private Element getImmediateChildOfConstExpr(ConstExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nExpr | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nExpr = n + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + ) + ) + } + + private Element getImmediateChildOfContinueExpr( + ContinueExpr e, int index, string partialPredicateCall + ) { + exists(int b, int bExpr, int n, int nLabel | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nLabel = n + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getLabel() and partialPredicateCall = "Label()" + ) + ) + } + + private Element getImmediateChildOfExprStmt(ExprStmt e, int index, string partialPredicateCall) { + exists(int b, int bStmt, int n, int nExpr | + b = 0 and + bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and + n = bStmt and + nExpr = n + 1 and + ( + none() + or + result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + ) + ) + } + + private Element getImmediateChildOfFieldExpr(FieldExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nExpr | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nExpr = n + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + ) + ) + } + + private Element getImmediateChildOfFunction(Function e, int index, string partialPredicateCall) { + exists(int b, int bDeclaration, int n, int nBody | + b = 0 and + bDeclaration = + b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDeclaration(e, i, _)) | i) and + n = bDeclaration and + nBody = n + 1 and + ( + none() + or + result = getImmediateChildOfDeclaration(e, index - b, partialPredicateCall) + or + index = n and result = e.getBody() and partialPredicateCall = "Body()" + ) + ) + } + + private Element getImmediateChildOfIfExpr(IfExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nCondition, int nThen, int nElse | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nCondition = n + 1 and + nThen = nCondition + 1 and + nElse = nThen + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getCondition() and partialPredicateCall = "Condition()" + or + index = nCondition and result = e.getThen() and partialPredicateCall = "Then()" + or + index = nThen and result = e.getElse() and partialPredicateCall = "Else()" + ) + ) + } + + private Element getImmediateChildOfIndexExpr(IndexExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nBase, int nIndex | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nBase = n + 1 and + nIndex = nBase + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getBase() and partialPredicateCall = "Base()" + or + index = nBase and result = e.getIndex() and partialPredicateCall = "Index()" + ) + ) + } + + private Element getImmediateChildOfInlineAsmExpr( + InlineAsmExpr e, int index, string partialPredicateCall + ) { + exists(int b, int bExpr, int n, int nExpr | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nExpr = n + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + ) + ) + } + + private Element getImmediateChildOfItemStmt(ItemStmt e, int index, string partialPredicateCall) { + exists(int b, int bStmt, int n | + b = 0 and + bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and + n = bStmt and + ( + none() + or + result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfLetExpr(LetExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nPat, int nExpr | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nPat = n + 1 and + nExpr = nPat + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getPat() and partialPredicateCall = "Pat()" + or + index = nPat and result = e.getExpr() and partialPredicateCall = "Expr()" + ) + ) + } + + private Element getImmediateChildOfLetStmt(LetStmt e, int index, string partialPredicateCall) { + exists(int b, int bStmt, int n, int nPat, int nTypeRef, int nInitializer, int nElse | + b = 0 and + bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and + n = bStmt and + nPat = n + 1 and + nTypeRef = nPat + 1 and + nInitializer = nTypeRef + 1 and + nElse = nInitializer + 1 and + ( + none() + or + result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) + or + index = n and result = e.getPat() and partialPredicateCall = "Pat()" + or + index = nPat and result = e.getTypeRef() and partialPredicateCall = "TypeRef()" + or + index = nTypeRef and result = e.getInitializer() and partialPredicateCall = "Initializer()" + or + index = nInitializer and result = e.getElse() and partialPredicateCall = "Else()" + ) + ) + } + + private Element getImmediateChildOfLitPat(LitPat e, int index, string partialPredicateCall) { + exists(int b, int bPat, int n, int nExpr | + b = 0 and + bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and + n = bPat and + nExpr = n + 1 and + ( + none() + or + result = getImmediateChildOfPat(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + ) + ) + } + + private Element getImmediateChildOfLiteralExpr( + LiteralExpr e, int index, string partialPredicateCall + ) { + exists(int b, int bExpr, int n | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfLoopExpr(LoopExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nBody, int nLabel | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nBody = n + 1 and + nLabel = nBody + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getBody() and partialPredicateCall = "Body()" + or + index = nBody and result = e.getLabel() and partialPredicateCall = "Label()" + ) + ) + } + + private Element getImmediateChildOfMatchExpr(MatchExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nExpr, int nBranch | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nExpr = n + 1 and + nBranch = nExpr + 1 + max(int i | i = -1 or exists(e.getBranch(i)) | i) and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + or + result = e.getBranch(index - nExpr) and + partialPredicateCall = "Branch(" + (index - nExpr).toString() + ")" + ) + ) + } + + private Element getImmediateChildOfMethodCallExpr( + MethodCallExpr e, int index, string partialPredicateCall + ) { + exists(int b, int bExpr, int n, int nReceiver, int nArg, int nGenericArgs | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nReceiver = n + 1 and + nArg = nReceiver + 1 + max(int i | i = -1 or exists(e.getArg(i)) | i) and + nGenericArgs = nArg + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getReceiver() and partialPredicateCall = "Receiver()" + or + result = e.getArg(index - nReceiver) and + partialPredicateCall = "Arg(" + (index - nReceiver).toString() + ")" + or + index = nArg and result = e.getGenericArgs() and partialPredicateCall = "GenericArgs()" + ) + ) + } + + private Element getImmediateChildOfMissingExpr( + MissingExpr e, int index, string partialPredicateCall + ) { + exists(int b, int bExpr, int n | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfMissingPat(MissingPat e, int index, string partialPredicateCall) { + exists(int b, int bPat, int n | + b = 0 and + bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and + n = bPat and + ( + none() + or + result = getImmediateChildOfPat(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfModule(Module e, int index, string partialPredicateCall) { + exists(int b, int bDeclaration, int n, int nDeclaration | + b = 0 and + bDeclaration = + b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDeclaration(e, i, _)) | i) and + n = bDeclaration and + nDeclaration = n + 1 + max(int i | i = -1 or exists(e.getDeclaration(i)) | i) and + ( + none() + or + result = getImmediateChildOfDeclaration(e, index - b, partialPredicateCall) + or + result = e.getDeclaration(index - n) and + partialPredicateCall = "Declaration(" + (index - n).toString() + ")" + ) + ) + } + + private Element getImmediateChildOfOffsetOfExpr( + OffsetOfExpr e, int index, string partialPredicateCall + ) { + exists(int b, int bExpr, int n, int nContainer | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nContainer = n + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getContainer() and partialPredicateCall = "Container()" + ) + ) + } + + private Element getImmediateChildOfOrPat(OrPat e, int index, string partialPredicateCall) { + exists(int b, int bPat, int n, int nArg | + b = 0 and + bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and + n = bPat and + nArg = n + 1 + max(int i | i = -1 or exists(e.getArg(i)) | i) and + ( + none() + or + result = getImmediateChildOfPat(e, index - b, partialPredicateCall) + or + result = e.getArg(index - n) and + partialPredicateCall = "Arg(" + (index - n).toString() + ")" + ) + ) + } + + private Element getImmediateChildOfPathExpr(PathExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nPath | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nPath = n + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getPath() and partialPredicateCall = "Path()" + ) + ) + } + + private Element getImmediateChildOfPathPat(PathPat e, int index, string partialPredicateCall) { + exists(int b, int bPat, int n, int nPath | + b = 0 and + bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and + n = bPat and + nPath = n + 1 and + ( + none() + or + result = getImmediateChildOfPat(e, index - b, partialPredicateCall) + or + index = n and result = e.getPath() and partialPredicateCall = "Path()" + ) + ) + } + + private Element getImmediateChildOfRangeExpr(RangeExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nLhs, int nRhs | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nLhs = n + 1 and + nRhs = nLhs + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getLhs() and partialPredicateCall = "Lhs()" + or + index = nLhs and result = e.getRhs() and partialPredicateCall = "Rhs()" + ) + ) + } + + private Element getImmediateChildOfRangePat(RangePat e, int index, string partialPredicateCall) { + exists(int b, int bPat, int n, int nStart, int nEnd | + b = 0 and + bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and + n = bPat and + nStart = n + 1 and + nEnd = nStart + 1 and + ( + none() + or + result = getImmediateChildOfPat(e, index - b, partialPredicateCall) + or + index = n and result = e.getStart() and partialPredicateCall = "Start()" + or + index = nStart and result = e.getEnd() and partialPredicateCall = "End()" + ) + ) + } + + private Element getImmediateChildOfRecordLitExpr( + RecordLitExpr e, int index, string partialPredicateCall + ) { + exists(int b, int bExpr, int n, int nPath, int nField, int nSpread | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nPath = n + 1 and + nField = nPath + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and + nSpread = nField + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getPath() and partialPredicateCall = "Path()" + or + result = e.getField(index - nPath) and + partialPredicateCall = "Field(" + (index - nPath).toString() + ")" + or + index = nField and result = e.getSpread() and partialPredicateCall = "Spread()" + ) + ) + } + + private Element getImmediateChildOfRecordPat(RecordPat e, int index, string partialPredicateCall) { + exists(int b, int bPat, int n, int nPath, int nArg | + b = 0 and + bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and + n = bPat and + nPath = n + 1 and + nArg = nPath + 1 + max(int i | i = -1 or exists(e.getArg(i)) | i) and + ( + none() + or + result = getImmediateChildOfPat(e, index - b, partialPredicateCall) + or + index = n and result = e.getPath() and partialPredicateCall = "Path()" + or + result = e.getArg(index - nPath) and + partialPredicateCall = "Arg(" + (index - nPath).toString() + ")" + ) + ) + } + + private Element getImmediateChildOfRefExpr(RefExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nExpr | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nExpr = n + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + ) + ) + } + + private Element getImmediateChildOfRefPat(RefPat e, int index, string partialPredicateCall) { + exists(int b, int bPat, int n, int nPat | + b = 0 and + bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and + n = bPat and + nPat = n + 1 and + ( + none() + or + result = getImmediateChildOfPat(e, index - b, partialPredicateCall) + or + index = n and result = e.getPat() and partialPredicateCall = "Pat()" + ) + ) + } + + private Element getImmediateChildOfReturnExpr(ReturnExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nExpr | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nExpr = n + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + ) + ) + } + + private Element getImmediateChildOfSlicePat(SlicePat e, int index, string partialPredicateCall) { + exists(int b, int bPat, int n, int nPrefix, int nSlice, int nSuffix | + b = 0 and + bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and + n = bPat and + nPrefix = n + 1 + max(int i | i = -1 or exists(e.getPrefix(i)) | i) and + nSlice = nPrefix + 1 and + nSuffix = nSlice + 1 + max(int i | i = -1 or exists(e.getSuffix(i)) | i) and + ( + none() + or + result = getImmediateChildOfPat(e, index - b, partialPredicateCall) + or + result = e.getPrefix(index - n) and + partialPredicateCall = "Prefix(" + (index - n).toString() + ")" + or + index = nPrefix and result = e.getSlice() and partialPredicateCall = "Slice()" + or + result = e.getSuffix(index - nSlice) and + partialPredicateCall = "Suffix(" + (index - nSlice).toString() + ")" + ) + ) + } + + private Element getImmediateChildOfTupleExpr(TupleExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nExpr | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nExpr = n + 1 + max(int i | i = -1 or exists(e.getExpr(i)) | i) and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + result = e.getExpr(index - n) and + partialPredicateCall = "Expr(" + (index - n).toString() + ")" + ) + ) + } + + private Element getImmediateChildOfTuplePat(TuplePat e, int index, string partialPredicateCall) { + exists(int b, int bPat, int n, int nArg | + b = 0 and + bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and + n = bPat and + nArg = n + 1 + max(int i | i = -1 or exists(e.getArg(i)) | i) and + ( + none() + or + result = getImmediateChildOfPat(e, index - b, partialPredicateCall) + or + result = e.getArg(index - n) and + partialPredicateCall = "Arg(" + (index - n).toString() + ")" + ) + ) + } + + private Element getImmediateChildOfTupleStructPat( + TupleStructPat e, int index, string partialPredicateCall + ) { + exists(int b, int bPat, int n, int nPath, int nArg | + b = 0 and + bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and + n = bPat and + nPath = n + 1 and + nArg = nPath + 1 + max(int i | i = -1 or exists(e.getArg(i)) | i) and + ( + none() + or + result = getImmediateChildOfPat(e, index - b, partialPredicateCall) + or + index = n and result = e.getPath() and partialPredicateCall = "Path()" + or + result = e.getArg(index - nPath) and + partialPredicateCall = "Arg(" + (index - nPath).toString() + ")" + ) + ) + } + + private Element getImmediateChildOfUnaryOpExpr( + UnaryOpExpr e, int index, string partialPredicateCall + ) { + exists(int b, int bExpr, int n, int nExpr | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nExpr = n + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + ) + ) + } + + private Element getImmediateChildOfUnderscoreExpr( + UnderscoreExpr e, int index, string partialPredicateCall + ) { + exists(int b, int bExpr, int n | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfWildPat(WildPat e, int index, string partialPredicateCall) { + exists(int b, int bPat, int n | + b = 0 and + bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and + n = bPat and + ( + none() + or + result = getImmediateChildOfPat(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfYeetExpr(YeetExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nExpr | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nExpr = n + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + ) + ) + } + + private Element getImmediateChildOfYieldExpr(YieldExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nExpr | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nExpr = n + 1 and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getExpr() and partialPredicateCall = "Expr()" + ) + ) + } + + private Element getImmediateChildOfAsyncBlockExpr( + AsyncBlockExpr e, int index, string partialPredicateCall + ) { + exists(int b, int bBlockExprBase, int n | + b = 0 and + bBlockExprBase = + b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBlockExprBase(e, i, _)) | i) and + n = bBlockExprBase and + ( + none() + or + result = getImmediateChildOfBlockExprBase(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfBlockExpr(BlockExpr e, int index, string partialPredicateCall) { + exists(int b, int bBlockExprBase, int n, int nLabel | + b = 0 and + bBlockExprBase = + b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBlockExprBase(e, i, _)) | i) and + n = bBlockExprBase and + nLabel = n + 1 and + ( + none() + or + result = getImmediateChildOfBlockExprBase(e, index - b, partialPredicateCall) + or + index = n and result = e.getLabel() and partialPredicateCall = "Label()" + ) + ) + } + + private Element getImmediateChildOfElementListExpr( + ElementListExpr e, int index, string partialPredicateCall + ) { + exists(int b, int bArrayExpr, int n, int nElement | + b = 0 and + bArrayExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArrayExpr(e, i, _)) | i) and + n = bArrayExpr and + nElement = n + 1 + max(int i | i = -1 or exists(e.getElement(i)) | i) and + ( + none() + or + result = getImmediateChildOfArrayExpr(e, index - b, partialPredicateCall) + or + result = e.getElement(index - n) and + partialPredicateCall = "Element(" + (index - n).toString() + ")" + ) + ) + } + + private Element getImmediateChildOfRepeatExpr(RepeatExpr e, int index, string partialPredicateCall) { + exists(int b, int bArrayExpr, int n, int nInitializer, int nRepeat | + b = 0 and + bArrayExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArrayExpr(e, i, _)) | i) and + n = bArrayExpr and + nInitializer = n + 1 and + nRepeat = nInitializer + 1 and + ( + none() + or + result = getImmediateChildOfArrayExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getInitializer() and partialPredicateCall = "Initializer()" + or + index = nInitializer and result = e.getRepeat() and partialPredicateCall = "Repeat()" + ) + ) + } + + private Element getImmediateChildOfUnsafeBlockExpr( + UnsafeBlockExpr e, int index, string partialPredicateCall + ) { + exists(int b, int bBlockExprBase, int n | + b = 0 and + bBlockExprBase = + b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBlockExprBase(e, i, _)) | i) and + n = bBlockExprBase and + ( + none() + or + result = getImmediateChildOfBlockExprBase(e, index - b, partialPredicateCall) + ) + ) + } + + cached + Element getImmediateChild(Element e, int index, string partialAccessor) { + // why does this look more complicated than it should? + // * none() simplifies generation, as we can append `or ...` without a special case for the first item + none() + or + result = getImmediateChildOfDbFile(e, index, partialAccessor) + or + result = getImmediateChildOfDbLocation(e, index, partialAccessor) + or + result = getImmediateChildOfUnknownFile(e, index, partialAccessor) + or + result = getImmediateChildOfUnknownLocation(e, index, partialAccessor) + or + result = getImmediateChildOfLabel(e, index, partialAccessor) + or + result = getImmediateChildOfMatchArm(e, index, partialAccessor) + or + result = getImmediateChildOfRecordFieldPat(e, index, partialAccessor) + or + result = getImmediateChildOfRecordLitField(e, index, partialAccessor) + or + result = getImmediateChildOfTypeRef(e, index, partialAccessor) + or + result = getImmediateChildOfUnimplemented(e, index, partialAccessor) + or + result = getImmediateChildOfAwaitExpr(e, index, partialAccessor) + or + result = getImmediateChildOfBecomeExpr(e, index, partialAccessor) + or + result = getImmediateChildOfBinaryOpExpr(e, index, partialAccessor) + or + result = getImmediateChildOfBindPat(e, index, partialAccessor) + or + result = getImmediateChildOfBoxExpr(e, index, partialAccessor) + or + result = getImmediateChildOfBoxPat(e, index, partialAccessor) + or + result = getImmediateChildOfBreakExpr(e, index, partialAccessor) + or + result = getImmediateChildOfCallExpr(e, index, partialAccessor) + or + result = getImmediateChildOfCastExpr(e, index, partialAccessor) + or + result = getImmediateChildOfClosureExpr(e, index, partialAccessor) + or + result = getImmediateChildOfConstBlockPat(e, index, partialAccessor) + or + result = getImmediateChildOfConstExpr(e, index, partialAccessor) + or + result = getImmediateChildOfContinueExpr(e, index, partialAccessor) + or + result = getImmediateChildOfExprStmt(e, index, partialAccessor) + or + result = getImmediateChildOfFieldExpr(e, index, partialAccessor) + or + result = getImmediateChildOfFunction(e, index, partialAccessor) + or + result = getImmediateChildOfIfExpr(e, index, partialAccessor) + or + result = getImmediateChildOfIndexExpr(e, index, partialAccessor) + or + result = getImmediateChildOfInlineAsmExpr(e, index, partialAccessor) + or + result = getImmediateChildOfItemStmt(e, index, partialAccessor) + or + result = getImmediateChildOfLetExpr(e, index, partialAccessor) + or + result = getImmediateChildOfLetStmt(e, index, partialAccessor) + or + result = getImmediateChildOfLitPat(e, index, partialAccessor) + or + result = getImmediateChildOfLiteralExpr(e, index, partialAccessor) + or + result = getImmediateChildOfLoopExpr(e, index, partialAccessor) + or + result = getImmediateChildOfMatchExpr(e, index, partialAccessor) + or + result = getImmediateChildOfMethodCallExpr(e, index, partialAccessor) + or + result = getImmediateChildOfMissingExpr(e, index, partialAccessor) + or + result = getImmediateChildOfMissingPat(e, index, partialAccessor) + or + result = getImmediateChildOfModule(e, index, partialAccessor) + or + result = getImmediateChildOfOffsetOfExpr(e, index, partialAccessor) + or + result = getImmediateChildOfOrPat(e, index, partialAccessor) + or + result = getImmediateChildOfPathExpr(e, index, partialAccessor) + or + result = getImmediateChildOfPathPat(e, index, partialAccessor) + or + result = getImmediateChildOfRangeExpr(e, index, partialAccessor) + or + result = getImmediateChildOfRangePat(e, index, partialAccessor) + or + result = getImmediateChildOfRecordLitExpr(e, index, partialAccessor) + or + result = getImmediateChildOfRecordPat(e, index, partialAccessor) + or + result = getImmediateChildOfRefExpr(e, index, partialAccessor) + or + result = getImmediateChildOfRefPat(e, index, partialAccessor) + or + result = getImmediateChildOfReturnExpr(e, index, partialAccessor) + or + result = getImmediateChildOfSlicePat(e, index, partialAccessor) + or + result = getImmediateChildOfTupleExpr(e, index, partialAccessor) + or + result = getImmediateChildOfTuplePat(e, index, partialAccessor) + or + result = getImmediateChildOfTupleStructPat(e, index, partialAccessor) + or + result = getImmediateChildOfUnaryOpExpr(e, index, partialAccessor) + or + result = getImmediateChildOfUnderscoreExpr(e, index, partialAccessor) + or + result = getImmediateChildOfWildPat(e, index, partialAccessor) + or + result = getImmediateChildOfYeetExpr(e, index, partialAccessor) + or + result = getImmediateChildOfYieldExpr(e, index, partialAccessor) + or + result = getImmediateChildOfAsyncBlockExpr(e, index, partialAccessor) + or + result = getImmediateChildOfBlockExpr(e, index, partialAccessor) + or + result = getImmediateChildOfElementListExpr(e, index, partialAccessor) + or + result = getImmediateChildOfRepeatExpr(e, index, partialAccessor) + or + result = getImmediateChildOfUnsafeBlockExpr(e, index, partialAccessor) + } +} + +/** + * Gets the "immediate" parent of `e`. "Immediate" means not taking into account node resolution: for example + * if `e` has conversions, `getImmediateParent(e)` will give the innermost conversion in the hidden AST. + */ +Element getImmediateParent(Element e) { + // `unique` is used here to tell the optimizer that there is in fact only one result + // this is tested by the `library-tests/parent/no_double_parents.ql` test + result = unique(Element x | e = Impl::getImmediateChild(x, _, _) | x) +} + +/** + * Gets the immediate child indexed at `index`. Indexes are not guaranteed to be contiguous, but are guaranteed to be distinct. `accessor` is bound the member predicate call resulting in the given child. + */ +Element getImmediateChildAndAccessor(Element e, int index, string accessor) { + exists(string partialAccessor | + result = Impl::getImmediateChild(e, index, partialAccessor) and + accessor = "get" + partialAccessor + ) +} + +/** + * Gets the child indexed at `index`. Indexes are not guaranteed to be contiguous, but are guaranteed to be distinct. `accessor` is bound the member predicate call resulting in the given child. + */ +Element getChildAndAccessor(Element e, int index, string accessor) { + exists(string partialAccessor | + result = Impl::getImmediateChild(e, index, partialAccessor).resolve() and + accessor = "get" + partialAccessor + ) +} diff --git a/rust/ql/lib/codeql/rust/generated/Pat.qll b/rust/ql/lib/codeql/rust/generated/Pat.qll new file mode 100644 index 000000000000..c21fcf46d715 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/Pat.qll @@ -0,0 +1,21 @@ +// generated by codegen +/** + * This module provides the generated definition of `Pat`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.AstNode + +/** + * INTERNAL: This module contains the fully generated definition of `Pat` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::Pat` class directly. + * Use the subclass `Pat`, where the following predicates are available. + */ + class Pat extends Synth::TPat, AstNode { } +} diff --git a/rust/ql/lib/codeql/rust/generated/PathExpr.qll b/rust/ql/lib/codeql/rust/generated/PathExpr.qll new file mode 100644 index 000000000000..7a164820a73d --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/PathExpr.qll @@ -0,0 +1,34 @@ +// generated by codegen +/** + * This module provides the generated definition of `PathExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr +import codeql.rust.elements.Unimplemented + +/** + * INTERNAL: This module contains the fully generated definition of `PathExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::PathExpr` class directly. + * Use the subclass `PathExpr`, where the following predicates are available. + */ + class PathExpr extends Synth::TPathExpr, Expr { + override string getAPrimaryQlClass() { result = "PathExpr" } + + /** + * Gets the path of this path expression. + */ + Unimplemented getPath() { + result = + Synth::convertUnimplementedFromRaw(Synth::convertPathExprToRaw(this) + .(Raw::PathExpr) + .getPath()) + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/PathPat.qll b/rust/ql/lib/codeql/rust/generated/PathPat.qll new file mode 100644 index 000000000000..5fb2acfb13cf --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/PathPat.qll @@ -0,0 +1,32 @@ +// generated by codegen +/** + * This module provides the generated definition of `PathPat`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Pat +import codeql.rust.elements.Unimplemented + +/** + * INTERNAL: This module contains the fully generated definition of `PathPat` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::PathPat` class directly. + * Use the subclass `PathPat`, where the following predicates are available. + */ + class PathPat extends Synth::TPathPat, Pat { + override string getAPrimaryQlClass() { result = "PathPat" } + + /** + * Gets the path of this path pat. + */ + Unimplemented getPath() { + result = + Synth::convertUnimplementedFromRaw(Synth::convertPathPatToRaw(this).(Raw::PathPat).getPath()) + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/PureSynthConstructors.qll b/rust/ql/lib/codeql/rust/generated/PureSynthConstructors.qll new file mode 100644 index 000000000000..db7165ee7791 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/PureSynthConstructors.qll @@ -0,0 +1,5 @@ +// generated by codegen +/** + * This module exports all modules providing `Element` subclasses. + */ + diff --git a/rust/ql/lib/codeql/rust/generated/RangeExpr.qll b/rust/ql/lib/codeql/rust/generated/RangeExpr.qll new file mode 100644 index 000000000000..d1d783e22880 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/RangeExpr.qll @@ -0,0 +1,54 @@ +// generated by codegen +/** + * This module provides the generated definition of `RangeExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `RangeExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::RangeExpr` class directly. + * Use the subclass `RangeExpr`, where the following predicates are available. + */ + class RangeExpr extends Synth::TRangeExpr, Expr { + override string getAPrimaryQlClass() { result = "RangeExpr" } + + /** + * Gets the lhs of this range expression, if it exists. + */ + Expr getLhs() { + result = + Synth::convertExprFromRaw(Synth::convertRangeExprToRaw(this).(Raw::RangeExpr).getLhs()) + } + + /** + * Holds if `getLhs()` exists. + */ + final predicate hasLhs() { exists(this.getLhs()) } + + /** + * Gets the rhs of this range expression, if it exists. + */ + Expr getRhs() { + result = + Synth::convertExprFromRaw(Synth::convertRangeExprToRaw(this).(Raw::RangeExpr).getRhs()) + } + + /** + * Holds if `getRhs()` exists. + */ + final predicate hasRhs() { exists(this.getRhs()) } + + /** + * Holds if this range expression is inclusive. + */ + predicate isInclusive() { Synth::convertRangeExprToRaw(this).(Raw::RangeExpr).isInclusive() } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/RangePat.qll b/rust/ql/lib/codeql/rust/generated/RangePat.qll new file mode 100644 index 000000000000..f0cfa96e869a --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/RangePat.qll @@ -0,0 +1,48 @@ +// generated by codegen +/** + * This module provides the generated definition of `RangePat`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Pat + +/** + * INTERNAL: This module contains the fully generated definition of `RangePat` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::RangePat` class directly. + * Use the subclass `RangePat`, where the following predicates are available. + */ + class RangePat extends Synth::TRangePat, Pat { + override string getAPrimaryQlClass() { result = "RangePat" } + + /** + * Gets the start of this range pat, if it exists. + */ + Pat getStart() { + result = + Synth::convertPatFromRaw(Synth::convertRangePatToRaw(this).(Raw::RangePat).getStart()) + } + + /** + * Holds if `getStart()` exists. + */ + final predicate hasStart() { exists(this.getStart()) } + + /** + * Gets the end of this range pat, if it exists. + */ + Pat getEnd() { + result = Synth::convertPatFromRaw(Synth::convertRangePatToRaw(this).(Raw::RangePat).getEnd()) + } + + /** + * Holds if `getEnd()` exists. + */ + final predicate hasEnd() { exists(this.getEnd()) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/Raw.qll b/rust/ql/lib/codeql/rust/generated/Raw.qll new file mode 100644 index 000000000000..28531dfe4a0b --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/Raw.qll @@ -0,0 +1,1083 @@ +/** + * INTERNAL: Do not use. + * This module holds thin fully generated class definitions around DB entities. + */ +module Raw { + /** + * INTERNAL: Do not use. + */ + class Element extends @element { + string toString() { none() } + } + + /** + * INTERNAL: Do not use. + */ + class File extends @file, Element { + /** + * Gets the name of this file. + */ + string getName() { files(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class Locatable extends @locatable, Element { + /** + * Gets the location of this locatable, if it exists. + */ + Location getLocation() { locatable_locations(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class Location extends @location, Element { + /** + * Gets the file of this location. + */ + File getFile() { locations(this, result, _, _, _, _) } + + /** + * Gets the start line of this location. + */ + int getStartLine() { locations(this, _, result, _, _, _) } + + /** + * Gets the start column of this location. + */ + int getStartColumn() { locations(this, _, _, result, _, _) } + + /** + * Gets the end line of this location. + */ + int getEndLine() { locations(this, _, _, _, result, _) } + + /** + * Gets the end column of this location. + */ + int getEndColumn() { locations(this, _, _, _, _, result) } + } + + /** + * INTERNAL: Do not use. + */ + class AstNode extends @ast_node, Locatable { } + + /** + * INTERNAL: Do not use. + */ + class DbFile extends @db_file, File { + override string toString() { result = "DbFile" } + } + + /** + * INTERNAL: Do not use. + */ + class DbLocation extends @db_location, Location { + override string toString() { result = "DbLocation" } + } + + /** + * INTERNAL: Do not use. + */ + class Declaration extends @declaration, AstNode { } + + /** + * INTERNAL: Do not use. + */ + class Expr extends @expr, AstNode { } + + /** + * INTERNAL: Do not use. + */ + class Label extends @label, AstNode { + override string toString() { result = "Label" } + + /** + * Gets the name of this label. + */ + string getName() { labels(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class MatchArm extends @match_arm, AstNode { + override string toString() { result = "MatchArm" } + + /** + * Gets the pat of this match arm. + */ + Pat getPat() { match_arms(this, result, _) } + + /** + * Gets the guard of this match arm, if it exists. + */ + Expr getGuard() { match_arm_guards(this, result) } + + /** + * Gets the expression of this match arm. + */ + Expr getExpr() { match_arms(this, _, result) } + } + + /** + * INTERNAL: Do not use. + */ + class Pat extends @pat, AstNode { } + + /** + * INTERNAL: Do not use. + */ + class RecordFieldPat extends @record_field_pat, AstNode { + override string toString() { result = "RecordFieldPat" } + + /** + * Gets the name of this record field pat. + */ + string getName() { record_field_pats(this, result, _) } + + /** + * Gets the pat of this record field pat. + */ + Pat getPat() { record_field_pats(this, _, result) } + } + + /** + * INTERNAL: Do not use. + */ + class RecordLitField extends @record_lit_field, AstNode { + override string toString() { result = "RecordLitField" } + + /** + * Gets the name of this record lit field. + */ + string getName() { record_lit_fields(this, result, _) } + + /** + * Gets the expression of this record lit field. + */ + Expr getExpr() { record_lit_fields(this, _, result) } + } + + /** + * INTERNAL: Do not use. + */ + class Stmt extends @stmt, AstNode { } + + /** + * INTERNAL: Do not use. + */ + class TypeRef extends @type_ref, AstNode { + override string toString() { result = "TypeRef" } + } + + /** + * INTERNAL: Do not use. + */ + class Unimplemented extends @unimplemented, AstNode { + override string toString() { result = "Unimplemented" } + } + + /** + * INTERNAL: Do not use. + */ + class ArrayExpr extends @array_expr, Expr { } + + /** + * INTERNAL: Do not use. + */ + class AwaitExpr extends @await_expr, Expr { + override string toString() { result = "AwaitExpr" } + + /** + * Gets the expression of this await expression. + */ + Expr getExpr() { await_exprs(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class BecomeExpr extends @become_expr, Expr { + override string toString() { result = "BecomeExpr" } + + /** + * Gets the expression of this become expression. + */ + Expr getExpr() { become_exprs(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class BinaryOpExpr extends @binary_op_expr, Expr { + override string toString() { result = "BinaryOpExpr" } + + /** + * Gets the lhs of this binary op expression. + */ + Expr getLhs() { binary_op_exprs(this, result, _) } + + /** + * Gets the rhs of this binary op expression. + */ + Expr getRhs() { binary_op_exprs(this, _, result) } + + /** + * Gets the op of this binary op expression, if it exists. + */ + string getOp() { binary_op_expr_ops(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class BindPat extends @bind_pat, Pat { + override string toString() { result = "BindPat" } + + /** + * Gets the binding of this bind pat. + */ + string getBindingId() { bind_pats(this, result) } + + /** + * Gets the subpat of this bind pat, if it exists. + */ + Pat getSubpat() { bind_pat_subpats(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class BlockExprBase extends @block_expr_base, Expr { + /** + * Gets the `index`th statement of this block expression base (0-based). + */ + Stmt getStatement(int index) { block_expr_base_statements(this, index, result) } + + /** + * Gets the tail of this block expression base, if it exists. + */ + Expr getTail() { block_expr_base_tails(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class BoxExpr extends @box_expr, Expr { + override string toString() { result = "BoxExpr" } + + /** + * Gets the expression of this box expression. + */ + Expr getExpr() { box_exprs(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class BoxPat extends @box_pat, Pat { + override string toString() { result = "BoxPat" } + + /** + * Gets the inner of this box pat. + */ + Pat getInner() { box_pats(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class BreakExpr extends @break_expr, Expr { + override string toString() { result = "BreakExpr" } + + /** + * Gets the expression of this break expression, if it exists. + */ + Expr getExpr() { break_expr_exprs(this, result) } + + /** + * Gets the label of this break expression, if it exists. + */ + Label getLabel() { break_expr_labels(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class CallExpr extends @call_expr, Expr { + override string toString() { result = "CallExpr" } + + /** + * Gets the callee of this call expression. + */ + Expr getCallee() { call_exprs(this, result) } + + /** + * Gets the `index`th argument of this call expression (0-based). + */ + Expr getArg(int index) { call_expr_args(this, index, result) } + + /** + * Holds if this call expression is assignee expression. + */ + predicate isAssigneeExpr() { call_expr_is_assignee_expr(this) } + } + + /** + * INTERNAL: Do not use. + */ + class CastExpr extends @cast_expr, Expr { + override string toString() { result = "CastExpr" } + + /** + * Gets the expression of this cast expression. + */ + Expr getExpr() { cast_exprs(this, result, _) } + + /** + * Gets the type reference of this cast expression. + */ + TypeRef getTypeRef() { cast_exprs(this, _, result) } + } + + /** + * INTERNAL: Do not use. + */ + class ClosureExpr extends @closure_expr, Expr { + override string toString() { result = "ClosureExpr" } + + /** + * Gets the `index`th argument of this closure expression (0-based). + */ + Pat getArg(int index) { closure_expr_args(this, index, result) } + + /** + * Gets the `index`th argument type of this closure expression (0-based), if it exists. + */ + TypeRef getArgType(int index) { closure_expr_arg_types(this, index, result) } + + /** + * Gets the ret type of this closure expression, if it exists. + */ + TypeRef getRetType() { closure_expr_ret_types(this, result) } + + /** + * Gets the body of this closure expression. + */ + Expr getBody() { closure_exprs(this, result, _) } + + /** + * Gets the closure kind of this closure expression. + */ + string getClosureKind() { closure_exprs(this, _, result) } + + /** + * Holds if this closure expression is move. + */ + predicate isMove() { closure_expr_is_move(this) } + } + + /** + * INTERNAL: Do not use. + */ + class ConstBlockPat extends @const_block_pat, Pat { + override string toString() { result = "ConstBlockPat" } + + /** + * Gets the expression of this const block pat. + */ + Expr getExpr() { const_block_pats(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class ConstExpr extends @const_expr, Expr { + override string toString() { result = "ConstExpr" } + + /** + * Gets the expression of this const expression. + */ + Expr getExpr() { const_exprs(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class ContinueExpr extends @continue_expr, Expr { + override string toString() { result = "ContinueExpr" } + + /** + * Gets the label of this continue expression, if it exists. + */ + Label getLabel() { continue_expr_labels(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class ExprStmt extends @expr_stmt, Stmt { + override string toString() { result = "ExprStmt" } + + /** + * Gets the expression of this expression statement. + */ + Expr getExpr() { expr_stmts(this, result) } + + /** + * Holds if this expression statement has semicolon. + */ + predicate hasSemicolon() { expr_stmt_has_semicolon(this) } + } + + /** + * INTERNAL: Do not use. + */ + class FieldExpr extends @field_expr, Expr { + override string toString() { result = "FieldExpr" } + + /** + * Gets the expression of this field expression. + */ + Expr getExpr() { field_exprs(this, result, _) } + + /** + * Gets the name of this field expression. + */ + string getName() { field_exprs(this, _, result) } + } + + /** + * INTERNAL: Do not use. + * A function declaration. For example + * ``` + * fn foo(x: u32) -> u64 { (x + 1).into() } + * ``` + * A function declaration within a trait might not have a body: + * ``` + * trait Trait { + * fn bar(); + * } + * ``` + */ + class Function extends @function, Declaration { + override string toString() { result = "Function" } + + /** + * Gets the name of this function. + */ + string getName() { functions(this, result, _) } + + /** + * Gets the body of this function. + */ + Expr getBody() { functions(this, _, result) } + } + + /** + * INTERNAL: Do not use. + */ + class IfExpr extends @if_expr, Expr { + override string toString() { result = "IfExpr" } + + /** + * Gets the condition of this if expression. + */ + Expr getCondition() { if_exprs(this, result, _) } + + /** + * Gets the then of this if expression. + */ + Expr getThen() { if_exprs(this, _, result) } + + /** + * Gets the else of this if expression, if it exists. + */ + Expr getElse() { if_expr_elses(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class IndexExpr extends @index_expr, Expr { + override string toString() { result = "IndexExpr" } + + /** + * Gets the base of this index expression. + */ + Expr getBase() { index_exprs(this, result, _) } + + /** + * Gets the index of this index expression. + */ + Expr getIndex() { index_exprs(this, _, result) } + + /** + * Holds if this index expression is assignee expression. + */ + predicate isAssigneeExpr() { index_expr_is_assignee_expr(this) } + } + + /** + * INTERNAL: Do not use. + */ + class InlineAsmExpr extends @inline_asm_expr, Expr { + override string toString() { result = "InlineAsmExpr" } + + /** + * Gets the expression of this inline asm expression. + */ + Expr getExpr() { inline_asm_exprs(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class ItemStmt extends @item_stmt, Stmt { + override string toString() { result = "ItemStmt" } + } + + /** + * INTERNAL: Do not use. + */ + class LetExpr extends @let_expr, Expr { + override string toString() { result = "LetExpr" } + + /** + * Gets the pat of this let expression. + */ + Pat getPat() { let_exprs(this, result, _) } + + /** + * Gets the expression of this let expression. + */ + Expr getExpr() { let_exprs(this, _, result) } + } + + /** + * INTERNAL: Do not use. + */ + class LetStmt extends @let_stmt, Stmt { + override string toString() { result = "LetStmt" } + + /** + * Gets the pat of this let statement. + */ + Pat getPat() { let_stmts(this, result) } + + /** + * Gets the type reference of this let statement, if it exists. + */ + TypeRef getTypeRef() { let_stmt_type_refs(this, result) } + + /** + * Gets the initializer of this let statement, if it exists. + */ + Expr getInitializer() { let_stmt_initializers(this, result) } + + /** + * Gets the else of this let statement, if it exists. + */ + Expr getElse() { let_stmt_elses(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class LitPat extends @lit_pat, Pat { + override string toString() { result = "LitPat" } + + /** + * Gets the expression of this lit pat. + */ + Expr getExpr() { lit_pats(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class LiteralExpr extends @literal_expr, Expr { + override string toString() { result = "LiteralExpr" } + } + + /** + * INTERNAL: Do not use. + */ + class LoopExpr extends @loop_expr, Expr { + override string toString() { result = "LoopExpr" } + + /** + * Gets the body of this loop expression. + */ + Expr getBody() { loop_exprs(this, result) } + + /** + * Gets the label of this loop expression, if it exists. + */ + Label getLabel() { loop_expr_labels(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class MatchExpr extends @match_expr, Expr { + override string toString() { result = "MatchExpr" } + + /** + * Gets the expression of this match expression. + */ + Expr getExpr() { match_exprs(this, result) } + + /** + * Gets the `index`th branch of this match expression (0-based). + */ + MatchArm getBranch(int index) { match_expr_branches(this, index, result) } + } + + /** + * INTERNAL: Do not use. + */ + class MethodCallExpr extends @method_call_expr, Expr { + override string toString() { result = "MethodCallExpr" } + + /** + * Gets the receiver of this method call expression. + */ + Expr getReceiver() { method_call_exprs(this, result, _) } + + /** + * Gets the method name of this method call expression. + */ + string getMethodName() { method_call_exprs(this, _, result) } + + /** + * Gets the `index`th argument of this method call expression (0-based). + */ + Expr getArg(int index) { method_call_expr_args(this, index, result) } + + /** + * Gets the generic arguments of this method call expression, if it exists. + */ + Unimplemented getGenericArgs() { method_call_expr_generic_args(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class MissingExpr extends @missing_expr, Expr { + override string toString() { result = "MissingExpr" } + } + + /** + * INTERNAL: Do not use. + */ + class MissingPat extends @missing_pat, Pat { + override string toString() { result = "MissingPat" } + } + + /** + * INTERNAL: Do not use. + */ + class Module extends @module, Declaration { + override string toString() { result = "Module" } + + /** + * Gets the `index`th declaration of this module (0-based). + */ + Declaration getDeclaration(int index) { module_declarations(this, index, result) } + } + + /** + * INTERNAL: Do not use. + */ + class OffsetOfExpr extends @offset_of_expr, Expr { + override string toString() { result = "OffsetOfExpr" } + + /** + * Gets the container of this offset of expression. + */ + TypeRef getContainer() { offset_of_exprs(this, result) } + + /** + * Gets the `index`th field of this offset of expression (0-based). + */ + string getField(int index) { offset_of_expr_fields(this, index, result) } + } + + /** + * INTERNAL: Do not use. + */ + class OrPat extends @or_pat, Pat { + override string toString() { result = "OrPat" } + + /** + * Gets the `index`th argument of this or pat (0-based). + */ + Pat getArg(int index) { or_pat_args(this, index, result) } + } + + /** + * INTERNAL: Do not use. + */ + class PathExpr extends @path_expr, Expr { + override string toString() { result = "PathExpr" } + + /** + * Gets the path of this path expression. + */ + Unimplemented getPath() { path_exprs(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class PathPat extends @path_pat, Pat { + override string toString() { result = "PathPat" } + + /** + * Gets the path of this path pat. + */ + Unimplemented getPath() { path_pats(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class RangeExpr extends @range_expr, Expr { + override string toString() { result = "RangeExpr" } + + /** + * Gets the lhs of this range expression, if it exists. + */ + Expr getLhs() { range_expr_lhs(this, result) } + + /** + * Gets the rhs of this range expression, if it exists. + */ + Expr getRhs() { range_expr_rhs(this, result) } + + /** + * Holds if this range expression is inclusive. + */ + predicate isInclusive() { range_expr_is_inclusive(this) } + } + + /** + * INTERNAL: Do not use. + */ + class RangePat extends @range_pat, Pat { + override string toString() { result = "RangePat" } + + /** + * Gets the start of this range pat, if it exists. + */ + Pat getStart() { range_pat_starts(this, result) } + + /** + * Gets the end of this range pat, if it exists. + */ + Pat getEnd() { range_pat_ends(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class RecordLitExpr extends @record_lit_expr, Expr { + override string toString() { result = "RecordLitExpr" } + + /** + * Gets the path of this record lit expression, if it exists. + */ + Unimplemented getPath() { record_lit_expr_paths(this, result) } + + /** + * Gets the `index`th field of this record lit expression (0-based). + */ + RecordLitField getField(int index) { record_lit_expr_fields(this, index, result) } + + /** + * Gets the spread of this record lit expression, if it exists. + */ + Expr getSpread() { record_lit_expr_spreads(this, result) } + + /** + * Holds if this record lit expression has ellipsis. + */ + predicate hasEllipsis() { record_lit_expr_has_ellipsis(this) } + + /** + * Holds if this record lit expression is assignee expression. + */ + predicate isAssigneeExpr() { record_lit_expr_is_assignee_expr(this) } + } + + /** + * INTERNAL: Do not use. + */ + class RecordPat extends @record_pat, Pat { + override string toString() { result = "RecordPat" } + + /** + * Gets the path of this record pat, if it exists. + */ + Unimplemented getPath() { record_pat_paths(this, result) } + + /** + * Gets the `index`th argument of this record pat (0-based). + */ + RecordFieldPat getArg(int index) { record_pat_args(this, index, result) } + + /** + * Holds if this record pat has ellipsis. + */ + predicate hasEllipsis() { record_pat_has_ellipsis(this) } + } + + /** + * INTERNAL: Do not use. + */ + class RefExpr extends @ref_expr, Expr { + override string toString() { result = "RefExpr" } + + /** + * Gets the expression of this reference expression. + */ + Expr getExpr() { ref_exprs(this, result) } + + /** + * Holds if this reference expression is raw. + */ + predicate isRaw() { ref_expr_is_raw(this) } + + /** + * Holds if this reference expression is mut. + */ + predicate isMut() { ref_expr_is_mut(this) } + } + + /** + * INTERNAL: Do not use. + */ + class RefPat extends @ref_pat, Pat { + override string toString() { result = "RefPat" } + + /** + * Gets the pat of this reference pat. + */ + Pat getPat() { ref_pats(this, result) } + + /** + * Holds if this reference pat is mut. + */ + predicate isMut() { ref_pat_is_mut(this) } + } + + /** + * INTERNAL: Do not use. + */ + class ReturnExpr extends @return_expr, Expr { + override string toString() { result = "ReturnExpr" } + + /** + * Gets the expression of this return expression, if it exists. + */ + Expr getExpr() { return_expr_exprs(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class SlicePat extends @slice_pat, Pat { + override string toString() { result = "SlicePat" } + + /** + * Gets the `index`th prefix of this slice pat (0-based). + */ + Pat getPrefix(int index) { slice_pat_prefixes(this, index, result) } + + /** + * Gets the slice of this slice pat, if it exists. + */ + Pat getSlice() { slice_pat_slice(this, result) } + + /** + * Gets the `index`th suffix of this slice pat (0-based). + */ + Pat getSuffix(int index) { slice_pat_suffixes(this, index, result) } + } + + /** + * INTERNAL: Do not use. + */ + class TupleExpr extends @tuple_expr, Expr { + override string toString() { result = "TupleExpr" } + + /** + * Gets the `index`th expression of this tuple expression (0-based). + */ + Expr getExpr(int index) { tuple_expr_exprs(this, index, result) } + + /** + * Holds if this tuple expression is assignee expression. + */ + predicate isAssigneeExpr() { tuple_expr_is_assignee_expr(this) } + } + + /** + * INTERNAL: Do not use. + */ + class TuplePat extends @tuple_pat, Pat { + override string toString() { result = "TuplePat" } + + /** + * Gets the `index`th argument of this tuple pat (0-based). + */ + Pat getArg(int index) { tuple_pat_args(this, index, result) } + + /** + * Gets the ellipsis index of this tuple pat, if it exists. + */ + int getEllipsisIndex() { tuple_pat_ellipsis_indices(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class TupleStructPat extends @tuple_struct_pat, Pat { + override string toString() { result = "TupleStructPat" } + + /** + * Gets the path of this tuple struct pat, if it exists. + */ + Unimplemented getPath() { tuple_struct_pat_paths(this, result) } + + /** + * Gets the `index`th argument of this tuple struct pat (0-based). + */ + Pat getArg(int index) { tuple_struct_pat_args(this, index, result) } + + /** + * Gets the ellipsis index of this tuple struct pat, if it exists. + */ + int getEllipsisIndex() { tuple_struct_pat_ellipsis_indices(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class UnaryOpExpr extends @unary_op_expr, Expr { + override string toString() { result = "UnaryOpExpr" } + + /** + * Gets the expression of this unary op expression. + */ + Expr getExpr() { unary_op_exprs(this, result, _) } + + /** + * Gets the op of this unary op expression. + */ + string getOp() { unary_op_exprs(this, _, result) } + } + + /** + * INTERNAL: Do not use. + */ + class UnderscoreExpr extends @underscore_expr, Expr { + override string toString() { result = "UnderscoreExpr" } + } + + /** + * INTERNAL: Do not use. + */ + class WildPat extends @wild_pat, Pat { + override string toString() { result = "WildPat" } + } + + /** + * INTERNAL: Do not use. + */ + class YeetExpr extends @yeet_expr, Expr { + override string toString() { result = "YeetExpr" } + + /** + * Gets the expression of this yeet expression, if it exists. + */ + Expr getExpr() { yeet_expr_exprs(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class YieldExpr extends @yield_expr, Expr { + override string toString() { result = "YieldExpr" } + + /** + * Gets the expression of this yield expression, if it exists. + */ + Expr getExpr() { yield_expr_exprs(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class AsyncBlockExpr extends @async_block_expr, BlockExprBase { + override string toString() { result = "AsyncBlockExpr" } + } + + /** + * INTERNAL: Do not use. + */ + class BlockExpr extends @block_expr, BlockExprBase { + override string toString() { result = "BlockExpr" } + + /** + * Gets the label of this block expression, if it exists. + */ + Label getLabel() { block_expr_labels(this, result) } + } + + /** + * INTERNAL: Do not use. + */ + class ElementListExpr extends @element_list_expr, ArrayExpr { + override string toString() { result = "ElementListExpr" } + + /** + * Gets the `index`th element of this element list expression (0-based). + */ + Expr getElement(int index) { element_list_expr_elements(this, index, result) } + + /** + * Holds if this element list expression is assignee expression. + */ + predicate isAssigneeExpr() { element_list_expr_is_assignee_expr(this) } + } + + /** + * INTERNAL: Do not use. + */ + class RepeatExpr extends @repeat_expr, ArrayExpr { + override string toString() { result = "RepeatExpr" } + + /** + * Gets the initializer of this repeat expression. + */ + Expr getInitializer() { repeat_exprs(this, result, _) } + + /** + * Gets the repeat of this repeat expression. + */ + Expr getRepeat() { repeat_exprs(this, _, result) } + } + + /** + * INTERNAL: Do not use. + */ + class UnsafeBlockExpr extends @unsafe_block_expr, BlockExprBase { + override string toString() { result = "UnsafeBlockExpr" } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/RecordFieldPat.qll b/rust/ql/lib/codeql/rust/generated/RecordFieldPat.qll new file mode 100644 index 000000000000..d2924880931a --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/RecordFieldPat.qll @@ -0,0 +1,41 @@ +// generated by codegen +/** + * This module provides the generated definition of `RecordFieldPat`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.AstNode +import codeql.rust.elements.Pat + +/** + * INTERNAL: This module contains the fully generated definition of `RecordFieldPat` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::RecordFieldPat` class directly. + * Use the subclass `RecordFieldPat`, where the following predicates are available. + */ + class RecordFieldPat extends Synth::TRecordFieldPat, AstNode { + override string getAPrimaryQlClass() { result = "RecordFieldPat" } + + /** + * Gets the name of this record field pat. + */ + string getName() { + result = Synth::convertRecordFieldPatToRaw(this).(Raw::RecordFieldPat).getName() + } + + /** + * Gets the pat of this record field pat. + */ + Pat getPat() { + result = + Synth::convertPatFromRaw(Synth::convertRecordFieldPatToRaw(this) + .(Raw::RecordFieldPat) + .getPat()) + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/RecordLitExpr.qll b/rust/ql/lib/codeql/rust/generated/RecordLitExpr.qll new file mode 100644 index 000000000000..71318e79a6f3 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/RecordLitExpr.qll @@ -0,0 +1,89 @@ +// generated by codegen +/** + * This module provides the generated definition of `RecordLitExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr +import codeql.rust.elements.RecordLitField +import codeql.rust.elements.Unimplemented + +/** + * INTERNAL: This module contains the fully generated definition of `RecordLitExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::RecordLitExpr` class directly. + * Use the subclass `RecordLitExpr`, where the following predicates are available. + */ + class RecordLitExpr extends Synth::TRecordLitExpr, Expr { + override string getAPrimaryQlClass() { result = "RecordLitExpr" } + + /** + * Gets the path of this record lit expression, if it exists. + */ + Unimplemented getPath() { + result = + Synth::convertUnimplementedFromRaw(Synth::convertRecordLitExprToRaw(this) + .(Raw::RecordLitExpr) + .getPath()) + } + + /** + * Holds if `getPath()` exists. + */ + final predicate hasPath() { exists(this.getPath()) } + + /** + * Gets the `index`th field of this record lit expression (0-based). + */ + RecordLitField getField(int index) { + result = + Synth::convertRecordLitFieldFromRaw(Synth::convertRecordLitExprToRaw(this) + .(Raw::RecordLitExpr) + .getField(index)) + } + + /** + * Gets any of the fields of this record lit expression. + */ + final RecordLitField getAField() { result = this.getField(_) } + + /** + * Gets the number of fields of this record lit expression. + */ + final int getNumberOfFields() { result = count(int i | exists(this.getField(i))) } + + /** + * Gets the spread of this record lit expression, if it exists. + */ + Expr getSpread() { + result = + Synth::convertExprFromRaw(Synth::convertRecordLitExprToRaw(this) + .(Raw::RecordLitExpr) + .getSpread()) + } + + /** + * Holds if `getSpread()` exists. + */ + final predicate hasSpread() { exists(this.getSpread()) } + + /** + * Holds if this record lit expression has ellipsis. + */ + predicate hasEllipsis() { + Synth::convertRecordLitExprToRaw(this).(Raw::RecordLitExpr).hasEllipsis() + } + + /** + * Holds if this record lit expression is assignee expression. + */ + predicate isAssigneeExpr() { + Synth::convertRecordLitExprToRaw(this).(Raw::RecordLitExpr).isAssigneeExpr() + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/RecordLitField.qll b/rust/ql/lib/codeql/rust/generated/RecordLitField.qll new file mode 100644 index 000000000000..55a488e2ff6d --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/RecordLitField.qll @@ -0,0 +1,41 @@ +// generated by codegen +/** + * This module provides the generated definition of `RecordLitField`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.AstNode +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `RecordLitField` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::RecordLitField` class directly. + * Use the subclass `RecordLitField`, where the following predicates are available. + */ + class RecordLitField extends Synth::TRecordLitField, AstNode { + override string getAPrimaryQlClass() { result = "RecordLitField" } + + /** + * Gets the name of this record lit field. + */ + string getName() { + result = Synth::convertRecordLitFieldToRaw(this).(Raw::RecordLitField).getName() + } + + /** + * Gets the expression of this record lit field. + */ + Expr getExpr() { + result = + Synth::convertExprFromRaw(Synth::convertRecordLitFieldToRaw(this) + .(Raw::RecordLitField) + .getExpr()) + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/RecordPat.qll b/rust/ql/lib/codeql/rust/generated/RecordPat.qll new file mode 100644 index 000000000000..dca4cbb93822 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/RecordPat.qll @@ -0,0 +1,65 @@ +// generated by codegen +/** + * This module provides the generated definition of `RecordPat`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Pat +import codeql.rust.elements.RecordFieldPat +import codeql.rust.elements.Unimplemented + +/** + * INTERNAL: This module contains the fully generated definition of `RecordPat` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::RecordPat` class directly. + * Use the subclass `RecordPat`, where the following predicates are available. + */ + class RecordPat extends Synth::TRecordPat, Pat { + override string getAPrimaryQlClass() { result = "RecordPat" } + + /** + * Gets the path of this record pat, if it exists. + */ + Unimplemented getPath() { + result = + Synth::convertUnimplementedFromRaw(Synth::convertRecordPatToRaw(this) + .(Raw::RecordPat) + .getPath()) + } + + /** + * Holds if `getPath()` exists. + */ + final predicate hasPath() { exists(this.getPath()) } + + /** + * Gets the `index`th argument of this record pat (0-based). + */ + RecordFieldPat getArg(int index) { + result = + Synth::convertRecordFieldPatFromRaw(Synth::convertRecordPatToRaw(this) + .(Raw::RecordPat) + .getArg(index)) + } + + /** + * Gets any of the arguments of this record pat. + */ + final RecordFieldPat getAnArg() { result = this.getArg(_) } + + /** + * Gets the number of arguments of this record pat. + */ + final int getNumberOfArgs() { result = count(int i | exists(this.getArg(i))) } + + /** + * Holds if this record pat has ellipsis. + */ + predicate hasEllipsis() { Synth::convertRecordPatToRaw(this).(Raw::RecordPat).hasEllipsis() } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/RefExpr.qll b/rust/ql/lib/codeql/rust/generated/RefExpr.qll new file mode 100644 index 000000000000..6fce583db98e --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/RefExpr.qll @@ -0,0 +1,40 @@ +// generated by codegen +/** + * This module provides the generated definition of `RefExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `RefExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::RefExpr` class directly. + * Use the subclass `RefExpr`, where the following predicates are available. + */ + class RefExpr extends Synth::TRefExpr, Expr { + override string getAPrimaryQlClass() { result = "RefExpr" } + + /** + * Gets the expression of this reference expression. + */ + Expr getExpr() { + result = Synth::convertExprFromRaw(Synth::convertRefExprToRaw(this).(Raw::RefExpr).getExpr()) + } + + /** + * Holds if this reference expression is raw. + */ + predicate isRaw() { Synth::convertRefExprToRaw(this).(Raw::RefExpr).isRaw() } + + /** + * Holds if this reference expression is mut. + */ + predicate isMut() { Synth::convertRefExprToRaw(this).(Raw::RefExpr).isMut() } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/RefPat.qll b/rust/ql/lib/codeql/rust/generated/RefPat.qll new file mode 100644 index 000000000000..33674b00330b --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/RefPat.qll @@ -0,0 +1,35 @@ +// generated by codegen +/** + * This module provides the generated definition of `RefPat`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Pat + +/** + * INTERNAL: This module contains the fully generated definition of `RefPat` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::RefPat` class directly. + * Use the subclass `RefPat`, where the following predicates are available. + */ + class RefPat extends Synth::TRefPat, Pat { + override string getAPrimaryQlClass() { result = "RefPat" } + + /** + * Gets the pat of this reference pat. + */ + Pat getPat() { + result = Synth::convertPatFromRaw(Synth::convertRefPatToRaw(this).(Raw::RefPat).getPat()) + } + + /** + * Holds if this reference pat is mut. + */ + predicate isMut() { Synth::convertRefPatToRaw(this).(Raw::RefPat).isMut() } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/RepeatExpr.qll b/rust/ql/lib/codeql/rust/generated/RepeatExpr.qll new file mode 100644 index 000000000000..17df2bb4db1a --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/RepeatExpr.qll @@ -0,0 +1,42 @@ +// generated by codegen +/** + * This module provides the generated definition of `RepeatExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.ArrayExpr +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `RepeatExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::RepeatExpr` class directly. + * Use the subclass `RepeatExpr`, where the following predicates are available. + */ + class RepeatExpr extends Synth::TRepeatExpr, ArrayExpr { + override string getAPrimaryQlClass() { result = "RepeatExpr" } + + /** + * Gets the initializer of this repeat expression. + */ + Expr getInitializer() { + result = + Synth::convertExprFromRaw(Synth::convertRepeatExprToRaw(this) + .(Raw::RepeatExpr) + .getInitializer()) + } + + /** + * Gets the repeat of this repeat expression. + */ + Expr getRepeat() { + result = + Synth::convertExprFromRaw(Synth::convertRepeatExprToRaw(this).(Raw::RepeatExpr).getRepeat()) + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/ReturnExpr.qll b/rust/ql/lib/codeql/rust/generated/ReturnExpr.qll new file mode 100644 index 000000000000..1d9ee4be7ac6 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/ReturnExpr.qll @@ -0,0 +1,36 @@ +// generated by codegen +/** + * This module provides the generated definition of `ReturnExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `ReturnExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::ReturnExpr` class directly. + * Use the subclass `ReturnExpr`, where the following predicates are available. + */ + class ReturnExpr extends Synth::TReturnExpr, Expr { + override string getAPrimaryQlClass() { result = "ReturnExpr" } + + /** + * Gets the expression of this return expression, if it exists. + */ + Expr getExpr() { + result = + Synth::convertExprFromRaw(Synth::convertReturnExprToRaw(this).(Raw::ReturnExpr).getExpr()) + } + + /** + * Holds if `getExpr()` exists. + */ + final predicate hasExpr() { exists(this.getExpr()) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/SlicePat.qll b/rust/ql/lib/codeql/rust/generated/SlicePat.qll new file mode 100644 index 000000000000..272be5951670 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/SlicePat.qll @@ -0,0 +1,72 @@ +// generated by codegen +/** + * This module provides the generated definition of `SlicePat`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Pat + +/** + * INTERNAL: This module contains the fully generated definition of `SlicePat` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::SlicePat` class directly. + * Use the subclass `SlicePat`, where the following predicates are available. + */ + class SlicePat extends Synth::TSlicePat, Pat { + override string getAPrimaryQlClass() { result = "SlicePat" } + + /** + * Gets the `index`th prefix of this slice pat (0-based). + */ + Pat getPrefix(int index) { + result = + Synth::convertPatFromRaw(Synth::convertSlicePatToRaw(this).(Raw::SlicePat).getPrefix(index)) + } + + /** + * Gets any of the prefixes of this slice pat. + */ + final Pat getAPrefix() { result = this.getPrefix(_) } + + /** + * Gets the number of prefixes of this slice pat. + */ + final int getNumberOfPrefixes() { result = count(int i | exists(this.getPrefix(i))) } + + /** + * Gets the slice of this slice pat, if it exists. + */ + Pat getSlice() { + result = + Synth::convertPatFromRaw(Synth::convertSlicePatToRaw(this).(Raw::SlicePat).getSlice()) + } + + /** + * Holds if `getSlice()` exists. + */ + final predicate hasSlice() { exists(this.getSlice()) } + + /** + * Gets the `index`th suffix of this slice pat (0-based). + */ + Pat getSuffix(int index) { + result = + Synth::convertPatFromRaw(Synth::convertSlicePatToRaw(this).(Raw::SlicePat).getSuffix(index)) + } + + /** + * Gets any of the suffixes of this slice pat. + */ + final Pat getASuffix() { result = this.getSuffix(_) } + + /** + * Gets the number of suffixes of this slice pat. + */ + final int getNumberOfSuffixes() { result = count(int i | exists(this.getSuffix(i))) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/Stmt.qll b/rust/ql/lib/codeql/rust/generated/Stmt.qll new file mode 100644 index 000000000000..d1536f06e7cd --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/Stmt.qll @@ -0,0 +1,21 @@ +// generated by codegen +/** + * This module provides the generated definition of `Stmt`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.AstNode + +/** + * INTERNAL: This module contains the fully generated definition of `Stmt` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::Stmt` class directly. + * Use the subclass `Stmt`, where the following predicates are available. + */ + class Stmt extends Synth::TStmt, AstNode { } +} diff --git a/rust/ql/lib/codeql/rust/generated/Synth.qll b/rust/ql/lib/codeql/rust/generated/Synth.qll new file mode 100644 index 000000000000..24cd549448af --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/Synth.qll @@ -0,0 +1,1698 @@ +/** + * INTERNAL: Do not use. + * This module defines the IPA layer on top of raw DB entities, and the conversions between the two + * layers. + */ + +private import codeql.rust.generated.SynthConstructors +private import codeql.rust.generated.Raw + +cached +module Synth { + /** + * INTERNAL: Do not use. + * The synthesized type of all elements. + */ + cached + newtype TElement = + /** + * INTERNAL: Do not use. + */ + TAsyncBlockExpr(Raw::AsyncBlockExpr id) { constructAsyncBlockExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TAwaitExpr(Raw::AwaitExpr id) { constructAwaitExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TBecomeExpr(Raw::BecomeExpr id) { constructBecomeExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TBinaryOpExpr(Raw::BinaryOpExpr id) { constructBinaryOpExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TBindPat(Raw::BindPat id) { constructBindPat(id) } or + /** + * INTERNAL: Do not use. + */ + TBlockExpr(Raw::BlockExpr id) { constructBlockExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TBoxExpr(Raw::BoxExpr id) { constructBoxExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TBoxPat(Raw::BoxPat id) { constructBoxPat(id) } or + /** + * INTERNAL: Do not use. + */ + TBreakExpr(Raw::BreakExpr id) { constructBreakExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TCallExpr(Raw::CallExpr id) { constructCallExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TCastExpr(Raw::CastExpr id) { constructCastExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TClosureExpr(Raw::ClosureExpr id) { constructClosureExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TConstBlockPat(Raw::ConstBlockPat id) { constructConstBlockPat(id) } or + /** + * INTERNAL: Do not use. + */ + TConstExpr(Raw::ConstExpr id) { constructConstExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TContinueExpr(Raw::ContinueExpr id) { constructContinueExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TDbFile(Raw::DbFile id) { constructDbFile(id) } or + /** + * INTERNAL: Do not use. + */ + TDbLocation(Raw::DbLocation id) { constructDbLocation(id) } or + /** + * INTERNAL: Do not use. + */ + TElementListExpr(Raw::ElementListExpr id) { constructElementListExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TExprStmt(Raw::ExprStmt id) { constructExprStmt(id) } or + /** + * INTERNAL: Do not use. + */ + TFieldExpr(Raw::FieldExpr id) { constructFieldExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TFunction(Raw::Function id) { constructFunction(id) } or + /** + * INTERNAL: Do not use. + */ + TIfExpr(Raw::IfExpr id) { constructIfExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TIndexExpr(Raw::IndexExpr id) { constructIndexExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TInlineAsmExpr(Raw::InlineAsmExpr id) { constructInlineAsmExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TItemStmt(Raw::ItemStmt id) { constructItemStmt(id) } or + /** + * INTERNAL: Do not use. + */ + TLabel(Raw::Label id) { constructLabel(id) } or + /** + * INTERNAL: Do not use. + */ + TLetExpr(Raw::LetExpr id) { constructLetExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TLetStmt(Raw::LetStmt id) { constructLetStmt(id) } or + /** + * INTERNAL: Do not use. + */ + TLitPat(Raw::LitPat id) { constructLitPat(id) } or + /** + * INTERNAL: Do not use. + */ + TLiteralExpr(Raw::LiteralExpr id) { constructLiteralExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TLoopExpr(Raw::LoopExpr id) { constructLoopExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TMatchArm(Raw::MatchArm id) { constructMatchArm(id) } or + /** + * INTERNAL: Do not use. + */ + TMatchExpr(Raw::MatchExpr id) { constructMatchExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TMethodCallExpr(Raw::MethodCallExpr id) { constructMethodCallExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TMissingExpr(Raw::MissingExpr id) { constructMissingExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TMissingPat(Raw::MissingPat id) { constructMissingPat(id) } or + /** + * INTERNAL: Do not use. + */ + TModule(Raw::Module id) { constructModule(id) } or + /** + * INTERNAL: Do not use. + */ + TOffsetOfExpr(Raw::OffsetOfExpr id) { constructOffsetOfExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TOrPat(Raw::OrPat id) { constructOrPat(id) } or + /** + * INTERNAL: Do not use. + */ + TPathExpr(Raw::PathExpr id) { constructPathExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TPathPat(Raw::PathPat id) { constructPathPat(id) } or + /** + * INTERNAL: Do not use. + */ + TRangeExpr(Raw::RangeExpr id) { constructRangeExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TRangePat(Raw::RangePat id) { constructRangePat(id) } or + /** + * INTERNAL: Do not use. + */ + TRecordFieldPat(Raw::RecordFieldPat id) { constructRecordFieldPat(id) } or + /** + * INTERNAL: Do not use. + */ + TRecordLitExpr(Raw::RecordLitExpr id) { constructRecordLitExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TRecordLitField(Raw::RecordLitField id) { constructRecordLitField(id) } or + /** + * INTERNAL: Do not use. + */ + TRecordPat(Raw::RecordPat id) { constructRecordPat(id) } or + /** + * INTERNAL: Do not use. + */ + TRefExpr(Raw::RefExpr id) { constructRefExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TRefPat(Raw::RefPat id) { constructRefPat(id) } or + /** + * INTERNAL: Do not use. + */ + TRepeatExpr(Raw::RepeatExpr id) { constructRepeatExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TReturnExpr(Raw::ReturnExpr id) { constructReturnExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TSlicePat(Raw::SlicePat id) { constructSlicePat(id) } or + /** + * INTERNAL: Do not use. + */ + TTupleExpr(Raw::TupleExpr id) { constructTupleExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TTuplePat(Raw::TuplePat id) { constructTuplePat(id) } or + /** + * INTERNAL: Do not use. + */ + TTupleStructPat(Raw::TupleStructPat id) { constructTupleStructPat(id) } or + /** + * INTERNAL: Do not use. + */ + TTypeRef(Raw::TypeRef id) { constructTypeRef(id) } or + /** + * INTERNAL: Do not use. + */ + TUnaryOpExpr(Raw::UnaryOpExpr id) { constructUnaryOpExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TUnderscoreExpr(Raw::UnderscoreExpr id) { constructUnderscoreExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TUnimplemented(Raw::Unimplemented id) { constructUnimplemented(id) } or + /** + * INTERNAL: Do not use. + */ + TUnknownFile() or + /** + * INTERNAL: Do not use. + */ + TUnknownLocation() or + /** + * INTERNAL: Do not use. + */ + TUnsafeBlockExpr(Raw::UnsafeBlockExpr id) { constructUnsafeBlockExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TWildPat(Raw::WildPat id) { constructWildPat(id) } or + /** + * INTERNAL: Do not use. + */ + TYeetExpr(Raw::YeetExpr id) { constructYeetExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TYieldExpr(Raw::YieldExpr id) { constructYieldExpr(id) } + + /** + * INTERNAL: Do not use. + */ + class TArrayExpr = TElementListExpr or TRepeatExpr; + + /** + * INTERNAL: Do not use. + */ + class TAstNode = + TDeclaration or TExpr or TLabel or TMatchArm or TPat or TRecordFieldPat or TRecordLitField or + TStmt or TTypeRef or TUnimplemented; + + /** + * INTERNAL: Do not use. + */ + class TBlockExprBase = TAsyncBlockExpr or TBlockExpr or TUnsafeBlockExpr; + + /** + * INTERNAL: Do not use. + */ + class TDeclaration = TFunction or TModule; + + /** + * INTERNAL: Do not use. + */ + class TExpr = + TArrayExpr or TAwaitExpr or TBecomeExpr or TBinaryOpExpr or TBlockExprBase or TBoxExpr or + TBreakExpr or TCallExpr or TCastExpr or TClosureExpr or TConstExpr or TContinueExpr or + TFieldExpr or TIfExpr or TIndexExpr or TInlineAsmExpr or TLetExpr or TLiteralExpr or + TLoopExpr or TMatchExpr or TMethodCallExpr or TMissingExpr or TOffsetOfExpr or TPathExpr or + TRangeExpr or TRecordLitExpr or TRefExpr or TReturnExpr or TTupleExpr or TUnaryOpExpr or + TUnderscoreExpr or TYeetExpr or TYieldExpr; + + /** + * INTERNAL: Do not use. + */ + class TFile = TDbFile or TUnknownFile; + + /** + * INTERNAL: Do not use. + */ + class TLocatable = TAstNode; + + /** + * INTERNAL: Do not use. + */ + class TLocation = TDbLocation or TUnknownLocation; + + /** + * INTERNAL: Do not use. + */ + class TPat = + TBindPat or TBoxPat or TConstBlockPat or TLitPat or TMissingPat or TOrPat or TPathPat or + TRangePat or TRecordPat or TRefPat or TSlicePat or TTuplePat or TTupleStructPat or TWildPat; + + /** + * INTERNAL: Do not use. + */ + class TStmt = TExprStmt or TItemStmt or TLetStmt; + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TAsyncBlockExpr`, if possible. + */ + cached + TAsyncBlockExpr convertAsyncBlockExprFromRaw(Raw::Element e) { result = TAsyncBlockExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TAwaitExpr`, if possible. + */ + cached + TAwaitExpr convertAwaitExprFromRaw(Raw::Element e) { result = TAwaitExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TBecomeExpr`, if possible. + */ + cached + TBecomeExpr convertBecomeExprFromRaw(Raw::Element e) { result = TBecomeExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TBinaryOpExpr`, if possible. + */ + cached + TBinaryOpExpr convertBinaryOpExprFromRaw(Raw::Element e) { result = TBinaryOpExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TBindPat`, if possible. + */ + cached + TBindPat convertBindPatFromRaw(Raw::Element e) { result = TBindPat(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TBlockExpr`, if possible. + */ + cached + TBlockExpr convertBlockExprFromRaw(Raw::Element e) { result = TBlockExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TBoxExpr`, if possible. + */ + cached + TBoxExpr convertBoxExprFromRaw(Raw::Element e) { result = TBoxExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TBoxPat`, if possible. + */ + cached + TBoxPat convertBoxPatFromRaw(Raw::Element e) { result = TBoxPat(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TBreakExpr`, if possible. + */ + cached + TBreakExpr convertBreakExprFromRaw(Raw::Element e) { result = TBreakExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TCallExpr`, if possible. + */ + cached + TCallExpr convertCallExprFromRaw(Raw::Element e) { result = TCallExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TCastExpr`, if possible. + */ + cached + TCastExpr convertCastExprFromRaw(Raw::Element e) { result = TCastExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TClosureExpr`, if possible. + */ + cached + TClosureExpr convertClosureExprFromRaw(Raw::Element e) { result = TClosureExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TConstBlockPat`, if possible. + */ + cached + TConstBlockPat convertConstBlockPatFromRaw(Raw::Element e) { result = TConstBlockPat(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TConstExpr`, if possible. + */ + cached + TConstExpr convertConstExprFromRaw(Raw::Element e) { result = TConstExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TContinueExpr`, if possible. + */ + cached + TContinueExpr convertContinueExprFromRaw(Raw::Element e) { result = TContinueExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TDbFile`, if possible. + */ + cached + TDbFile convertDbFileFromRaw(Raw::Element e) { result = TDbFile(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TDbLocation`, if possible. + */ + cached + TDbLocation convertDbLocationFromRaw(Raw::Element e) { result = TDbLocation(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TElementListExpr`, if possible. + */ + cached + TElementListExpr convertElementListExprFromRaw(Raw::Element e) { result = TElementListExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TExprStmt`, if possible. + */ + cached + TExprStmt convertExprStmtFromRaw(Raw::Element e) { result = TExprStmt(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TFieldExpr`, if possible. + */ + cached + TFieldExpr convertFieldExprFromRaw(Raw::Element e) { result = TFieldExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TFunction`, if possible. + */ + cached + TFunction convertFunctionFromRaw(Raw::Element e) { result = TFunction(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TIfExpr`, if possible. + */ + cached + TIfExpr convertIfExprFromRaw(Raw::Element e) { result = TIfExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TIndexExpr`, if possible. + */ + cached + TIndexExpr convertIndexExprFromRaw(Raw::Element e) { result = TIndexExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TInlineAsmExpr`, if possible. + */ + cached + TInlineAsmExpr convertInlineAsmExprFromRaw(Raw::Element e) { result = TInlineAsmExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TItemStmt`, if possible. + */ + cached + TItemStmt convertItemStmtFromRaw(Raw::Element e) { result = TItemStmt(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TLabel`, if possible. + */ + cached + TLabel convertLabelFromRaw(Raw::Element e) { result = TLabel(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TLetExpr`, if possible. + */ + cached + TLetExpr convertLetExprFromRaw(Raw::Element e) { result = TLetExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TLetStmt`, if possible. + */ + cached + TLetStmt convertLetStmtFromRaw(Raw::Element e) { result = TLetStmt(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TLitPat`, if possible. + */ + cached + TLitPat convertLitPatFromRaw(Raw::Element e) { result = TLitPat(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TLiteralExpr`, if possible. + */ + cached + TLiteralExpr convertLiteralExprFromRaw(Raw::Element e) { result = TLiteralExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TLoopExpr`, if possible. + */ + cached + TLoopExpr convertLoopExprFromRaw(Raw::Element e) { result = TLoopExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TMatchArm`, if possible. + */ + cached + TMatchArm convertMatchArmFromRaw(Raw::Element e) { result = TMatchArm(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TMatchExpr`, if possible. + */ + cached + TMatchExpr convertMatchExprFromRaw(Raw::Element e) { result = TMatchExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TMethodCallExpr`, if possible. + */ + cached + TMethodCallExpr convertMethodCallExprFromRaw(Raw::Element e) { result = TMethodCallExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TMissingExpr`, if possible. + */ + cached + TMissingExpr convertMissingExprFromRaw(Raw::Element e) { result = TMissingExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TMissingPat`, if possible. + */ + cached + TMissingPat convertMissingPatFromRaw(Raw::Element e) { result = TMissingPat(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TModule`, if possible. + */ + cached + TModule convertModuleFromRaw(Raw::Element e) { result = TModule(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TOffsetOfExpr`, if possible. + */ + cached + TOffsetOfExpr convertOffsetOfExprFromRaw(Raw::Element e) { result = TOffsetOfExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TOrPat`, if possible. + */ + cached + TOrPat convertOrPatFromRaw(Raw::Element e) { result = TOrPat(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TPathExpr`, if possible. + */ + cached + TPathExpr convertPathExprFromRaw(Raw::Element e) { result = TPathExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TPathPat`, if possible. + */ + cached + TPathPat convertPathPatFromRaw(Raw::Element e) { result = TPathPat(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TRangeExpr`, if possible. + */ + cached + TRangeExpr convertRangeExprFromRaw(Raw::Element e) { result = TRangeExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TRangePat`, if possible. + */ + cached + TRangePat convertRangePatFromRaw(Raw::Element e) { result = TRangePat(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TRecordFieldPat`, if possible. + */ + cached + TRecordFieldPat convertRecordFieldPatFromRaw(Raw::Element e) { result = TRecordFieldPat(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TRecordLitExpr`, if possible. + */ + cached + TRecordLitExpr convertRecordLitExprFromRaw(Raw::Element e) { result = TRecordLitExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TRecordLitField`, if possible. + */ + cached + TRecordLitField convertRecordLitFieldFromRaw(Raw::Element e) { result = TRecordLitField(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TRecordPat`, if possible. + */ + cached + TRecordPat convertRecordPatFromRaw(Raw::Element e) { result = TRecordPat(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TRefExpr`, if possible. + */ + cached + TRefExpr convertRefExprFromRaw(Raw::Element e) { result = TRefExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TRefPat`, if possible. + */ + cached + TRefPat convertRefPatFromRaw(Raw::Element e) { result = TRefPat(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TRepeatExpr`, if possible. + */ + cached + TRepeatExpr convertRepeatExprFromRaw(Raw::Element e) { result = TRepeatExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TReturnExpr`, if possible. + */ + cached + TReturnExpr convertReturnExprFromRaw(Raw::Element e) { result = TReturnExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TSlicePat`, if possible. + */ + cached + TSlicePat convertSlicePatFromRaw(Raw::Element e) { result = TSlicePat(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TTupleExpr`, if possible. + */ + cached + TTupleExpr convertTupleExprFromRaw(Raw::Element e) { result = TTupleExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TTuplePat`, if possible. + */ + cached + TTuplePat convertTuplePatFromRaw(Raw::Element e) { result = TTuplePat(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TTupleStructPat`, if possible. + */ + cached + TTupleStructPat convertTupleStructPatFromRaw(Raw::Element e) { result = TTupleStructPat(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TTypeRef`, if possible. + */ + cached + TTypeRef convertTypeRefFromRaw(Raw::Element e) { result = TTypeRef(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TUnaryOpExpr`, if possible. + */ + cached + TUnaryOpExpr convertUnaryOpExprFromRaw(Raw::Element e) { result = TUnaryOpExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TUnderscoreExpr`, if possible. + */ + cached + TUnderscoreExpr convertUnderscoreExprFromRaw(Raw::Element e) { result = TUnderscoreExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TUnimplemented`, if possible. + */ + cached + TUnimplemented convertUnimplementedFromRaw(Raw::Element e) { result = TUnimplemented(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TUnknownFile`, if possible. + */ + cached + TUnknownFile convertUnknownFileFromRaw(Raw::Element e) { none() } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TUnknownLocation`, if possible. + */ + cached + TUnknownLocation convertUnknownLocationFromRaw(Raw::Element e) { none() } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TUnsafeBlockExpr`, if possible. + */ + cached + TUnsafeBlockExpr convertUnsafeBlockExprFromRaw(Raw::Element e) { result = TUnsafeBlockExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TWildPat`, if possible. + */ + cached + TWildPat convertWildPatFromRaw(Raw::Element e) { result = TWildPat(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TYeetExpr`, if possible. + */ + cached + TYeetExpr convertYeetExprFromRaw(Raw::Element e) { result = TYeetExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TYieldExpr`, if possible. + */ + cached + TYieldExpr convertYieldExprFromRaw(Raw::Element e) { result = TYieldExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw DB element to a synthesized `TArrayExpr`, if possible. + */ + cached + TArrayExpr convertArrayExprFromRaw(Raw::Element e) { + result = convertElementListExprFromRaw(e) + or + result = convertRepeatExprFromRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a raw DB element to a synthesized `TAstNode`, if possible. + */ + cached + TAstNode convertAstNodeFromRaw(Raw::Element e) { + result = convertDeclarationFromRaw(e) + or + result = convertExprFromRaw(e) + or + result = convertLabelFromRaw(e) + or + result = convertMatchArmFromRaw(e) + or + result = convertPatFromRaw(e) + or + result = convertRecordFieldPatFromRaw(e) + or + result = convertRecordLitFieldFromRaw(e) + or + result = convertStmtFromRaw(e) + or + result = convertTypeRefFromRaw(e) + or + result = convertUnimplementedFromRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a raw DB element to a synthesized `TBlockExprBase`, if possible. + */ + cached + TBlockExprBase convertBlockExprBaseFromRaw(Raw::Element e) { + result = convertAsyncBlockExprFromRaw(e) + or + result = convertBlockExprFromRaw(e) + or + result = convertUnsafeBlockExprFromRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a raw DB element to a synthesized `TDeclaration`, if possible. + */ + cached + TDeclaration convertDeclarationFromRaw(Raw::Element e) { + result = convertFunctionFromRaw(e) + or + result = convertModuleFromRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a raw DB element to a synthesized `TElement`, if possible. + */ + cached + TElement convertElementFromRaw(Raw::Element e) { + result = convertFileFromRaw(e) + or + result = convertLocatableFromRaw(e) + or + result = convertLocationFromRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a raw DB element to a synthesized `TExpr`, if possible. + */ + cached + TExpr convertExprFromRaw(Raw::Element e) { + result = convertArrayExprFromRaw(e) + or + result = convertAwaitExprFromRaw(e) + or + result = convertBecomeExprFromRaw(e) + or + result = convertBinaryOpExprFromRaw(e) + or + result = convertBlockExprBaseFromRaw(e) + or + result = convertBoxExprFromRaw(e) + or + result = convertBreakExprFromRaw(e) + or + result = convertCallExprFromRaw(e) + or + result = convertCastExprFromRaw(e) + or + result = convertClosureExprFromRaw(e) + or + result = convertConstExprFromRaw(e) + or + result = convertContinueExprFromRaw(e) + or + result = convertFieldExprFromRaw(e) + or + result = convertIfExprFromRaw(e) + or + result = convertIndexExprFromRaw(e) + or + result = convertInlineAsmExprFromRaw(e) + or + result = convertLetExprFromRaw(e) + or + result = convertLiteralExprFromRaw(e) + or + result = convertLoopExprFromRaw(e) + or + result = convertMatchExprFromRaw(e) + or + result = convertMethodCallExprFromRaw(e) + or + result = convertMissingExprFromRaw(e) + or + result = convertOffsetOfExprFromRaw(e) + or + result = convertPathExprFromRaw(e) + or + result = convertRangeExprFromRaw(e) + or + result = convertRecordLitExprFromRaw(e) + or + result = convertRefExprFromRaw(e) + or + result = convertReturnExprFromRaw(e) + or + result = convertTupleExprFromRaw(e) + or + result = convertUnaryOpExprFromRaw(e) + or + result = convertUnderscoreExprFromRaw(e) + or + result = convertYeetExprFromRaw(e) + or + result = convertYieldExprFromRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a raw DB element to a synthesized `TFile`, if possible. + */ + cached + TFile convertFileFromRaw(Raw::Element e) { + result = convertDbFileFromRaw(e) + or + result = convertUnknownFileFromRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a raw DB element to a synthesized `TLocatable`, if possible. + */ + cached + TLocatable convertLocatableFromRaw(Raw::Element e) { result = convertAstNodeFromRaw(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw DB element to a synthesized `TLocation`, if possible. + */ + cached + TLocation convertLocationFromRaw(Raw::Element e) { + result = convertDbLocationFromRaw(e) + or + result = convertUnknownLocationFromRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a raw DB element to a synthesized `TPat`, if possible. + */ + cached + TPat convertPatFromRaw(Raw::Element e) { + result = convertBindPatFromRaw(e) + or + result = convertBoxPatFromRaw(e) + or + result = convertConstBlockPatFromRaw(e) + or + result = convertLitPatFromRaw(e) + or + result = convertMissingPatFromRaw(e) + or + result = convertOrPatFromRaw(e) + or + result = convertPathPatFromRaw(e) + or + result = convertRangePatFromRaw(e) + or + result = convertRecordPatFromRaw(e) + or + result = convertRefPatFromRaw(e) + or + result = convertSlicePatFromRaw(e) + or + result = convertTuplePatFromRaw(e) + or + result = convertTupleStructPatFromRaw(e) + or + result = convertWildPatFromRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a raw DB element to a synthesized `TStmt`, if possible. + */ + cached + TStmt convertStmtFromRaw(Raw::Element e) { + result = convertExprStmtFromRaw(e) + or + result = convertItemStmtFromRaw(e) + or + result = convertLetStmtFromRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TAsyncBlockExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertAsyncBlockExprToRaw(TAsyncBlockExpr e) { e = TAsyncBlockExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TAwaitExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertAwaitExprToRaw(TAwaitExpr e) { e = TAwaitExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TBecomeExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertBecomeExprToRaw(TBecomeExpr e) { e = TBecomeExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TBinaryOpExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertBinaryOpExprToRaw(TBinaryOpExpr e) { e = TBinaryOpExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TBindPat` to a raw DB element, if possible. + */ + cached + Raw::Element convertBindPatToRaw(TBindPat e) { e = TBindPat(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TBlockExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertBlockExprToRaw(TBlockExpr e) { e = TBlockExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TBoxExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertBoxExprToRaw(TBoxExpr e) { e = TBoxExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TBoxPat` to a raw DB element, if possible. + */ + cached + Raw::Element convertBoxPatToRaw(TBoxPat e) { e = TBoxPat(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TBreakExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertBreakExprToRaw(TBreakExpr e) { e = TBreakExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TCallExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertCallExprToRaw(TCallExpr e) { e = TCallExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TCastExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertCastExprToRaw(TCastExpr e) { e = TCastExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TClosureExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertClosureExprToRaw(TClosureExpr e) { e = TClosureExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TConstBlockPat` to a raw DB element, if possible. + */ + cached + Raw::Element convertConstBlockPatToRaw(TConstBlockPat e) { e = TConstBlockPat(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TConstExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertConstExprToRaw(TConstExpr e) { e = TConstExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TContinueExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertContinueExprToRaw(TContinueExpr e) { e = TContinueExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TDbFile` to a raw DB element, if possible. + */ + cached + Raw::Element convertDbFileToRaw(TDbFile e) { e = TDbFile(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TDbLocation` to a raw DB element, if possible. + */ + cached + Raw::Element convertDbLocationToRaw(TDbLocation e) { e = TDbLocation(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TElementListExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertElementListExprToRaw(TElementListExpr e) { e = TElementListExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TExprStmt` to a raw DB element, if possible. + */ + cached + Raw::Element convertExprStmtToRaw(TExprStmt e) { e = TExprStmt(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TFieldExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertFieldExprToRaw(TFieldExpr e) { e = TFieldExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TFunction` to a raw DB element, if possible. + */ + cached + Raw::Element convertFunctionToRaw(TFunction e) { e = TFunction(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TIfExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertIfExprToRaw(TIfExpr e) { e = TIfExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TIndexExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertIndexExprToRaw(TIndexExpr e) { e = TIndexExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TInlineAsmExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertInlineAsmExprToRaw(TInlineAsmExpr e) { e = TInlineAsmExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TItemStmt` to a raw DB element, if possible. + */ + cached + Raw::Element convertItemStmtToRaw(TItemStmt e) { e = TItemStmt(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TLabel` to a raw DB element, if possible. + */ + cached + Raw::Element convertLabelToRaw(TLabel e) { e = TLabel(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TLetExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertLetExprToRaw(TLetExpr e) { e = TLetExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TLetStmt` to a raw DB element, if possible. + */ + cached + Raw::Element convertLetStmtToRaw(TLetStmt e) { e = TLetStmt(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TLitPat` to a raw DB element, if possible. + */ + cached + Raw::Element convertLitPatToRaw(TLitPat e) { e = TLitPat(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TLiteralExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertLiteralExprToRaw(TLiteralExpr e) { e = TLiteralExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TLoopExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertLoopExprToRaw(TLoopExpr e) { e = TLoopExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TMatchArm` to a raw DB element, if possible. + */ + cached + Raw::Element convertMatchArmToRaw(TMatchArm e) { e = TMatchArm(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TMatchExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertMatchExprToRaw(TMatchExpr e) { e = TMatchExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TMethodCallExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertMethodCallExprToRaw(TMethodCallExpr e) { e = TMethodCallExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TMissingExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertMissingExprToRaw(TMissingExpr e) { e = TMissingExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TMissingPat` to a raw DB element, if possible. + */ + cached + Raw::Element convertMissingPatToRaw(TMissingPat e) { e = TMissingPat(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TModule` to a raw DB element, if possible. + */ + cached + Raw::Element convertModuleToRaw(TModule e) { e = TModule(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TOffsetOfExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertOffsetOfExprToRaw(TOffsetOfExpr e) { e = TOffsetOfExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TOrPat` to a raw DB element, if possible. + */ + cached + Raw::Element convertOrPatToRaw(TOrPat e) { e = TOrPat(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TPathExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertPathExprToRaw(TPathExpr e) { e = TPathExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TPathPat` to a raw DB element, if possible. + */ + cached + Raw::Element convertPathPatToRaw(TPathPat e) { e = TPathPat(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TRangeExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertRangeExprToRaw(TRangeExpr e) { e = TRangeExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TRangePat` to a raw DB element, if possible. + */ + cached + Raw::Element convertRangePatToRaw(TRangePat e) { e = TRangePat(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TRecordFieldPat` to a raw DB element, if possible. + */ + cached + Raw::Element convertRecordFieldPatToRaw(TRecordFieldPat e) { e = TRecordFieldPat(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TRecordLitExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertRecordLitExprToRaw(TRecordLitExpr e) { e = TRecordLitExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TRecordLitField` to a raw DB element, if possible. + */ + cached + Raw::Element convertRecordLitFieldToRaw(TRecordLitField e) { e = TRecordLitField(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TRecordPat` to a raw DB element, if possible. + */ + cached + Raw::Element convertRecordPatToRaw(TRecordPat e) { e = TRecordPat(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TRefExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertRefExprToRaw(TRefExpr e) { e = TRefExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TRefPat` to a raw DB element, if possible. + */ + cached + Raw::Element convertRefPatToRaw(TRefPat e) { e = TRefPat(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TRepeatExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertRepeatExprToRaw(TRepeatExpr e) { e = TRepeatExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TReturnExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertReturnExprToRaw(TReturnExpr e) { e = TReturnExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TSlicePat` to a raw DB element, if possible. + */ + cached + Raw::Element convertSlicePatToRaw(TSlicePat e) { e = TSlicePat(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TTupleExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertTupleExprToRaw(TTupleExpr e) { e = TTupleExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TTuplePat` to a raw DB element, if possible. + */ + cached + Raw::Element convertTuplePatToRaw(TTuplePat e) { e = TTuplePat(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TTupleStructPat` to a raw DB element, if possible. + */ + cached + Raw::Element convertTupleStructPatToRaw(TTupleStructPat e) { e = TTupleStructPat(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TTypeRef` to a raw DB element, if possible. + */ + cached + Raw::Element convertTypeRefToRaw(TTypeRef e) { e = TTypeRef(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TUnaryOpExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertUnaryOpExprToRaw(TUnaryOpExpr e) { e = TUnaryOpExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TUnderscoreExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertUnderscoreExprToRaw(TUnderscoreExpr e) { e = TUnderscoreExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TUnimplemented` to a raw DB element, if possible. + */ + cached + Raw::Element convertUnimplementedToRaw(TUnimplemented e) { e = TUnimplemented(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TUnknownFile` to a raw DB element, if possible. + */ + cached + Raw::Element convertUnknownFileToRaw(TUnknownFile e) { none() } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TUnknownLocation` to a raw DB element, if possible. + */ + cached + Raw::Element convertUnknownLocationToRaw(TUnknownLocation e) { none() } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TUnsafeBlockExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertUnsafeBlockExprToRaw(TUnsafeBlockExpr e) { e = TUnsafeBlockExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TWildPat` to a raw DB element, if possible. + */ + cached + Raw::Element convertWildPatToRaw(TWildPat e) { e = TWildPat(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TYeetExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertYeetExprToRaw(TYeetExpr e) { e = TYeetExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TYieldExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertYieldExprToRaw(TYieldExpr e) { e = TYieldExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TArrayExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertArrayExprToRaw(TArrayExpr e) { + result = convertElementListExprToRaw(e) + or + result = convertRepeatExprToRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TAstNode` to a raw DB element, if possible. + */ + cached + Raw::Element convertAstNodeToRaw(TAstNode e) { + result = convertDeclarationToRaw(e) + or + result = convertExprToRaw(e) + or + result = convertLabelToRaw(e) + or + result = convertMatchArmToRaw(e) + or + result = convertPatToRaw(e) + or + result = convertRecordFieldPatToRaw(e) + or + result = convertRecordLitFieldToRaw(e) + or + result = convertStmtToRaw(e) + or + result = convertTypeRefToRaw(e) + or + result = convertUnimplementedToRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TBlockExprBase` to a raw DB element, if possible. + */ + cached + Raw::Element convertBlockExprBaseToRaw(TBlockExprBase e) { + result = convertAsyncBlockExprToRaw(e) + or + result = convertBlockExprToRaw(e) + or + result = convertUnsafeBlockExprToRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TDeclaration` to a raw DB element, if possible. + */ + cached + Raw::Element convertDeclarationToRaw(TDeclaration e) { + result = convertFunctionToRaw(e) + or + result = convertModuleToRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TElement` to a raw DB element, if possible. + */ + cached + Raw::Element convertElementToRaw(TElement e) { + result = convertFileToRaw(e) + or + result = convertLocatableToRaw(e) + or + result = convertLocationToRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TExpr` to a raw DB element, if possible. + */ + cached + Raw::Element convertExprToRaw(TExpr e) { + result = convertArrayExprToRaw(e) + or + result = convertAwaitExprToRaw(e) + or + result = convertBecomeExprToRaw(e) + or + result = convertBinaryOpExprToRaw(e) + or + result = convertBlockExprBaseToRaw(e) + or + result = convertBoxExprToRaw(e) + or + result = convertBreakExprToRaw(e) + or + result = convertCallExprToRaw(e) + or + result = convertCastExprToRaw(e) + or + result = convertClosureExprToRaw(e) + or + result = convertConstExprToRaw(e) + or + result = convertContinueExprToRaw(e) + or + result = convertFieldExprToRaw(e) + or + result = convertIfExprToRaw(e) + or + result = convertIndexExprToRaw(e) + or + result = convertInlineAsmExprToRaw(e) + or + result = convertLetExprToRaw(e) + or + result = convertLiteralExprToRaw(e) + or + result = convertLoopExprToRaw(e) + or + result = convertMatchExprToRaw(e) + or + result = convertMethodCallExprToRaw(e) + or + result = convertMissingExprToRaw(e) + or + result = convertOffsetOfExprToRaw(e) + or + result = convertPathExprToRaw(e) + or + result = convertRangeExprToRaw(e) + or + result = convertRecordLitExprToRaw(e) + or + result = convertRefExprToRaw(e) + or + result = convertReturnExprToRaw(e) + or + result = convertTupleExprToRaw(e) + or + result = convertUnaryOpExprToRaw(e) + or + result = convertUnderscoreExprToRaw(e) + or + result = convertYeetExprToRaw(e) + or + result = convertYieldExprToRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TFile` to a raw DB element, if possible. + */ + cached + Raw::Element convertFileToRaw(TFile e) { + result = convertDbFileToRaw(e) + or + result = convertUnknownFileToRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TLocatable` to a raw DB element, if possible. + */ + cached + Raw::Element convertLocatableToRaw(TLocatable e) { result = convertAstNodeToRaw(e) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TLocation` to a raw DB element, if possible. + */ + cached + Raw::Element convertLocationToRaw(TLocation e) { + result = convertDbLocationToRaw(e) + or + result = convertUnknownLocationToRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TPat` to a raw DB element, if possible. + */ + cached + Raw::Element convertPatToRaw(TPat e) { + result = convertBindPatToRaw(e) + or + result = convertBoxPatToRaw(e) + or + result = convertConstBlockPatToRaw(e) + or + result = convertLitPatToRaw(e) + or + result = convertMissingPatToRaw(e) + or + result = convertOrPatToRaw(e) + or + result = convertPathPatToRaw(e) + or + result = convertRangePatToRaw(e) + or + result = convertRecordPatToRaw(e) + or + result = convertRefPatToRaw(e) + or + result = convertSlicePatToRaw(e) + or + result = convertTuplePatToRaw(e) + or + result = convertTupleStructPatToRaw(e) + or + result = convertWildPatToRaw(e) + } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TStmt` to a raw DB element, if possible. + */ + cached + Raw::Element convertStmtToRaw(TStmt e) { + result = convertExprStmtToRaw(e) + or + result = convertItemStmtToRaw(e) + or + result = convertLetStmtToRaw(e) + } +} diff --git a/rust/ql/lib/codeql/rust/generated/SynthConstructors.qll b/rust/ql/lib/codeql/rust/generated/SynthConstructors.qll new file mode 100644 index 000000000000..c4281ed696ee --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/SynthConstructors.qll @@ -0,0 +1,68 @@ +// generated by codegen +/** + * This module exports all modules providing `Element` subclasses. + */ + +import codeql.rust.elements.AsyncBlockExprConstructor +import codeql.rust.elements.AwaitExprConstructor +import codeql.rust.elements.BecomeExprConstructor +import codeql.rust.elements.BinaryOpExprConstructor +import codeql.rust.elements.BindPatConstructor +import codeql.rust.elements.BlockExprConstructor +import codeql.rust.elements.BoxExprConstructor +import codeql.rust.elements.BoxPatConstructor +import codeql.rust.elements.BreakExprConstructor +import codeql.rust.elements.CallExprConstructor +import codeql.rust.elements.CastExprConstructor +import codeql.rust.elements.ClosureExprConstructor +import codeql.rust.elements.ConstBlockPatConstructor +import codeql.rust.elements.ConstExprConstructor +import codeql.rust.elements.ContinueExprConstructor +import codeql.rust.elements.DbFileConstructor +import codeql.rust.elements.DbLocationConstructor +import codeql.rust.elements.ElementListExprConstructor +import codeql.rust.elements.ExprStmtConstructor +import codeql.rust.elements.FieldExprConstructor +import codeql.rust.elements.FunctionConstructor +import codeql.rust.elements.IfExprConstructor +import codeql.rust.elements.IndexExprConstructor +import codeql.rust.elements.InlineAsmExprConstructor +import codeql.rust.elements.ItemStmtConstructor +import codeql.rust.elements.LabelConstructor +import codeql.rust.elements.LetExprConstructor +import codeql.rust.elements.LetStmtConstructor +import codeql.rust.elements.LitPatConstructor +import codeql.rust.elements.LiteralExprConstructor +import codeql.rust.elements.LoopExprConstructor +import codeql.rust.elements.MatchArmConstructor +import codeql.rust.elements.MatchExprConstructor +import codeql.rust.elements.MethodCallExprConstructor +import codeql.rust.elements.MissingExprConstructor +import codeql.rust.elements.MissingPatConstructor +import codeql.rust.elements.ModuleConstructor +import codeql.rust.elements.OffsetOfExprConstructor +import codeql.rust.elements.OrPatConstructor +import codeql.rust.elements.PathExprConstructor +import codeql.rust.elements.PathPatConstructor +import codeql.rust.elements.RangeExprConstructor +import codeql.rust.elements.RangePatConstructor +import codeql.rust.elements.RecordFieldPatConstructor +import codeql.rust.elements.RecordLitExprConstructor +import codeql.rust.elements.RecordLitFieldConstructor +import codeql.rust.elements.RecordPatConstructor +import codeql.rust.elements.RefExprConstructor +import codeql.rust.elements.RefPatConstructor +import codeql.rust.elements.RepeatExprConstructor +import codeql.rust.elements.ReturnExprConstructor +import codeql.rust.elements.SlicePatConstructor +import codeql.rust.elements.TupleExprConstructor +import codeql.rust.elements.TuplePatConstructor +import codeql.rust.elements.TupleStructPatConstructor +import codeql.rust.elements.TypeRefConstructor +import codeql.rust.elements.UnaryOpExprConstructor +import codeql.rust.elements.UnderscoreExprConstructor +import codeql.rust.elements.UnimplementedConstructor +import codeql.rust.elements.UnsafeBlockExprConstructor +import codeql.rust.elements.WildPatConstructor +import codeql.rust.elements.YeetExprConstructor +import codeql.rust.elements.YieldExprConstructor diff --git a/rust/ql/lib/codeql/rust/generated/TupleExpr.qll b/rust/ql/lib/codeql/rust/generated/TupleExpr.qll new file mode 100644 index 000000000000..730550be4569 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/TupleExpr.qll @@ -0,0 +1,48 @@ +// generated by codegen +/** + * This module provides the generated definition of `TupleExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `TupleExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::TupleExpr` class directly. + * Use the subclass `TupleExpr`, where the following predicates are available. + */ + class TupleExpr extends Synth::TTupleExpr, Expr { + override string getAPrimaryQlClass() { result = "TupleExpr" } + + /** + * Gets the `index`th expression of this tuple expression (0-based). + */ + Expr getExpr(int index) { + result = + Synth::convertExprFromRaw(Synth::convertTupleExprToRaw(this).(Raw::TupleExpr).getExpr(index)) + } + + /** + * Gets any of the expressions of this tuple expression. + */ + final Expr getAnExpr() { result = this.getExpr(_) } + + /** + * Gets the number of expressions of this tuple expression. + */ + final int getNumberOfExprs() { result = count(int i | exists(this.getExpr(i))) } + + /** + * Holds if this tuple expression is assignee expression. + */ + predicate isAssigneeExpr() { + Synth::convertTupleExprToRaw(this).(Raw::TupleExpr).isAssigneeExpr() + } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/TuplePat.qll b/rust/ql/lib/codeql/rust/generated/TuplePat.qll new file mode 100644 index 000000000000..8ed7f0b15ecd --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/TuplePat.qll @@ -0,0 +1,53 @@ +// generated by codegen +/** + * This module provides the generated definition of `TuplePat`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Pat + +/** + * INTERNAL: This module contains the fully generated definition of `TuplePat` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::TuplePat` class directly. + * Use the subclass `TuplePat`, where the following predicates are available. + */ + class TuplePat extends Synth::TTuplePat, Pat { + override string getAPrimaryQlClass() { result = "TuplePat" } + + /** + * Gets the `index`th argument of this tuple pat (0-based). + */ + Pat getArg(int index) { + result = + Synth::convertPatFromRaw(Synth::convertTuplePatToRaw(this).(Raw::TuplePat).getArg(index)) + } + + /** + * Gets any of the arguments of this tuple pat. + */ + final Pat getAnArg() { result = this.getArg(_) } + + /** + * Gets the number of arguments of this tuple pat. + */ + final int getNumberOfArgs() { result = count(int i | exists(this.getArg(i))) } + + /** + * Gets the ellipsis index of this tuple pat, if it exists. + */ + int getEllipsisIndex() { + result = Synth::convertTuplePatToRaw(this).(Raw::TuplePat).getEllipsisIndex() + } + + /** + * Holds if `getEllipsisIndex()` exists. + */ + final predicate hasEllipsisIndex() { exists(this.getEllipsisIndex()) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/TupleStructPat.qll b/rust/ql/lib/codeql/rust/generated/TupleStructPat.qll new file mode 100644 index 000000000000..606ceb90375c --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/TupleStructPat.qll @@ -0,0 +1,71 @@ +// generated by codegen +/** + * This module provides the generated definition of `TupleStructPat`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Pat +import codeql.rust.elements.Unimplemented + +/** + * INTERNAL: This module contains the fully generated definition of `TupleStructPat` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::TupleStructPat` class directly. + * Use the subclass `TupleStructPat`, where the following predicates are available. + */ + class TupleStructPat extends Synth::TTupleStructPat, Pat { + override string getAPrimaryQlClass() { result = "TupleStructPat" } + + /** + * Gets the path of this tuple struct pat, if it exists. + */ + Unimplemented getPath() { + result = + Synth::convertUnimplementedFromRaw(Synth::convertTupleStructPatToRaw(this) + .(Raw::TupleStructPat) + .getPath()) + } + + /** + * Holds if `getPath()` exists. + */ + final predicate hasPath() { exists(this.getPath()) } + + /** + * Gets the `index`th argument of this tuple struct pat (0-based). + */ + Pat getArg(int index) { + result = + Synth::convertPatFromRaw(Synth::convertTupleStructPatToRaw(this) + .(Raw::TupleStructPat) + .getArg(index)) + } + + /** + * Gets any of the arguments of this tuple struct pat. + */ + final Pat getAnArg() { result = this.getArg(_) } + + /** + * Gets the number of arguments of this tuple struct pat. + */ + final int getNumberOfArgs() { result = count(int i | exists(this.getArg(i))) } + + /** + * Gets the ellipsis index of this tuple struct pat, if it exists. + */ + int getEllipsisIndex() { + result = Synth::convertTupleStructPatToRaw(this).(Raw::TupleStructPat).getEllipsisIndex() + } + + /** + * Holds if `getEllipsisIndex()` exists. + */ + final predicate hasEllipsisIndex() { exists(this.getEllipsisIndex()) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/TypeRef.qll b/rust/ql/lib/codeql/rust/generated/TypeRef.qll new file mode 100644 index 000000000000..b75359dbbec7 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/TypeRef.qll @@ -0,0 +1,23 @@ +// generated by codegen +/** + * This module provides the generated definition of `TypeRef`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.AstNode + +/** + * INTERNAL: This module contains the fully generated definition of `TypeRef` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::TypeRef` class directly. + * Use the subclass `TypeRef`, where the following predicates are available. + */ + class TypeRef extends Synth::TTypeRef, AstNode { + override string getAPrimaryQlClass() { result = "TypeRef" } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/UnaryOpExpr.qll b/rust/ql/lib/codeql/rust/generated/UnaryOpExpr.qll new file mode 100644 index 000000000000..283b8f8eae1f --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/UnaryOpExpr.qll @@ -0,0 +1,36 @@ +// generated by codegen +/** + * This module provides the generated definition of `UnaryOpExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `UnaryOpExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::UnaryOpExpr` class directly. + * Use the subclass `UnaryOpExpr`, where the following predicates are available. + */ + class UnaryOpExpr extends Synth::TUnaryOpExpr, Expr { + override string getAPrimaryQlClass() { result = "UnaryOpExpr" } + + /** + * Gets the expression of this unary op expression. + */ + Expr getExpr() { + result = + Synth::convertExprFromRaw(Synth::convertUnaryOpExprToRaw(this).(Raw::UnaryOpExpr).getExpr()) + } + + /** + * Gets the op of this unary op expression. + */ + string getOp() { result = Synth::convertUnaryOpExprToRaw(this).(Raw::UnaryOpExpr).getOp() } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/UnderscoreExpr.qll b/rust/ql/lib/codeql/rust/generated/UnderscoreExpr.qll new file mode 100644 index 000000000000..5ba5bd771557 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/UnderscoreExpr.qll @@ -0,0 +1,23 @@ +// generated by codegen +/** + * This module provides the generated definition of `UnderscoreExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `UnderscoreExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::UnderscoreExpr` class directly. + * Use the subclass `UnderscoreExpr`, where the following predicates are available. + */ + class UnderscoreExpr extends Synth::TUnderscoreExpr, Expr { + override string getAPrimaryQlClass() { result = "UnderscoreExpr" } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/Unimplemented.qll b/rust/ql/lib/codeql/rust/generated/Unimplemented.qll new file mode 100644 index 000000000000..749c88b8acae --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/Unimplemented.qll @@ -0,0 +1,23 @@ +// generated by codegen +/** + * This module provides the generated definition of `Unimplemented`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.AstNode + +/** + * INTERNAL: This module contains the fully generated definition of `Unimplemented` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::Unimplemented` class directly. + * Use the subclass `Unimplemented`, where the following predicates are available. + */ + class Unimplemented extends Synth::TUnimplemented, AstNode { + override string getAPrimaryQlClass() { result = "Unimplemented" } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/UnknownFile.qll b/rust/ql/lib/codeql/rust/generated/UnknownFile.qll new file mode 100644 index 000000000000..4b5ce7cc81e4 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/UnknownFile.qll @@ -0,0 +1,23 @@ +// generated by codegen +/** + * This module provides the generated definition of `UnknownFile`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.File + +/** + * INTERNAL: This module contains the fully generated definition of `UnknownFile` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::UnknownFile` class directly. + * Use the subclass `UnknownFile`, where the following predicates are available. + */ + class UnknownFile extends Synth::TUnknownFile, File { + override string getAPrimaryQlClass() { result = "UnknownFile" } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/UnknownLocation.qll b/rust/ql/lib/codeql/rust/generated/UnknownLocation.qll new file mode 100644 index 000000000000..5adaae87e7fc --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/UnknownLocation.qll @@ -0,0 +1,23 @@ +// generated by codegen +/** + * This module provides the generated definition of `UnknownLocation`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Location + +/** + * INTERNAL: This module contains the fully generated definition of `UnknownLocation` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::UnknownLocation` class directly. + * Use the subclass `UnknownLocation`, where the following predicates are available. + */ + class UnknownLocation extends Synth::TUnknownLocation, Location { + override string getAPrimaryQlClass() { result = "UnknownLocation" } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/UnsafeBlockExpr.qll b/rust/ql/lib/codeql/rust/generated/UnsafeBlockExpr.qll new file mode 100644 index 000000000000..e53ce046fa66 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/UnsafeBlockExpr.qll @@ -0,0 +1,23 @@ +// generated by codegen +/** + * This module provides the generated definition of `UnsafeBlockExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.BlockExprBase + +/** + * INTERNAL: This module contains the fully generated definition of `UnsafeBlockExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::UnsafeBlockExpr` class directly. + * Use the subclass `UnsafeBlockExpr`, where the following predicates are available. + */ + class UnsafeBlockExpr extends Synth::TUnsafeBlockExpr, BlockExprBase { + override string getAPrimaryQlClass() { result = "UnsafeBlockExpr" } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/WildPat.qll b/rust/ql/lib/codeql/rust/generated/WildPat.qll new file mode 100644 index 000000000000..05db09c16e0c --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/WildPat.qll @@ -0,0 +1,23 @@ +// generated by codegen +/** + * This module provides the generated definition of `WildPat`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Pat + +/** + * INTERNAL: This module contains the fully generated definition of `WildPat` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::WildPat` class directly. + * Use the subclass `WildPat`, where the following predicates are available. + */ + class WildPat extends Synth::TWildPat, Pat { + override string getAPrimaryQlClass() { result = "WildPat" } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/YeetExpr.qll b/rust/ql/lib/codeql/rust/generated/YeetExpr.qll new file mode 100644 index 000000000000..3599779650d2 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/YeetExpr.qll @@ -0,0 +1,36 @@ +// generated by codegen +/** + * This module provides the generated definition of `YeetExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `YeetExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::YeetExpr` class directly. + * Use the subclass `YeetExpr`, where the following predicates are available. + */ + class YeetExpr extends Synth::TYeetExpr, Expr { + override string getAPrimaryQlClass() { result = "YeetExpr" } + + /** + * Gets the expression of this yeet expression, if it exists. + */ + Expr getExpr() { + result = + Synth::convertExprFromRaw(Synth::convertYeetExprToRaw(this).(Raw::YeetExpr).getExpr()) + } + + /** + * Holds if `getExpr()` exists. + */ + final predicate hasExpr() { exists(this.getExpr()) } + } +} diff --git a/rust/ql/lib/codeql/rust/generated/YieldExpr.qll b/rust/ql/lib/codeql/rust/generated/YieldExpr.qll new file mode 100644 index 000000000000..6abe7de7fba6 --- /dev/null +++ b/rust/ql/lib/codeql/rust/generated/YieldExpr.qll @@ -0,0 +1,36 @@ +// generated by codegen +/** + * This module provides the generated definition of `YieldExpr`. + * INTERNAL: Do not import directly. + */ + +private import codeql.rust.generated.Synth +private import codeql.rust.generated.Raw +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `YieldExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::YieldExpr` class directly. + * Use the subclass `YieldExpr`, where the following predicates are available. + */ + class YieldExpr extends Synth::TYieldExpr, Expr { + override string getAPrimaryQlClass() { result = "YieldExpr" } + + /** + * Gets the expression of this yield expression, if it exists. + */ + Expr getExpr() { + result = + Synth::convertExprFromRaw(Synth::convertYieldExprToRaw(this).(Raw::YieldExpr).getExpr()) + } + + /** + * Holds if `getExpr()` exists. + */ + final predicate hasExpr() { exists(this.getExpr()) } + } +} diff --git a/rust/ql/lib/codeql/rust/printast/PrintAst.qll b/rust/ql/lib/codeql/rust/printast/PrintAst.qll new file mode 100644 index 000000000000..af16368f3c0c --- /dev/null +++ b/rust/ql/lib/codeql/rust/printast/PrintAst.qll @@ -0,0 +1,49 @@ +/** + * Provides queries to pretty-print a Rust AST as a graph. + */ + +import PrintAstNode + +cached +private int getOrder(PrintAstNode node) { + node = + rank[result](PrintAstNode n, Location loc | + loc = n.getLocation() + | + n + order by + loc.getFile().getName(), loc.getStartLine(), loc.getStartColumn(), loc.getEndLine(), + loc.getEndColumn() + ) +} + +/** Holds if `node` belongs to the output tree, and its property `key` has the given `value`. */ +query predicate nodes(PrintAstNode node, string key, string value) { + node.shouldBePrinted() and + ( + key = "semmle.label" and value = node.toString() + or + key = "semmle.order" and value = getOrder(node).toString() + or + value = node.getProperty(key) + ) +} + +/** + * Holds if `target` is a child of `source` in the AST, and property `key` of the edge has the + * given `value`. + */ +query predicate edges(PrintAstNode source, PrintAstNode target, string key, string value) { + source.shouldBePrinted() and + target.shouldBePrinted() and + exists(int index, string accessor | source.hasChild(target, index, accessor) | + key = "semmle.label" and value = accessor + or + key = "semmle.order" and value = index.toString() + ) +} + +/** Holds if property `key` of the graph has the given `value`. */ +query predicate graphProperties(string key, string value) { + key = "semmle.graphKind" and value = "tree" +} diff --git a/rust/ql/lib/codeql/rust/printast/PrintAstNode.qll b/rust/ql/lib/codeql/rust/printast/PrintAstNode.qll new file mode 100644 index 000000000000..7caae22893c3 --- /dev/null +++ b/rust/ql/lib/codeql/rust/printast/PrintAstNode.qll @@ -0,0 +1,110 @@ +/** + * Provides classes used to pretty-print a Rust AST as a graph. + * This is factored out of `PrintAst.qll` for testing purposes. + */ + +import rust +import codeql.rust.generated.ParentChild + +private newtype TPrintAstConfiguration = TMakePrintAstConfiguration() + +/** + * The hook to customize the files and functions printed by this module. + */ +class PrintAstConfiguration extends TPrintAstConfiguration { + /** + * Gets the string representation of this singleton + */ + string toString() { result = "PrintAstConfiguration" } + + /** + * Holds if the AST for `e` should be printed. By default, holds for all. + */ + predicate shouldPrint(Locatable e) { any() } +} + +private predicate shouldPrint(Locatable e) { any(PrintAstConfiguration config).shouldPrint(e) } + +/** + * An AST node that should be printed. + */ +private newtype TPrintAstNode = TPrintLocatable(Locatable ast) + +/** + * A node in the output tree. + */ +class PrintAstNode extends TPrintAstNode { + /** + * Gets a textual representation of this node. + */ + abstract string toString(); + + /** + * Gets the child node at index `index`. Child indices must be unique, + * but need not be contiguous. + */ + abstract predicate hasChild(PrintAstNode child, int index, string label); + + /** + * Holds if this node should be printed in the output. + */ + abstract predicate shouldBePrinted(); + + /** + * Gets the location of this node in the source code. + */ + abstract Location getLocation(); + + /** + * Gets the value of an additional property of this node, where the name of + * the property is `key`. + */ + string getProperty(string key) { none() } + + /** + * Gets the underlying AST node, if any. + */ + abstract Locatable getAstNode(); +} + +private string prettyPrint(Locatable e) { + result = "[" + concat(e.getPrimaryQlClasses(), ", ") + "] " + e +} + +private class Unresolved extends Locatable { + Unresolved() { this != this.resolve() } +} + +/** + * A graph node representing a real Locatable node. + */ +class PrintLocatable extends PrintAstNode, TPrintLocatable { + Locatable ast; + + PrintLocatable() { this = TPrintLocatable(ast) } + + override string toString() { result = prettyPrint(ast) } + + final override predicate shouldBePrinted() { shouldPrint(ast) } + + override predicate hasChild(PrintAstNode child, int index, string label) { + child = TPrintLocatable(any(Locatable c | c = getChildAndAccessor(ast, index, label))) + } + + final override Locatable getAstNode() { result = ast } + + final override Location getLocation() { result = ast.getLocation() } +} + +/** + * A specialization of graph node for "unresolved" children, that is nodes in + * the parallel conversion AST. + */ +class PrintUnresolved extends PrintLocatable { + override Unresolved ast; + + override predicate hasChild(PrintAstNode child, int index, string label) { + // only print immediate unresolved children from the "parallel" AST + child = TPrintLocatable(getImmediateChildAndAccessor(ast, index, label).(Unresolved)) + } +} diff --git a/rust/ql/lib/qlpack.lock.yml b/rust/ql/lib/qlpack.lock.yml new file mode 100644 index 000000000000..06dd07fc7dc7 --- /dev/null +++ b/rust/ql/lib/qlpack.lock.yml @@ -0,0 +1,4 @@ +--- +dependencies: {} +compiled: false +lockVersion: 1.0.0 diff --git a/rust/ql/lib/qlpack.yml b/rust/ql/lib/qlpack.yml new file mode 100644 index 000000000000..649d02c8e3aa --- /dev/null +++ b/rust/ql/lib/qlpack.yml @@ -0,0 +1,15 @@ +name: codeql/rust-all +version: 0.1.0-dev +groups: rust +extractor: rust +dbscheme: rust.dbscheme +library: true +dependencies: + codeql/controlflow: ${workspace} + codeql/dataflow: ${workspace} + codeql/regex: ${workspace} + codeql/mad: ${workspace} + codeql/ssa: ${workspace} + codeql/tutorial: ${workspace} + codeql/util: ${workspace} +warnOnImplicitThis: true diff --git a/rust/ql/lib/rust.dbscheme b/rust/ql/lib/rust.dbscheme new file mode 100644 index 000000000000..c38f0f61ea0f --- /dev/null +++ b/rust/ql/lib/rust.dbscheme @@ -0,0 +1,798 @@ +// generated by codegen + +// from prefix.dbscheme +/** + * The source location of the snapshot. + */ +sourceLocationPrefix( + string prefix: string ref +); + + +// from schema.py + +@element = + @file +| @locatable +| @location +; + +@file = + @db_file +; + +#keyset[id] +files( + int id: @file ref, + string name: string ref +); + +@locatable = + @ast_node +; + +#keyset[id] +locatable_locations( + int id: @locatable ref, + int location: @location ref +); + +@location = + @db_location +; + +#keyset[id] +locations( + int id: @location ref, + int file: @file ref, + int start_line: int ref, + int start_column: int ref, + int end_line: int ref, + int end_column: int ref +); + +@ast_node = + @declaration +| @expr +| @label +| @match_arm +| @pat +| @record_field_pat +| @record_lit_field +| @stmt +| @type_ref +| @unimplemented +; + +db_files( + unique int id: @db_file +); + +db_locations( + unique int id: @db_location +); + +@declaration = + @function +| @module +; + +@expr = + @array_expr +| @await_expr +| @become_expr +| @binary_op_expr +| @block_expr_base +| @box_expr +| @break_expr +| @call_expr +| @cast_expr +| @closure_expr +| @const_expr +| @continue_expr +| @field_expr +| @if_expr +| @index_expr +| @inline_asm_expr +| @let_expr +| @literal_expr +| @loop_expr +| @match_expr +| @method_call_expr +| @missing_expr +| @offset_of_expr +| @path_expr +| @range_expr +| @record_lit_expr +| @ref_expr +| @return_expr +| @tuple_expr +| @unary_op_expr +| @underscore_expr +| @yeet_expr +| @yield_expr +; + +labels( + unique int id: @label, + string name: string ref +); + +match_arms( + unique int id: @match_arm, + int pat: @pat ref, + int expr: @expr ref +); + +#keyset[id] +match_arm_guards( + int id: @match_arm ref, + int guard: @expr ref +); + +@pat = + @bind_pat +| @box_pat +| @const_block_pat +| @lit_pat +| @missing_pat +| @or_pat +| @path_pat +| @range_pat +| @record_pat +| @ref_pat +| @slice_pat +| @tuple_pat +| @tuple_struct_pat +| @wild_pat +; + +record_field_pats( + unique int id: @record_field_pat, + string name: string ref, + int pat: @pat ref +); + +record_lit_fields( + unique int id: @record_lit_field, + string name: string ref, + int expr: @expr ref +); + +@stmt = + @expr_stmt +| @item_stmt +| @let_stmt +; + +type_refs( + unique int id: @type_ref +); + +unimplementeds( + unique int id: @unimplemented +); + +@array_expr = + @element_list_expr +| @repeat_expr +; + +await_exprs( + unique int id: @await_expr, + int expr: @expr ref +); + +become_exprs( + unique int id: @become_expr, + int expr: @expr ref +); + +binary_op_exprs( + unique int id: @binary_op_expr, + int lhs: @expr ref, + int rhs: @expr ref +); + +#keyset[id] +binary_op_expr_ops( + int id: @binary_op_expr ref, + string op: string ref +); + +bind_pats( + unique int id: @bind_pat, + string binding_id: string ref +); + +#keyset[id] +bind_pat_subpats( + int id: @bind_pat ref, + int subpat: @pat ref +); + +@block_expr_base = + @async_block_expr +| @block_expr +| @unsafe_block_expr +; + +#keyset[id, index] +block_expr_base_statements( + int id: @block_expr_base ref, + int index: int ref, + int statement: @stmt ref +); + +#keyset[id] +block_expr_base_tails( + int id: @block_expr_base ref, + int tail: @expr ref +); + +box_exprs( + unique int id: @box_expr, + int expr: @expr ref +); + +box_pats( + unique int id: @box_pat, + int inner: @pat ref +); + +break_exprs( + unique int id: @break_expr +); + +#keyset[id] +break_expr_exprs( + int id: @break_expr ref, + int expr: @expr ref +); + +#keyset[id] +break_expr_labels( + int id: @break_expr ref, + int label: @label ref +); + +call_exprs( + unique int id: @call_expr, + int callee: @expr ref +); + +#keyset[id, index] +call_expr_args( + int id: @call_expr ref, + int index: int ref, + int arg: @expr ref +); + +#keyset[id] +call_expr_is_assignee_expr( + int id: @call_expr ref +); + +cast_exprs( + unique int id: @cast_expr, + int expr: @expr ref, + int type_ref: @type_ref ref +); + +closure_exprs( + unique int id: @closure_expr, + int body: @expr ref, + string closure_kind: string ref +); + +#keyset[id, index] +closure_expr_args( + int id: @closure_expr ref, + int index: int ref, + int arg: @pat ref +); + +#keyset[id, index] +closure_expr_arg_types( + int id: @closure_expr ref, + int index: int ref, + int arg_type: @type_ref ref +); + +#keyset[id] +closure_expr_ret_types( + int id: @closure_expr ref, + int ret_type: @type_ref ref +); + +#keyset[id] +closure_expr_is_move( + int id: @closure_expr ref +); + +const_block_pats( + unique int id: @const_block_pat, + int expr: @expr ref +); + +const_exprs( + unique int id: @const_expr, + int expr: @expr ref +); + +continue_exprs( + unique int id: @continue_expr +); + +#keyset[id] +continue_expr_labels( + int id: @continue_expr ref, + int label: @label ref +); + +expr_stmts( + unique int id: @expr_stmt, + int expr: @expr ref +); + +#keyset[id] +expr_stmt_has_semicolon( + int id: @expr_stmt ref +); + +field_exprs( + unique int id: @field_expr, + int expr: @expr ref, + string name: string ref +); + +functions( + unique int id: @function, + string name: string ref, + int body: @expr ref +); + +if_exprs( + unique int id: @if_expr, + int condition: @expr ref, + int then: @expr ref +); + +#keyset[id] +if_expr_elses( + int id: @if_expr ref, + int else: @expr ref +); + +index_exprs( + unique int id: @index_expr, + int base: @expr ref, + int index: @expr ref +); + +#keyset[id] +index_expr_is_assignee_expr( + int id: @index_expr ref +); + +inline_asm_exprs( + unique int id: @inline_asm_expr, + int expr: @expr ref +); + +item_stmts( + unique int id: @item_stmt +); + +let_exprs( + unique int id: @let_expr, + int pat: @pat ref, + int expr: @expr ref +); + +let_stmts( + unique int id: @let_stmt, + int pat: @pat ref +); + +#keyset[id] +let_stmt_type_refs( + int id: @let_stmt ref, + int type_ref: @type_ref ref +); + +#keyset[id] +let_stmt_initializers( + int id: @let_stmt ref, + int initializer: @expr ref +); + +#keyset[id] +let_stmt_elses( + int id: @let_stmt ref, + int else: @expr ref +); + +lit_pats( + unique int id: @lit_pat, + int expr: @expr ref +); + +literal_exprs( + unique int id: @literal_expr +); + +loop_exprs( + unique int id: @loop_expr, + int body: @expr ref +); + +#keyset[id] +loop_expr_labels( + int id: @loop_expr ref, + int label: @label ref +); + +match_exprs( + unique int id: @match_expr, + int expr: @expr ref +); + +#keyset[id, index] +match_expr_branches( + int id: @match_expr ref, + int index: int ref, + int branch: @match_arm ref +); + +method_call_exprs( + unique int id: @method_call_expr, + int receiver: @expr ref, + string method_name: string ref +); + +#keyset[id, index] +method_call_expr_args( + int id: @method_call_expr ref, + int index: int ref, + int arg: @expr ref +); + +#keyset[id] +method_call_expr_generic_args( + int id: @method_call_expr ref, + int generic_args: @unimplemented ref +); + +missing_exprs( + unique int id: @missing_expr +); + +missing_pats( + unique int id: @missing_pat +); + +modules( + unique int id: @module +); + +#keyset[id, index] +module_declarations( + int id: @module ref, + int index: int ref, + int declaration: @declaration ref +); + +offset_of_exprs( + unique int id: @offset_of_expr, + int container: @type_ref ref +); + +#keyset[id, index] +offset_of_expr_fields( + int id: @offset_of_expr ref, + int index: int ref, + string field: string ref +); + +or_pats( + unique int id: @or_pat +); + +#keyset[id, index] +or_pat_args( + int id: @or_pat ref, + int index: int ref, + int arg: @pat ref +); + +path_exprs( + unique int id: @path_expr, + int path: @unimplemented ref +); + +path_pats( + unique int id: @path_pat, + int path: @unimplemented ref +); + +range_exprs( + unique int id: @range_expr +); + +#keyset[id] +range_expr_lhs( + int id: @range_expr ref, + int lhs: @expr ref +); + +#keyset[id] +range_expr_rhs( + int id: @range_expr ref, + int rhs: @expr ref +); + +#keyset[id] +range_expr_is_inclusive( + int id: @range_expr ref +); + +range_pats( + unique int id: @range_pat +); + +#keyset[id] +range_pat_starts( + int id: @range_pat ref, + int start: @pat ref +); + +#keyset[id] +range_pat_ends( + int id: @range_pat ref, + int end: @pat ref +); + +record_lit_exprs( + unique int id: @record_lit_expr +); + +#keyset[id] +record_lit_expr_paths( + int id: @record_lit_expr ref, + int path: @unimplemented ref +); + +#keyset[id, index] +record_lit_expr_fields( + int id: @record_lit_expr ref, + int index: int ref, + int field: @record_lit_field ref +); + +#keyset[id] +record_lit_expr_spreads( + int id: @record_lit_expr ref, + int spread: @expr ref +); + +#keyset[id] +record_lit_expr_has_ellipsis( + int id: @record_lit_expr ref +); + +#keyset[id] +record_lit_expr_is_assignee_expr( + int id: @record_lit_expr ref +); + +record_pats( + unique int id: @record_pat +); + +#keyset[id] +record_pat_paths( + int id: @record_pat ref, + int path: @unimplemented ref +); + +#keyset[id, index] +record_pat_args( + int id: @record_pat ref, + int index: int ref, + int arg: @record_field_pat ref +); + +#keyset[id] +record_pat_has_ellipsis( + int id: @record_pat ref +); + +ref_exprs( + unique int id: @ref_expr, + int expr: @expr ref +); + +#keyset[id] +ref_expr_is_raw( + int id: @ref_expr ref +); + +#keyset[id] +ref_expr_is_mut( + int id: @ref_expr ref +); + +ref_pats( + unique int id: @ref_pat, + int pat: @pat ref +); + +#keyset[id] +ref_pat_is_mut( + int id: @ref_pat ref +); + +return_exprs( + unique int id: @return_expr +); + +#keyset[id] +return_expr_exprs( + int id: @return_expr ref, + int expr: @expr ref +); + +slice_pats( + unique int id: @slice_pat +); + +#keyset[id, index] +slice_pat_prefixes( + int id: @slice_pat ref, + int index: int ref, + int prefix: @pat ref +); + +#keyset[id] +slice_pat_slice( + int id: @slice_pat ref, + int slice: @pat ref +); + +#keyset[id, index] +slice_pat_suffixes( + int id: @slice_pat ref, + int index: int ref, + int suffix: @pat ref +); + +tuple_exprs( + unique int id: @tuple_expr +); + +#keyset[id, index] +tuple_expr_exprs( + int id: @tuple_expr ref, + int index: int ref, + int expr: @expr ref +); + +#keyset[id] +tuple_expr_is_assignee_expr( + int id: @tuple_expr ref +); + +tuple_pats( + unique int id: @tuple_pat +); + +#keyset[id, index] +tuple_pat_args( + int id: @tuple_pat ref, + int index: int ref, + int arg: @pat ref +); + +#keyset[id] +tuple_pat_ellipsis_indices( + int id: @tuple_pat ref, + int ellipsis_index: int ref +); + +tuple_struct_pats( + unique int id: @tuple_struct_pat +); + +#keyset[id] +tuple_struct_pat_paths( + int id: @tuple_struct_pat ref, + int path: @unimplemented ref +); + +#keyset[id, index] +tuple_struct_pat_args( + int id: @tuple_struct_pat ref, + int index: int ref, + int arg: @pat ref +); + +#keyset[id] +tuple_struct_pat_ellipsis_indices( + int id: @tuple_struct_pat ref, + int ellipsis_index: int ref +); + +unary_op_exprs( + unique int id: @unary_op_expr, + int expr: @expr ref, + string op: string ref +); + +underscore_exprs( + unique int id: @underscore_expr +); + +wild_pats( + unique int id: @wild_pat +); + +yeet_exprs( + unique int id: @yeet_expr +); + +#keyset[id] +yeet_expr_exprs( + int id: @yeet_expr ref, + int expr: @expr ref +); + +yield_exprs( + unique int id: @yield_expr +); + +#keyset[id] +yield_expr_exprs( + int id: @yield_expr ref, + int expr: @expr ref +); + +async_block_exprs( + unique int id: @async_block_expr +); + +block_exprs( + unique int id: @block_expr +); + +#keyset[id] +block_expr_labels( + int id: @block_expr ref, + int label: @label ref +); + +element_list_exprs( + unique int id: @element_list_expr +); + +#keyset[id, index] +element_list_expr_elements( + int id: @element_list_expr ref, + int index: int ref, + int element: @expr ref +); + +#keyset[id] +element_list_expr_is_assignee_expr( + int id: @element_list_expr ref +); + +repeat_exprs( + unique int id: @repeat_expr, + int initializer: @expr ref, + int repeat: @expr ref +); + +unsafe_block_exprs( + unique int id: @unsafe_block_expr +); diff --git a/rust/ql/lib/rust.dbscheme.stats b/rust/ql/lib/rust.dbscheme.stats new file mode 100644 index 000000000000..9995467e33e5 --- /dev/null +++ b/rust/ql/lib/rust.dbscheme.stats @@ -0,0 +1,4 @@ + + + + diff --git a/rust/ql/lib/rust.qll b/rust/ql/lib/rust.qll new file mode 100644 index 000000000000..cedced159c33 --- /dev/null +++ b/rust/ql/lib/rust.qll @@ -0,0 +1,3 @@ +/** Top-level import for the Rust language pack */ + +import codeql.rust.elements diff --git a/rust/ql/src/qlpack.lock.yml b/rust/ql/src/qlpack.lock.yml new file mode 100644 index 000000000000..06dd07fc7dc7 --- /dev/null +++ b/rust/ql/src/qlpack.lock.yml @@ -0,0 +1,4 @@ +--- +dependencies: {} +compiled: false +lockVersion: 1.0.0 diff --git a/rust/ql/src/qlpack.yml b/rust/ql/src/qlpack.yml new file mode 100644 index 000000000000..1638da417ced --- /dev/null +++ b/rust/ql/src/qlpack.yml @@ -0,0 +1,12 @@ +name: codeql/rust-queries +version: 0.1.0-dev +groups: + - rust + - queries +suites: codeql-suites +extractor: rust +dependencies: + codeql/rust-all: ${workspace} + codeql/suite-helpers: ${workspace} + codeql/util: ${workspace} +warnOnImplicitThis: true diff --git a/rust/ql/src/queries/ide-contextual-queries/printAst.ql b/rust/ql/src/queries/ide-contextual-queries/printAst.ql new file mode 100644 index 000000000000..2fd65ca49ab3 --- /dev/null +++ b/rust/ql/src/queries/ide-contextual-queries/printAst.ql @@ -0,0 +1,33 @@ +/** + * @name Print AST + * @description Outputs a representation of a file's Abstract Syntax Tree. This + * query is used by the VS Code extension. + * @id rust/print-ast + * @kind graph + * @tags ide-contextual-queries/print-ast + */ + +import rust +import codeql.rust.printast.PrintAst +import codeql.IDEContextual +import codeql.rust.generated.ParentChild + +/** + * Gets the source file to generate an AST from. + */ +external string selectedSourceFile(); + +class PrintAstConfigurationOverride extends PrintAstConfiguration { + /** + * Holds if the location matches the selected file in the VS Code extension and + * the element is `e`. + */ + override predicate shouldPrint(Locatable e) { + super.shouldPrint(e) and + ( + e.getFile() = getFileBySourceArchiveName(selectedSourceFile()) + or + exists(Locatable parent | this.shouldPrint(parent) and parent = getImmediateParent(e)) + ) + } +} diff --git a/rust/ql/test/.gitignore b/rust/ql/test/.gitignore new file mode 100644 index 000000000000..b4887cab780f --- /dev/null +++ b/rust/ql/test/.gitignore @@ -0,0 +1,3 @@ +Cargo.toml +Cargo.lock +target/ diff --git a/rust/ql/test/TestUtils.qll b/rust/ql/test/TestUtils.qll new file mode 100644 index 000000000000..317b71f2bdfc --- /dev/null +++ b/rust/ql/test/TestUtils.qll @@ -0,0 +1,13 @@ +private import codeql.rust.elements + +cached +predicate toBeTested(Element e) { + exists(File f | + f.getName().matches("%rust/ql/test%") and + ( + e = f + or + e.(Locatable).getLocation().getFile() = f + ) + ) +} diff --git a/rust/ql/test/extractor-tests/generated/.generated_tests.list b/rust/ql/test/extractor-tests/generated/.generated_tests.list new file mode 100644 index 000000000000..aca5873c8207 --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/.generated_tests.list @@ -0,0 +1 @@ +Function/gen_function.rs 4be46d4798cd32b51e449d1b6c4bc7461216a8a0e765b61abac21354401a7776 4be46d4798cd32b51e449d1b6c4bc7461216a8a0e765b61abac21354401a7776 diff --git a/rust/ql/test/extractor-tests/generated/.gitattributes b/rust/ql/test/extractor-tests/generated/.gitattributes new file mode 100644 index 000000000000..2ca6c1370538 --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/.gitattributes @@ -0,0 +1,3 @@ +/.generated_tests.list linguist-generated +/.gitattributes linguist-generated +/Function/gen_function.rs linguist-generated diff --git a/rust/ql/test/extractor-tests/generated/Expr/MISSING_SOURCE.txt b/rust/ql/test/extractor-tests/generated/Expr/MISSING_SOURCE.txt new file mode 100644 index 000000000000..9cb54ddd059e --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/Expr/MISSING_SOURCE.txt @@ -0,0 +1,4 @@ +// generated by codegen + +After a source file is added in this directory and codegen is run again, test queries +will appear and this file will be deleted diff --git a/rust/ql/test/extractor-tests/generated/File/File.expected b/rust/ql/test/extractor-tests/generated/File/File.expected new file mode 100644 index 000000000000..7d8a15282a8c --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/File/File.expected @@ -0,0 +1 @@ +| test.rs:0:0:0:0 | test.rs | DbFile | getName: | test.rs | diff --git a/rust/ql/test/extractor-tests/generated/File/File.ql b/rust/ql/test/extractor-tests/generated/File/File.ql new file mode 100644 index 000000000000..20550a0d1b51 --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/File/File.ql @@ -0,0 +1,10 @@ +// generated by codegen +import codeql.rust.elements +import TestUtils + +from File x, string getName +where + toBeTested(x) and + not x.isUnknown() and + getName = x.getName() +select x, x.getPrimaryQlClasses(), "getName:", getName diff --git a/rust/ql/test/extractor-tests/generated/File/test.rs b/rust/ql/test/extractor-tests/generated/File/test.rs new file mode 100644 index 000000000000..f328e4d9d04c --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/File/test.rs @@ -0,0 +1 @@ +fn main() {} diff --git a/rust/ql/test/extractor-tests/generated/Function/Function.expected b/rust/ql/test/extractor-tests/generated/Function/Function.expected new file mode 100644 index 000000000000..453a2db17934 --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/Function/Function.expected @@ -0,0 +1 @@ +| gen_function.rs:3:1:4:40 | foo | getName: | foo | getBody: | gen_function.rs:4:23:4:40 | BlockExpr | diff --git a/rust/ql/test/extractor-tests/generated/Function/Function.ql b/rust/ql/test/extractor-tests/generated/Function/Function.ql new file mode 100644 index 000000000000..1cff30407106 --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/Function/Function.ql @@ -0,0 +1,11 @@ +// generated by codegen +import codeql.rust.elements +import TestUtils + +from Function x, string getName, Expr getBody +where + toBeTested(x) and + not x.isUnknown() and + getName = x.getName() and + getBody = x.getBody() +select x, "getName:", getName, "getBody:", getBody diff --git a/rust/ql/test/extractor-tests/generated/Function/gen_function.rs b/rust/ql/test/extractor-tests/generated/Function/gen_function.rs new file mode 100644 index 000000000000..0df26fce0ee8 --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/Function/gen_function.rs @@ -0,0 +1,8 @@ +// generated by codegen + +// A function declaration. For example +fn foo(x: u32) -> u64 { (x + 1).into() } +// A function declaration within a trait might not have a body: +trait Trait { + fn bar(); +} diff --git a/rust/ql/test/extractor-tests/generated/Module/MISSING_SOURCE.txt b/rust/ql/test/extractor-tests/generated/Module/MISSING_SOURCE.txt new file mode 100644 index 000000000000..9cb54ddd059e --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/Module/MISSING_SOURCE.txt @@ -0,0 +1,4 @@ +// generated by codegen + +After a source file is added in this directory and codegen is run again, test queries +will appear and this file will be deleted diff --git a/rust/ql/test/extractor-tests/generated/Pat/MISSING_SOURCE.txt b/rust/ql/test/extractor-tests/generated/Pat/MISSING_SOURCE.txt new file mode 100644 index 000000000000..9cb54ddd059e --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/Pat/MISSING_SOURCE.txt @@ -0,0 +1,4 @@ +// generated by codegen + +After a source file is added in this directory and codegen is run again, test queries +will appear and this file will be deleted diff --git a/rust/ql/test/extractor-tests/generated/RecordFieldPat/MISSING_SOURCE.txt b/rust/ql/test/extractor-tests/generated/RecordFieldPat/MISSING_SOURCE.txt new file mode 100644 index 000000000000..9cb54ddd059e --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/RecordFieldPat/MISSING_SOURCE.txt @@ -0,0 +1,4 @@ +// generated by codegen + +After a source file is added in this directory and codegen is run again, test queries +will appear and this file will be deleted diff --git a/rust/ql/test/extractor-tests/generated/RecordLitField/MISSING_SOURCE.txt b/rust/ql/test/extractor-tests/generated/RecordLitField/MISSING_SOURCE.txt new file mode 100644 index 000000000000..9cb54ddd059e --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/RecordLitField/MISSING_SOURCE.txt @@ -0,0 +1,4 @@ +// generated by codegen + +After a source file is added in this directory and codegen is run again, test queries +will appear and this file will be deleted diff --git a/rust/ql/test/extractor-tests/generated/Stmt/MISSING_SOURCE.txt b/rust/ql/test/extractor-tests/generated/Stmt/MISSING_SOURCE.txt new file mode 100644 index 000000000000..9cb54ddd059e --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/Stmt/MISSING_SOURCE.txt @@ -0,0 +1,4 @@ +// generated by codegen + +After a source file is added in this directory and codegen is run again, test queries +will appear and this file will be deleted diff --git a/rust/ql/test/extractor-tests/generated/TypeRef/MISSING_SOURCE.txt b/rust/ql/test/extractor-tests/generated/TypeRef/MISSING_SOURCE.txt new file mode 100644 index 000000000000..9cb54ddd059e --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/TypeRef/MISSING_SOURCE.txt @@ -0,0 +1,4 @@ +// generated by codegen + +After a source file is added in this directory and codegen is run again, test queries +will appear and this file will be deleted diff --git a/rust/ql/test/library-tests/controlflow/Cfg.expected b/rust/ql/test/library-tests/controlflow/Cfg.expected new file mode 100644 index 000000000000..57cbfe8c0011 --- /dev/null +++ b/rust/ql/test/library-tests/controlflow/Cfg.expected @@ -0,0 +1,92 @@ +nodes +| test.rs:1:1:7:1 | enter main | semmle.order | 1 | +| test.rs:1:1:7:1 | exit main | semmle.order | 2 | +| test.rs:1:1:7:1 | exit main (normal) | semmle.order | 3 | +| test.rs:1:1:7:1 | main | semmle.order | 4 | +| test.rs:1:18:7:1 | BlockExpr | semmle.order | 5 | +| test.rs:2:5:6:5 | IfExpr | semmle.order | 6 | +| test.rs:2:8:2:12 | LiteralExpr | semmle.order | 7 | +| test.rs:2:8:2:21 | BinaryOpExpr | semmle.order | 8 | +| test.rs:2:17:2:21 | LiteralExpr | semmle.order | 9 | +| test.rs:2:23:4:5 | BlockExpr | semmle.order | 10 | +| test.rs:3:9:3:20 | CallExpr | semmle.order | 11 | +| test.rs:3:19:3:19 | LiteralExpr | semmle.order | 12 | +| test.rs:4:12:6:5 | BlockExpr | semmle.order | 13 | +| test.rs:5:9:5:20 | CallExpr | semmle.order | 14 | +| test.rs:5:19:5:19 | LiteralExpr | semmle.order | 15 | +| test.rs:9:1:16:1 | decrement | semmle.order | 16 | +| test.rs:9:1:16:1 | enter decrement | semmle.order | 17 | +| test.rs:9:1:16:1 | exit decrement | semmle.order | 18 | +| test.rs:9:1:16:1 | exit decrement (normal) | semmle.order | 19 | +| test.rs:9:29:16:1 | BlockExpr | semmle.order | 20 | +| test.rs:11:5:15:5 | IfExpr | semmle.order | 21 | +| test.rs:11:8:11:8 | PathExpr | semmle.order | 22 | +| test.rs:11:8:11:13 | BinaryOpExpr | semmle.order | 23 | +| test.rs:11:13:11:13 | LiteralExpr | semmle.order | 24 | +| test.rs:11:15:13:5 | BlockExpr | semmle.order | 25 | +| test.rs:12:9:12:9 | LiteralExpr | semmle.order | 26 | +| test.rs:13:12:15:5 | BlockExpr | semmle.order | 27 | +| test.rs:14:9:14:9 | PathExpr | semmle.order | 28 | +| test.rs:14:9:14:13 | BinaryOpExpr | semmle.order | 29 | +| test.rs:14:13:14:13 | LiteralExpr | semmle.order | 30 | +edges +| test.rs:1:1:7:1 | enter main | test.rs:2:8:2:12 | LiteralExpr | semmle.label | | +| test.rs:1:1:7:1 | enter main | test.rs:2:8:2:12 | LiteralExpr | semmle.order | 1 | +| test.rs:1:1:7:1 | exit main (normal) | test.rs:1:1:7:1 | exit main | semmle.label | | +| test.rs:1:1:7:1 | exit main (normal) | test.rs:1:1:7:1 | exit main | semmle.order | 1 | +| test.rs:1:1:7:1 | main | test.rs:1:1:7:1 | exit main (normal) | semmle.label | | +| test.rs:1:1:7:1 | main | test.rs:1:1:7:1 | exit main (normal) | semmle.order | 1 | +| test.rs:1:18:7:1 | BlockExpr | test.rs:1:1:7:1 | main | semmle.label | | +| test.rs:1:18:7:1 | BlockExpr | test.rs:1:1:7:1 | main | semmle.order | 1 | +| test.rs:2:5:6:5 | IfExpr | test.rs:1:18:7:1 | BlockExpr | semmle.label | | +| test.rs:2:5:6:5 | IfExpr | test.rs:1:18:7:1 | BlockExpr | semmle.order | 1 | +| test.rs:2:8:2:12 | LiteralExpr | test.rs:2:17:2:21 | LiteralExpr | semmle.label | | +| test.rs:2:8:2:12 | LiteralExpr | test.rs:2:17:2:21 | LiteralExpr | semmle.order | 1 | +| test.rs:2:8:2:21 | BinaryOpExpr | test.rs:3:19:3:19 | LiteralExpr | semmle.label | true | +| test.rs:2:8:2:21 | BinaryOpExpr | test.rs:3:19:3:19 | LiteralExpr | semmle.order | 1 | +| test.rs:2:8:2:21 | BinaryOpExpr | test.rs:5:19:5:19 | LiteralExpr | semmle.label | false | +| test.rs:2:8:2:21 | BinaryOpExpr | test.rs:5:19:5:19 | LiteralExpr | semmle.order | 2 | +| test.rs:2:17:2:21 | LiteralExpr | test.rs:2:8:2:21 | BinaryOpExpr | semmle.label | | +| test.rs:2:17:2:21 | LiteralExpr | test.rs:2:8:2:21 | BinaryOpExpr | semmle.order | 1 | +| test.rs:2:23:4:5 | BlockExpr | test.rs:2:5:6:5 | IfExpr | semmle.label | | +| test.rs:2:23:4:5 | BlockExpr | test.rs:2:5:6:5 | IfExpr | semmle.order | 1 | +| test.rs:3:9:3:20 | CallExpr | test.rs:2:23:4:5 | BlockExpr | semmle.label | | +| test.rs:3:9:3:20 | CallExpr | test.rs:2:23:4:5 | BlockExpr | semmle.order | 1 | +| test.rs:3:19:3:19 | LiteralExpr | test.rs:3:9:3:20 | CallExpr | semmle.label | | +| test.rs:3:19:3:19 | LiteralExpr | test.rs:3:9:3:20 | CallExpr | semmle.order | 1 | +| test.rs:4:12:6:5 | BlockExpr | test.rs:2:5:6:5 | IfExpr | semmle.label | | +| test.rs:4:12:6:5 | BlockExpr | test.rs:2:5:6:5 | IfExpr | semmle.order | 1 | +| test.rs:5:9:5:20 | CallExpr | test.rs:4:12:6:5 | BlockExpr | semmle.label | | +| test.rs:5:9:5:20 | CallExpr | test.rs:4:12:6:5 | BlockExpr | semmle.order | 1 | +| test.rs:5:19:5:19 | LiteralExpr | test.rs:5:9:5:20 | CallExpr | semmle.label | | +| test.rs:5:19:5:19 | LiteralExpr | test.rs:5:9:5:20 | CallExpr | semmle.order | 1 | +| test.rs:9:1:16:1 | decrement | test.rs:9:1:16:1 | exit decrement (normal) | semmle.label | | +| test.rs:9:1:16:1 | decrement | test.rs:9:1:16:1 | exit decrement (normal) | semmle.order | 1 | +| test.rs:9:1:16:1 | enter decrement | test.rs:11:8:11:8 | PathExpr | semmle.label | | +| test.rs:9:1:16:1 | enter decrement | test.rs:11:8:11:8 | PathExpr | semmle.order | 1 | +| test.rs:9:1:16:1 | exit decrement (normal) | test.rs:9:1:16:1 | exit decrement | semmle.label | | +| test.rs:9:1:16:1 | exit decrement (normal) | test.rs:9:1:16:1 | exit decrement | semmle.order | 1 | +| test.rs:9:29:16:1 | BlockExpr | test.rs:9:1:16:1 | decrement | semmle.label | | +| test.rs:9:29:16:1 | BlockExpr | test.rs:9:1:16:1 | decrement | semmle.order | 1 | +| test.rs:11:5:15:5 | IfExpr | test.rs:9:29:16:1 | BlockExpr | semmle.label | | +| test.rs:11:5:15:5 | IfExpr | test.rs:9:29:16:1 | BlockExpr | semmle.order | 1 | +| test.rs:11:8:11:8 | PathExpr | test.rs:11:13:11:13 | LiteralExpr | semmle.label | | +| test.rs:11:8:11:8 | PathExpr | test.rs:11:13:11:13 | LiteralExpr | semmle.order | 1 | +| test.rs:11:8:11:13 | BinaryOpExpr | test.rs:12:9:12:9 | LiteralExpr | semmle.label | true | +| test.rs:11:8:11:13 | BinaryOpExpr | test.rs:12:9:12:9 | LiteralExpr | semmle.order | 1 | +| test.rs:11:8:11:13 | BinaryOpExpr | test.rs:14:9:14:9 | PathExpr | semmle.label | false | +| test.rs:11:8:11:13 | BinaryOpExpr | test.rs:14:9:14:9 | PathExpr | semmle.order | 2 | +| test.rs:11:13:11:13 | LiteralExpr | test.rs:11:8:11:13 | BinaryOpExpr | semmle.label | | +| test.rs:11:13:11:13 | LiteralExpr | test.rs:11:8:11:13 | BinaryOpExpr | semmle.order | 1 | +| test.rs:11:15:13:5 | BlockExpr | test.rs:11:5:15:5 | IfExpr | semmle.label | | +| test.rs:11:15:13:5 | BlockExpr | test.rs:11:5:15:5 | IfExpr | semmle.order | 1 | +| test.rs:12:9:12:9 | LiteralExpr | test.rs:11:15:13:5 | BlockExpr | semmle.label | | +| test.rs:12:9:12:9 | LiteralExpr | test.rs:11:15:13:5 | BlockExpr | semmle.order | 1 | +| test.rs:13:12:15:5 | BlockExpr | test.rs:11:5:15:5 | IfExpr | semmle.label | | +| test.rs:13:12:15:5 | BlockExpr | test.rs:11:5:15:5 | IfExpr | semmle.order | 1 | +| test.rs:14:9:14:9 | PathExpr | test.rs:14:13:14:13 | LiteralExpr | semmle.label | | +| test.rs:14:9:14:9 | PathExpr | test.rs:14:13:14:13 | LiteralExpr | semmle.order | 1 | +| test.rs:14:9:14:13 | BinaryOpExpr | test.rs:13:12:15:5 | BlockExpr | semmle.label | | +| test.rs:14:9:14:13 | BinaryOpExpr | test.rs:13:12:15:5 | BlockExpr | semmle.order | 1 | +| test.rs:14:13:14:13 | LiteralExpr | test.rs:14:9:14:13 | BinaryOpExpr | semmle.label | | +| test.rs:14:13:14:13 | LiteralExpr | test.rs:14:9:14:13 | BinaryOpExpr | semmle.order | 1 | diff --git a/rust/ql/test/library-tests/controlflow/Cfg.ql b/rust/ql/test/library-tests/controlflow/Cfg.ql new file mode 100644 index 000000000000..7792c6c9cc1e --- /dev/null +++ b/rust/ql/test/library-tests/controlflow/Cfg.ql @@ -0,0 +1,15 @@ +/** + * @id rust/controlflow/cfg + */ + +import rust +import codeql.rust.controlflow.ControlFlowGraph +import TestUtils + +class MyRelevantNode extends CfgNode { + MyRelevantNode() { toBeTested(this.getScope()) } + + string getOrderDisambiguation() { result = "" } +} + +import codeql.rust.controlflow.internal.ControlFlowGraphImpl::TestOutput diff --git a/rust/ql/test/library-tests/controlflow/test.rs b/rust/ql/test/library-tests/controlflow/test.rs new file mode 100644 index 000000000000..f60a227c16c8 --- /dev/null +++ b/rust/ql/test/library-tests/controlflow/test.rs @@ -0,0 +1,16 @@ +fn main() -> i64 { + if "foo" == "bar" { + decrement(0) + } else { + decrement(5) + } +} + +fn decrement(n: i64) -> i64 { + 12; + if n == 0 { + 0 + } else { + n - 1 + } +} diff --git a/rust/ql/test/qlpack.lock.yml b/rust/ql/test/qlpack.lock.yml new file mode 100644 index 000000000000..06dd07fc7dc7 --- /dev/null +++ b/rust/ql/test/qlpack.lock.yml @@ -0,0 +1,4 @@ +--- +dependencies: {} +compiled: false +lockVersion: 1.0.0 diff --git a/rust/ql/test/qlpack.yml b/rust/ql/test/qlpack.yml new file mode 100644 index 000000000000..7428ca33bed7 --- /dev/null +++ b/rust/ql/test/qlpack.yml @@ -0,0 +1,8 @@ +name: codeql/rust-tests +groups: [rust, test] +dependencies: + codeql/rust-queries: ${workspace} + codeql/rust-all: ${workspace} +extractor: rust +tests: . +warnOnImplicitThis: true diff --git a/rust/schema.py b/rust/schema.py new file mode 100644 index 000000000000..1a5a19b2e0b8 --- /dev/null +++ b/rust/schema.py @@ -0,0 +1,610 @@ +""" +Schema description + +This file should be kept simple: +* no flow control +* no aliases +* only class definitions with annotations and `include` calls + +For how documentation of generated QL code works, please read `misc/codegen/schema_documentation.md`. +""" + +from misc.codegen.lib.schemadefs import * + +include("prefix.dbscheme") + + +@qltest.skip +class Element: + pass + + +@qltest.collapse_hierarchy +class File(Element): + name: string + + +@qltest.skip +@qltest.collapse_hierarchy +class Location(Element): + file: File + start_line: int + start_column: int + end_line: int + end_column: int + + +class DbFile(File): + pass + + +class DbLocation(Location): + pass + + +@synth.on_arguments() +class UnknownFile(File): + pass + + +@synth.on_arguments() +class UnknownLocation(Location): + pass + + +@qltest.skip +class Locatable(Element): + location: optional[Location] + + +@qltest.skip +class AstNode(Locatable): + pass + + +@qltest.skip +class Unimplemented(AstNode): + pass + + +class Declaration(AstNode): + pass + + +class Module(Declaration): + # TODO name + declarations: list[Declaration] | child + + +@qltest.collapse_hierarchy +class Expr(AstNode): + pass + + +@qltest.collapse_hierarchy +class Pat(AstNode): + pass + + +@qltest.skip +class Label(AstNode): + name: string + + +@qltest.collapse_hierarchy +class Stmt(AstNode): + pass + + +@qltest.collapse_hierarchy +class TypeRef(AstNode): + # TODO + pass + + +class Function(Declaration): + """ + A function declaration. For example + ``` + fn foo(x: u32) -> u64 { (x + 1).into() } + ``` + A function declaration within a trait might not have a body: + ``` + trait Trait { + fn bar(); + } + ``` + """ + name: string + body: Expr | child + + +# Missing, +class MissingExpr(Expr): + pass + + +# Path(Path), + + +class PathExpr(Expr): + path: Unimplemented | child + +# If { +# condition: ExprId, +# then_branch: ExprId, +# else_branch: Option, +# }, + + +class IfExpr(Expr): + condition: Expr | child + then: Expr | child + else_: optional[Expr] | child + +# Let { +# pat: PatId, +# expr: ExprId, +# }, + + +class LetExpr(Expr): + pat: Pat | child + expr: Expr | child + +# Block { +# id: Option, +# statements: Box<[Stmt]>, +# tail: Option, +# label: Option, +# }, + + +class BlockExprBase(Expr): + statements: list[Stmt] | child + tail: optional[Expr] | child + + +class BlockExpr(BlockExprBase): + label: optional[Label] | child + +# Async { +# id: Option, +# statements: Box<[Stmt]>, +# tail: Option, +# }, + + +class AsyncBlockExpr(BlockExprBase): + pass + +# Const(ConstBlockId), + + +class ConstExpr(Expr): + expr: Expr | child + +# // FIXME: Fold this into Block with an unsafe flag? +# Unsafe { +# id: Option, +# statements: Box<[Stmt]>, +# tail: Option, +# }, + + +class UnsafeBlockExpr(BlockExprBase): + pass + +# Loop { +# body: ExprId, +# label: Option, +# }, + + +class LoopExpr(Expr): + body: Expr | child + label: optional[Label] | child + +# Call { +# callee: ExprId, +# args: Box<[ExprId]>, +# is_assignee_expr: bool, +# }, + + +class CallExpr(Expr): + callee: Expr | child + args: list[Expr] | child + is_assignee_expr: predicate + +# MethodCall { +# receiver: ExprId, +# method_name: Name, +# args: Box<[ExprId]>, +# generic_args: Option>, +# }, + + +class MethodCallExpr(Expr): + receiver: Expr | child + method_name: string + args: list[Expr] | child + generic_args: optional[Unimplemented] | child + +# pub struct MatchArm { +# pub pat: PatId, +# pub guard: Option, +# pub expr: ExprId, +# } + + +@qltest.skip +class MatchArm(AstNode): + pat: Pat | child + guard: optional[Expr] | child + expr: Expr | child +# Match { +# expr: ExprId, +# arms: Box<[MatchArm]>, +# }, + + +class MatchExpr(Expr): + expr: Expr | child + branches: list[MatchArm] | child + +# Continue { +# label: Option, +# }, + + +class ContinueExpr(Expr): + label: optional[Label] | child + +# Break { +# expr: Option, +# label: Option, +# }, + + +class BreakExpr(Expr): + expr: optional[Expr] | child + label: optional[Label] | child + + +# Return { +# expr: Option, +# }, + +class ReturnExpr(Expr): + expr: optional[Expr] | child +# Become { +# expr: ExprId, +# }, + + +class BecomeExpr(Expr): + expr: Expr | child +# Yield { +# expr: Option, +# }, + + +class YieldExpr(Expr): + expr: optional[Expr] | child + +# Yeet { +# expr: Option, +# }, + + +class YeetExpr(Expr): + expr: optional[Expr] | child +# RecordLit { +# path: Option>, +# fields: Box<[RecordLitField]>, +# spread: Option, +# ellipsis: bool, +# is_assignee_expr: bool, +# }, + + +class RecordFieldPat(AstNode): + name: string + pat: Pat | child + + +class RecordLitField(AstNode): + name: string + expr: Expr | child + + +class RecordLitExpr(Expr): + path: optional[Unimplemented] | child + fields: list[RecordLitField] | child + spread: optional[Expr] | child + has_ellipsis: predicate + is_assignee_expr: predicate + + +# Field { +# expr: ExprId, +# name: Name, +# }, + +class FieldExpr(Expr): + expr: Expr | child + name: string + +# Await { +# expr: ExprId, +# }, + + +class AwaitExpr(Expr): + expr: Expr | child + +# Cast { +# expr: ExprId, +# type_ref: Interned, +# }, + + +class CastExpr(Expr): + expr: Expr | child + type_ref: TypeRef | child +# Ref { +# expr: ExprId, +# rawness: Rawness, +# mutability: Mutability, +# }, + + +class RefExpr(Expr): + expr: Expr | child + is_raw: predicate + is_mut: predicate +# Box { +# expr: ExprId, +# }, + + +class BoxExpr(Expr): + expr: Expr | child +# UnaryOp { +# expr: ExprId, +# op: UnaryOp, +# }, + + +class UnaryOpExpr(Expr): + expr: Expr | child + op: string + + +# BinaryOp { +# lhs: ExprId, +# rhs: ExprId, +# op: Option, +# }, + + +class BinaryOpExpr(Expr): + lhs: Expr | child + rhs: Expr | child + op: optional[string] + + +# Range { +# lhs: Option, +# rhs: Option, +# range_type: RangeOp, +# }, + + +class RangeExpr(Expr): + lhs: optional[Expr] | child + rhs: optional[Expr] | child + is_inclusive: predicate + +# Index { +# base: ExprId, +# index: ExprId, +# is_assignee_expr: bool, +# }, + + +class IndexExpr(Expr): + base: Expr | child + index: Expr | child + is_assignee_expr: predicate + +# Closure { +# args: Box<[PatId]>, +# arg_types: Box<[Option>]>, +# ret_type: Option>, +# body: ExprId, +# closure_kind: ClosureKind, +# capture_by: CaptureBy, +# }, + + +class ClosureExpr(Expr): + args: list[Pat] | child + arg_types: list[optional[TypeRef]] | child + ret_type: optional[TypeRef] | child + body: Expr | child + closure_kind: string + is_move: predicate +# Tuple { +# exprs: Box<[ExprId]>, +# is_assignee_expr: bool, +# }, + + +class TupleExpr(Expr): + exprs: list[Expr] | child + is_assignee_expr: predicate + +# Array(Array), + + +class ArrayExpr(Expr): + pass +# Literal(Literal), + +# ElementList { elements: Box<[ExprId]>, is_assignee_expr: bool }, + + +class ElementListExpr(ArrayExpr): + elements: list[Expr] | child + is_assignee_expr: predicate + +# Repeat { initializer: ExprId, repeat: ExprId }, + + +class RepeatExpr(ArrayExpr): + initializer: Expr | child + repeat: Expr | child + + +class LiteralExpr(Expr): + pass +# Underscore, + + +class UnderscoreExpr(Expr): + pass +# OffsetOf(OffsetOf), + + +class OffsetOfExpr(Expr): + container: TypeRef | child + fields: list[string] + +# InlineAsm(InlineAsm), + + +class InlineAsmExpr(Expr): + expr: Expr | child + + +# Let { +# pat: PatId, +# type_ref: Option>, +# initializer: Option, +# else_branch: Option, +# }, + +class LetStmt(Stmt): + pat: Pat | child + type_ref: optional[TypeRef] | child + initializer: optional[Expr] | child + else_: optional[Expr] | child +# Expr { +# expr: ExprId, +# has_semi: bool, +# }, + + +class ExprStmt(Stmt): + expr: Expr | child + has_semicolon: predicate + +# // At the moment, we only use this to figure out if a return expression +# // is really the last statement of a block. See #16566 +# Item, + + +class ItemStmt(Stmt): + pass + + # Missing, + + +class MissingPat(Pat): + pass + # Wild, + + +class WildPat(Pat): + pass + # Tuple { args: Box<[PatId]>, ellipsis: Option }, + + +class TuplePat(Pat): + args: list[Pat] | child + ellipsis_index: optional[int] + + # Or(Box<[PatId]>), + + +class OrPat(Pat): + args: list[Pat] | child + + +# Record { path: Option>, args: Box<[RecordFieldPat]>, ellipsis: bool }, + + +class RecordPat(Pat): + path: optional[Unimplemented] | child + args: list[RecordFieldPat] | child + has_ellipsis: predicate + + # Range { start: Option>, end: Option> }, + + +class RangePat(Pat): + start: optional[Pat] | child + end: optional[Pat] | child + # Slice { prefix: Box<[PatId]>, slice: Option, suffix: Box<[PatId]> }, + + +class SlicePat(Pat): + prefix: list[Pat] | child + slice: optional[Pat] | child + suffix: list[Pat] | child + # Path(Box), + + +class PathPat(Pat): + path: Unimplemented | child + + # Lit(ExprId), + + +class LitPat(Pat): + expr: Expr | child + + # Bind { id: BindingId, subpat: Option }, + + +class BindPat(Pat): + binding_id: string + subpat: optional[Pat] | child + + # TupleStruct { path: Option>, args: Box<[PatId]>, ellipsis: Option }, + + +class TupleStructPat(Pat): + path: optional[Unimplemented] | child + args: list[Pat] | child + ellipsis_index: optional[int] + + # Ref { pat: PatId, mutability: Mutability }, + + +class RefPat(Pat): + pat: Pat | child + is_mut: predicate + + # Box { inner: PatId }, + + +class BoxPat(Pat): + inner: Pat | child + # ConstBlock(ExprId), + + +class ConstBlockPat(Pat): + expr: Expr | child diff --git a/rust/tools/BUILD.bazel b/rust/tools/BUILD.bazel new file mode 100644 index 000000000000..a61ab84edbf1 --- /dev/null +++ b/rust/tools/BUILD.bazel @@ -0,0 +1,7 @@ +load("//misc/bazel:pkg.bzl", "codeql_pkg_files") + +codeql_pkg_files( + name = "tools", + exes = glob(["*.sh"]), + visibility = ["//rust:__pkg__"], +) diff --git a/rust/tools/autobuild.sh b/rust/tools/autobuild.sh new file mode 100755 index 000000000000..b35a17298585 --- /dev/null +++ b/rust/tools/autobuild.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +exec "${CODEQL_DIST}/codeql" database index-files \ + --working-dir=. --language=rust --include-extension=.rs \ + ${CODEQL_VERBOSITY:+"--verbosity=${CODEQL_VERBOSITY}"} \ + "${CODEQL_EXTRACTOR_RUST_WIP_DATABASE}" diff --git a/rust/tools/index-files.sh b/rust/tools/index-files.sh new file mode 100755 index 000000000000..da4b841b692f --- /dev/null +++ b/rust/tools/index-files.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +set -eu + +exec "$CODEQL_EXTRACTOR_RUST_ROOT/tools/$CODEQL_PLATFORM/extractor" --inputs-file="$1" diff --git a/rust/tools/qltest.sh b/rust/tools/qltest.sh new file mode 100755 index 000000000000..61ca0ea5bbc6 --- /dev/null +++ b/rust/tools/qltest.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +mkdir -p "$CODEQL_EXTRACTOR_RUST_TRAP_DIR" + +export RUST_BACKTRACE=full + +QLTEST_LOG="$CODEQL_EXTRACTOR_RUST_LOG_DIR"/qltest.log + +EXTRACTOR="$CODEQL_EXTRACTOR_RUST_ROOT/tools/$CODEQL_PLATFORM/extractor" +for src in *.rs; do + echo -e "[workspace]\n\n[package]\nname = \"test\"\nversion=\"0.0.1\"\n[lib]\npath=\"$src\"\n" > Cargo.toml + env=() + opts=("$src") + opts+=($(sed -n '1 s=//codeql-extractor-options:==p' $src)) + expected_status=$(sed -n 's=//codeql-extractor-expected-status:[[:space:]]*==p' $src) + expected_status=${expected_status:-0} + env+=($(sed -n '1 s=//codeql-extractor-env:==p' $src)) + echo >> $QLTEST_LOG + echo "env ${env[@]} $EXTRACTOR ${opts[@]}" >> "$QLTEST_LOG" + env "${env[@]}" "$EXTRACTOR" "${opts[@]}" >> $QLTEST_LOG 2>&1 + actual_status=$? + if [[ $actual_status != $expected_status ]]; then + FAILED=1 + fi +done + +rm -rf Cargo.* + +if [ -n "$FAILED" ]; then + cat "$QLTEST_LOG" # Show compiler errors on extraction failure + exit 1 +fi diff --git a/shared/tree-sitter-extractor/BUILD.bazel b/shared/tree-sitter-extractor/BUILD.bazel index e57a9f47ca13..dc9001a32d25 100644 --- a/shared/tree-sitter-extractor/BUILD.bazel +++ b/shared/tree-sitter-extractor/BUILD.bazel @@ -1,5 +1,5 @@ -load("@ruby_deps//:defs.bzl", "aliases", "all_crate_deps") load("@rules_rust//rust:defs.bzl", "rust_library") +load("@tree_sitter_extractors_deps//:defs.bzl", "aliases", "all_crate_deps") package(default_visibility = ["//visibility:public"]) @@ -12,5 +12,5 @@ rust_library( compile_data = [ "src/generator/prefix.dbscheme", ], - deps = all_crate_deps(package_name = "ruby/extractor/codeql-extractor-fake-crate"), + deps = all_crate_deps(), ) diff --git a/shared/tree-sitter-extractor/src/trap.rs b/shared/tree-sitter-extractor/src/trap.rs index 32b33d340c55..4c061f8dbd82 100644 --- a/shared/tree-sitter-extractor/src/trap.rs +++ b/shared/tree-sitter-extractor/src/trap.rs @@ -137,10 +137,16 @@ impl fmt::Display for Entry { } } -#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Copy, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)] // Identifiers of the form #0, #1... pub struct Label(u32); +impl fmt::Debug for Label { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> fmt::Result { + write!(f, "Label({:#x})", self.0) + } +} + impl fmt::Display for Label { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "#{:x}", self.0) @@ -171,6 +177,30 @@ impl fmt::Display for Arg { } } +impl From for Arg { + fn from(value: String) -> Self { + Arg::String(value) + } +} + +impl From<&str> for Arg { + fn from(value: &str) -> Self { + Arg::String(value.into()) + } +} + +impl From