From 1dcd60527c7be4c7cff47a8d14e5b2a0bc1466cf Mon Sep 17 00:00:00 2001 From: Paolo Tranquilli Date: Tue, 24 Jun 2025 17:26:24 +0200 Subject: [PATCH] Codegen: improve implementation of generated parent/child relationship This improves the implementation of the generated parent/child relationship by adding a new `all_children` field to `ql.Class` which lists all children (both direct and inherited) of a class, carefully avoiding duplicating children in case of diamond inheritance. This: * simplifies the generated code, * avoid children ambiguities in case of diamond inheritance. This only comes with some changes in the order of children in the generated tests (we were previously sorting bases alphabetically there). For the rest this should be a non-functional change. --- misc/codegen/generators/qlgen.py | 367 +- misc/codegen/generators/rusttestgen.py | 7 +- misc/codegen/lib/ql.py | 15 +- misc/codegen/templates/ql_parent.mustache | 78 +- misc/codegen/test/test_ql.py | 22 +- misc/codegen/test/test_qlgen.py | 222 +- rust/ql/.generated.list | 4 +- .../internal/generated/ParentChild.qll | 2251 +++------- .../generated/Function/Cargo.lock | 7 + .../generated/Function/Function.expected | 4 +- .../generated/Function/Function.ql | 30 +- swift/ql/.generated.list | 8 +- .../codeql/swift/generated/ParentChild.qll | 3831 ++++------------- .../generated/decl/Accessor/Accessor.expected | 72 +- .../generated/decl/Accessor/Accessor.ql | 30 +- .../decl/ExtensionDecl/ExtensionDecl.expected | 8 +- .../decl/ExtensionDecl/ExtensionDecl.ql | 10 +- .../decl/NamedFunction/NamedFunction.expected | 10 +- .../decl/NamedFunction/NamedFunction.ql | 24 +- 19 files changed, 1941 insertions(+), 5059 deletions(-) create mode 100644 rust/ql/test/extractor-tests/generated/Function/Cargo.lock diff --git a/misc/codegen/generators/qlgen.py b/misc/codegen/generators/qlgen.py index 991c21990d46..3bf51a4b7df6 100755 --- a/misc/codegen/generators/qlgen.py +++ b/misc/codegen/generators/qlgen.py @@ -30,6 +30,7 @@ import typing import itertools import os +import dataclasses import inflection @@ -113,117 +114,201 @@ def _get_doc(cls: schema.Class, prop: schema.Property, plural=None): return f"{prop_name} of this {class_name}" -def _type_is_hideable(t: str, lookup: typing.Dict[str, schema.ClassBase]) -> bool: - if t in lookup: - match lookup[t]: +@dataclasses.dataclass +class Resolver: + lookup: typing.Dict[str, schema.ClassBase] + _property_cache: typing.Dict[tuple[int, int], ql.Property] = dataclasses.field( + default_factory=dict, init=False + ) + _class_cache: typing.Dict[int, ql.Class] = dataclasses.field( + default_factory=dict, init=False + ) + + def _type_is_hideable(self, t: str) -> bool: + match self.lookup.get(t): case schema.Class() as cls: return "ql_hideable" in cls.pragmas - return False - - -def get_ql_property( - cls: schema.Class, - prop: schema.Property, - lookup: typing.Dict[str, schema.ClassBase], - prev_child: str = "", -) -> ql.Property: - - args = dict( - type=prop.type if not prop.is_predicate else "predicate", - qltest_skip="qltest_skip" in prop.pragmas, - prev_child=prev_child if prop.is_child else None, - is_optional=prop.is_optional, - is_predicate=prop.is_predicate, - is_unordered=prop.is_unordered, - description=prop.description, - synth=bool(cls.synth) or prop.synth, - type_is_hideable=_type_is_hideable(prop.type, lookup), - type_is_codegen_class=prop.type in lookup and not lookup[prop.type].imported, - internal="ql_internal" in prop.pragmas, - ) - ql_name = prop.pragmas.get("ql_name", prop.name) - db_table_name = prop.pragmas.get("ql_db_table_name") - if db_table_name and prop.is_single: - raise Error( - f"`db_table_name` pragma is not supported for single properties, but {cls.name}.{prop.name} has it" - ) - if prop.is_single: - args.update( - singular=inflection.camelize(ql_name), - tablename=inflection.tableize(cls.name), - tableparams=["this"] - + ["result" if p is prop else "_" for p in cls.properties if p.is_single], - doc=_get_doc(cls, prop), - ) - elif prop.is_repeated: - args.update( - singular=inflection.singularize(inflection.camelize(ql_name)), - plural=inflection.pluralize(inflection.camelize(ql_name)), - tablename=db_table_name or inflection.tableize(f"{cls.name}_{prop.name}"), - tableparams=( - ["this", "index", "result"] - if not prop.is_unordered - else ["this", "result"] - ), - doc=_get_doc(cls, prop, plural=False), - doc_plural=_get_doc(cls, prop, plural=True), - ) - elif prop.is_optional: - args.update( - singular=inflection.camelize(ql_name), - tablename=db_table_name or inflection.tableize(f"{cls.name}_{prop.name}"), - tableparams=["this", "result"], - doc=_get_doc(cls, prop), - ) - elif prop.is_predicate: - args.update( - singular=inflection.camelize(ql_name, uppercase_first_letter=False), - tablename=db_table_name or inflection.underscore(f"{cls.name}_{prop.name}"), - tableparams=["this"], - doc=_get_doc(cls, prop), - ) - else: - raise ValueError(f"unknown property kind for {prop.name} from {cls.name}") - return ql.Property(**args) + case _: + return False + + def get_ql_property( + self, + cls: schema.Class, + prop: schema.Property, + ) -> ql.Property: + cache_key = (id(cls), id(prop)) + if cache_key not in self._property_cache: + args = dict( + type=prop.type if not prop.is_predicate else "predicate", + qltest_skip="qltest_skip" in prop.pragmas, + is_optional=prop.is_optional, + is_predicate=prop.is_predicate, + is_unordered=prop.is_unordered, + description=prop.description, + synth=bool(cls.synth) or prop.synth, + type_is_hideable=self._type_is_hideable(prop.type), + type_is_codegen_class=prop.type in self.lookup + and not self.lookup[prop.type].imported, + internal="ql_internal" in prop.pragmas, + cfg=prop.is_child + and prop.type in self.lookup + and self.lookup[prop.type].cfg, + is_child=prop.is_child, + ) + ql_name = prop.pragmas.get("ql_name", prop.name) + db_table_name = prop.pragmas.get("ql_db_table_name") + if db_table_name and prop.is_single: + raise Error( + f"`db_table_name` pragma is not supported for single properties, but {cls.name}.{prop.name} has it" + ) + if prop.is_single: + args.update( + singular=inflection.camelize(ql_name), + tablename=inflection.tableize(cls.name), + tableparams=["this"] + + [ + "result" if p is prop else "_" + for p in cls.properties + if p.is_single + ], + doc=_get_doc(cls, prop), + ) + elif prop.is_repeated: + args.update( + singular=inflection.singularize(inflection.camelize(ql_name)), + plural=inflection.pluralize(inflection.camelize(ql_name)), + tablename=db_table_name + or inflection.tableize(f"{cls.name}_{prop.name}"), + tableparams=( + ["this", "index", "result"] + if not prop.is_unordered + else ["this", "result"] + ), + doc=_get_doc(cls, prop, plural=False), + doc_plural=_get_doc(cls, prop, plural=True), + ) + elif prop.is_optional: + args.update( + singular=inflection.camelize(ql_name), + tablename=db_table_name + or inflection.tableize(f"{cls.name}_{prop.name}"), + tableparams=["this", "result"], + doc=_get_doc(cls, prop), + ) + elif prop.is_predicate: + args.update( + singular=inflection.camelize(ql_name, uppercase_first_letter=False), + tablename=db_table_name + or inflection.underscore(f"{cls.name}_{prop.name}"), + tableparams=["this"], + doc=_get_doc(cls, prop), + ) + else: + raise ValueError( + f"unknown property kind for {prop.name} from {cls.name}" + ) + self._property_cache[cache_key] = ql.Property(**args) + return self._property_cache[cache_key] + + def get_ql_class(self, cls: schema.Class) -> ql.Class: + cache_key = id(cls) + if cache_key not in self._class_cache: + if "ql_name" in cls.pragmas: + raise Error( + "ql_name is not supported yet for classes, only for properties" + ) + properties = [self.get_ql_property(cls, p) for p in cls.properties] + all_children = [ + ql.Child(self.get_ql_property(c, p)) + for c, p in self._get_all_properties(cls) + if p.is_child + ] + for prev, child in zip([""] + all_children, all_children): + child.prev = prev and prev.property.singular + self._class_cache[cache_key] = ql.Class( + name=cls.name, + bases=cls.bases, + bases_impl=[base + "Impl::" + base for base in cls.bases], + final=not cls.derived, + properties=properties, + all_children=all_children, + dir=pathlib.Path(cls.group or ""), + doc=cls.doc, + hideable="ql_hideable" in cls.pragmas, + internal="ql_internal" in cls.pragmas, + cfg=cls.cfg, + ) + return self._class_cache[cache_key] + def get_ql_cfg_class( + self, + cls: schema.Class, + ) -> ql.CfgClass: + return ql.CfgClass( + name=cls.name, + bases=[base for base in cls.bases if self.lookup[base.base].cfg], + properties=cls.properties, + doc=cls.doc, + ) -def get_ql_class( - cls: schema.Class, lookup: typing.Dict[str, schema.ClassBase] -) -> ql.Class: - if "ql_name" in cls.pragmas: - raise Error("ql_name is not supported yet for classes, only for properties") - prev_child = "" - properties = [] - for p in cls.properties: - prop = get_ql_property(cls, p, lookup, prev_child) - if prop.is_child: - prev_child = prop.singular - if prop.type in lookup and lookup[prop.type].cfg: - prop.cfg = True - properties.append(prop) - return ql.Class( - name=cls.name, - bases=cls.bases, - bases_impl=[base + "Impl::" + base for base in cls.bases], - final=not cls.derived, - properties=properties, - dir=pathlib.Path(cls.group or ""), - doc=cls.doc, - hideable="ql_hideable" in cls.pragmas, - internal="ql_internal" in cls.pragmas, - cfg=cls.cfg, - ) + def _get_all_properties( + self, + cls: schema.Class, + already_seen: typing.Optional[typing.Set[int]] = None, + ) -> typing.Iterable[typing.Tuple[schema.Class, schema.Property]]: + # deduplicate using ids + if already_seen is None: + already_seen = set() + for b in cls.bases: + base = self.lookup[b] + for item in self._get_all_properties(base, already_seen): + yield item + for p in cls.properties: + if id(p) not in already_seen: + already_seen.add(id(p)) + yield cls, p + + def get_all_properties_to_be_tested( + self, + cls: schema.Class, + ) -> typing.Iterable[ql.PropertyForTest]: + for c, p in self._get_all_properties(cls): + if not ("qltest_skip" in c.pragmas or "qltest_skip" in p.pragmas): + p = self.get_ql_property(c, p) + yield ql.PropertyForTest( + p.getter, + is_total=p.is_single or p.is_predicate, + type=p.type if not p.is_predicate else None, + is_indexed=p.is_indexed, + ) + if p.is_repeated and not p.is_optional: + yield ql.PropertyForTest(f"getNumberOf{p.plural}", type="int") + elif p.is_optional and not p.is_repeated: + yield ql.PropertyForTest(f"has{p.singular}") + + def _is_in_qltest_collapsed_hierarchy( + self, + cls: schema.Class, + ) -> bool: + return ( + "qltest_collapse_hierarchy" in cls.pragmas + or self._is_under_qltest_collapsed_hierarchy(cls) + ) + def _is_under_qltest_collapsed_hierarchy( + self, + cls: schema.Class, + ) -> bool: + return "qltest_uncollapse_hierarchy" not in cls.pragmas and any( + self._is_in_qltest_collapsed_hierarchy(self.lookup[b]) for b in cls.bases + ) -def get_ql_cfg_class( - cls: schema.Class, lookup: typing.Dict[str, ql.Class] -) -> ql.CfgClass: - return ql.CfgClass( - name=cls.name, - bases=[base for base in cls.bases if lookup[base.base].cfg], - properties=cls.properties, - doc=cls.doc, - ) + def should_skip_qltest(self, cls: schema.Class) -> bool: + return ( + "qltest_skip" in cls.pragmas + or not (cls.final or "qltest_collapse_hierarchy" in cls.pragmas) + or self._is_under_qltest_collapsed_hierarchy(cls) + ) def _to_db_type(x: str) -> str: @@ -330,43 +415,6 @@ def _get_path_public(cls: schema.Class) -> pathlib.Path: ).with_suffix(".qll") -def _get_all_properties( - cls: schema.Class, - lookup: typing.Dict[str, schema.Class], - already_seen: typing.Optional[typing.Set[int]] = None, -) -> typing.Iterable[typing.Tuple[schema.Class, schema.Property]]: - # deduplicate using ids - if already_seen is None: - already_seen = set() - for b in sorted(cls.bases): - base = lookup[b] - for item in _get_all_properties(base, lookup, already_seen): - yield item - for p in cls.properties: - if id(p) not in already_seen: - already_seen.add(id(p)) - yield cls, p - - -def _get_all_properties_to_be_tested( - cls: schema.Class, lookup: typing.Dict[str, schema.Class] -) -> typing.Iterable[ql.PropertyForTest]: - for c, p in _get_all_properties(cls, lookup): - if not ("qltest_skip" in c.pragmas or "qltest_skip" in p.pragmas): - # TODO here operations are duplicated, but should be better if we split ql and qltest generation - p = get_ql_property(c, p, lookup) - yield ql.PropertyForTest( - p.getter, - is_total=p.is_single or p.is_predicate, - type=p.type if not p.is_predicate else None, - is_indexed=p.is_indexed, - ) - if p.is_repeated and not p.is_optional: - yield ql.PropertyForTest(f"getNumberOf{p.plural}", type="int") - elif p.is_optional and not p.is_repeated: - yield ql.PropertyForTest(f"has{p.singular}") - - def _partition_iter(x, pred): x1, x2 = itertools.tee(x) return filter(pred, x1), itertools.filterfalse(pred, x2) @@ -377,31 +425,6 @@ def _partition(l, pred): return map(list, _partition_iter(l, pred)) -def _is_in_qltest_collapsed_hierarchy( - cls: schema.Class, lookup: typing.Dict[str, schema.Class] -): - return ( - "qltest_collapse_hierarchy" in cls.pragmas - or _is_under_qltest_collapsed_hierarchy(cls, lookup) - ) - - -def _is_under_qltest_collapsed_hierarchy( - cls: schema.Class, lookup: typing.Dict[str, schema.Class] -): - return "qltest_uncollapse_hierarchy" not in cls.pragmas and any( - _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]): - 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) - ) - - def _get_stub( cls: schema.Class, base_import: str, generated_import_prefix: str ) -> ql.Stub: @@ -487,8 +510,10 @@ def generate(opts, renderer): data = schemaloader.load_file(input) + resolver = Resolver(data.classes) + classes = { - name: get_ql_class(cls, data.classes) + name: resolver.get_ql_class(cls) for name, cls in data.classes.items() if not cls.imported } @@ -538,7 +563,7 @@ def generate(opts, renderer): ) imports_impl[c.name + "Impl"] = path_impl + "Impl" if c.cfg: - cfg_classes.append(get_ql_cfg_class(c, classes)) + cfg_classes.append(resolver.get_ql_cfg_class(c)) for c in classes.values(): qll = out / c.path.with_suffix(".qll") @@ -609,7 +634,7 @@ def generate(opts, renderer): for c in data.classes.values(): if c.imported: continue - if should_skip_qltest(c, data.classes): + if resolver.should_skip_qltest(c): continue test_with_name = c.pragmas.get("qltest_test_with") test_with = data.classes[test_with_name] if test_with_name else c @@ -626,7 +651,7 @@ def generate(opts, renderer): ) continue total_props, partial_props = _partition( - _get_all_properties_to_be_tested(c, data.classes), + resolver.get_all_properties_to_be_tested(c), lambda p: p.is_total, ) renderer.render( diff --git a/misc/codegen/generators/rusttestgen.py b/misc/codegen/generators/rusttestgen.py index a46d2584127b..4c6e2cb61174 100644 --- a/misc/codegen/generators/rusttestgen.py +++ b/misc/codegen/generators/rusttestgen.py @@ -59,13 +59,12 @@ def generate(opts, renderer): registry=opts.ql_test_output / ".generated_tests.list", force=opts.force, ) as renderer: + + resolver = qlgen.Resolver(schema.classes) for cls in schema.classes.values(): if cls.imported: continue - if ( - qlgen.should_skip_qltest(cls, schema.classes) - or "rust_skip_doc_test" in cls.pragmas - ): + if resolver.should_skip_qltest(cls) or "rust_skip_doc_test" in cls.pragmas: continue code = _get_code(cls.doc) for p in schema.iter_properties(cls.name): diff --git a/misc/codegen/lib/ql.py b/misc/codegen/lib/ql.py index 7537aac995c5..0dfb99d1ed8b 100644 --- a/misc/codegen/lib/ql.py +++ b/misc/codegen/lib/ql.py @@ -37,7 +37,6 @@ class Property: is_optional: bool = False is_predicate: bool = False is_unordered: bool = False - prev_child: Optional[str] = None qltest_skip: bool = False description: List[str] = field(default_factory=list) doc: Optional[str] = None @@ -48,6 +47,7 @@ class Property: type_is_self: bool = False internal: bool = False cfg: bool = False + is_child: bool = False def __post_init__(self): if self.tableparams: @@ -76,10 +76,6 @@ def is_repeated(self): def is_single(self): return not (self.is_optional or self.is_repeated or self.is_predicate) - @property - def is_child(self): - return self.prev_child is not None - @property def is_indexed(self) -> bool: return self.is_repeated and not self.is_unordered @@ -89,6 +85,12 @@ def type_alias(self) -> Optional[str]: return self.type + "Alias" if self.type_is_self else self.type +@dataclass +class Child: + property: Property + prev: str = "" + + @dataclass class Base: base: str @@ -107,6 +109,7 @@ class Class: bases_impl: List[Base] = field(default_factory=list) final: bool = False properties: List[Property] = field(default_factory=list) + all_children: List[Child] = field(default_factory=list) dir: pathlib.Path = pathlib.Path() imports: List[str] = field(default_factory=list) import_prefix: Optional[str] = None @@ -148,7 +151,7 @@ def db_id(self) -> str: @property def has_children(self) -> bool: - return any(p.is_child for p in self.properties) + return bool(self.all_children) @property def last_base(self) -> str: diff --git a/misc/codegen/templates/ql_parent.mustache b/misc/codegen/templates/ql_parent.mustache index 67b975183736..84bc0d79a0b7 100644 --- a/misc/codegen/templates/ql_parent.mustache +++ b/misc/codegen/templates/ql_parent.mustache @@ -9,51 +9,39 @@ import {{.}} private module Impl { {{#classes}} - private Element getImmediateChildOf{{name}}({{name}} e, int index, string partialPredicateCall) { - {{! avoid unused argument warnings on root element, assuming the root element has no children }} - {{#root}}none(){{/root}} - {{^root}} - {{! b is the base offset 0, for ease of generation }} - {{! b is constructed to be strictly greater than the indexes required for children coming from }} - {{! n is the base offset for direct children, equal to the last base offset from above }} - {{! n is constructed to be strictly greater than the indexes for children }} - exists(int b{{#bases}}, int b{{.}}{{/bases}}, int n{{#properties}}{{#is_child}}, int n{{singular}}{{/is_child}}{{/properties}} | - b = 0 - {{#bases}} - and - b{{.}} = b{{prev}} + 1 + max(int i | i = -1 or exists(getImmediateChildOf{{.}}(e, i, _)) | i) - {{/bases}} - and - n = b{{last_base}} - {{#properties}} - {{#is_child}} - {{! n is defined on top of the previous definition }} - {{! for single and optional properties it adds 1 (regardless of whether the optional property exists) }} - {{! for repeated it adds 1 + the maximum index (which works for repeated optional as well) }} - and - n{{singular}} = n{{prev_child}} + 1{{#is_repeated}}+ max(int i | i = -1 or exists(e.get{{#type_is_hideable}}Immediate{{/type_is_hideable}}{{singular}}(i)) | i){{/is_repeated}} - {{/is_child}} - {{/properties}} and ( - none() - {{#bases}} - or - result = getImmediateChildOf{{.}}(e, index - b{{prev}}, partialPredicateCall) - {{/bases}} - {{#properties}} - {{#is_child}} - or - {{#is_repeated}} - result = e.get{{#type_is_hideable}}Immediate{{/type_is_hideable}}{{singular}}(index - n{{prev_child}}) and partialPredicateCall = "{{singular}}(" + (index - n{{prev_child}}).toString() + ")" - {{/is_repeated}} - {{^is_repeated}} - index = n{{prev_child}} and result = e.get{{#type_is_hideable}}Immediate{{/type_is_hideable}}{{singular}}() and partialPredicateCall = "{{singular}}()" - {{/is_repeated}} - {{/is_child}} - {{/properties}} - )) - {{/root}} - } - + {{#final}} + private Element getImmediateChildOf{{name}}({{name}} e, int index, string partialPredicateCall) { + {{^has_children}}none(){{/has_children}} + {{#has_children}} + {{! n is the base offset 0, for ease of generation }} + {{! n is constructed to be strictly greater than the indexes for children }} + exists(int n{{#all_children}}, int n{{property.singular}}{{/all_children}} | + n = 0 + {{#all_children}} + {{#property}} + {{! n is defined on top of the previous definition }} + {{! for single and optional properties it adds 1 (regardless of whether the optional property exists) }} + {{! for repeated it adds 1 + the maximum index (which works for repeated optional as well) }} + and + n{{singular}} = n{{prev}} + 1{{#is_repeated}}+ max(int i | i = -1 or exists(e.get{{#type_is_hideable}}Immediate{{/type_is_hideable}}{{singular}}(i)) | i){{/is_repeated}} + {{/property}} + {{/all_children}} and ( + none() + {{#all_children}} + {{#property}} + or + {{#is_repeated}} + result = e.get{{#type_is_hideable}}Immediate{{/type_is_hideable}}{{singular}}(index - n{{prev}}) and partialPredicateCall = "{{singular}}(" + (index - n{{prev}}).toString() + ")" + {{/is_repeated}} + {{^is_repeated}} + index = n{{prev}} and result = e.get{{#type_is_hideable}}Immediate{{/type_is_hideable}}{{singular}}() and partialPredicateCall = "{{singular}}()" + {{/is_repeated}} + {{/property}} + {{/all_children}} + )) + {{/has_children}} + } + {{/final}} {{/classes}} cached Element getImmediateChild(Element e, int index, string partialAccessor) { diff --git a/misc/codegen/test/test_ql.py b/misc/codegen/test/test_ql.py index 406c6134a477..237e2d6ecd02 100644 --- a/misc/codegen/test/test_ql.py +++ b/misc/codegen/test/test_ql.py @@ -133,22 +133,10 @@ def test_non_root_class(): assert not cls.root -@pytest.mark.parametrize( - "prev_child,is_child", [(None, False), ("", True), ("x", True)] -) -def test_is_child(prev_child, is_child): - p = ql.Property("Foo", "int", prev_child=prev_child) - assert p.is_child is is_child - - -def test_empty_class_no_children(): - cls = ql.Class("Class", properties=[]) - assert cls.has_children is False - - def test_class_no_children(): cls = ql.Class( - "Class", properties=[ql.Property("Foo", "int"), ql.Property("Bar", "string")] + "Class", + all_children=[], ) assert cls.has_children is False @@ -156,11 +144,7 @@ def test_class_no_children(): def test_class_with_children(): cls = ql.Class( "Class", - properties=[ - ql.Property("Foo", "int"), - ql.Property("Child", "x", prev_child=""), - ql.Property("Bar", "string"), - ], + all_children=[ql.Child(ql.Property("Foo", "int"))], ) assert cls.has_children is True diff --git a/misc/codegen/test/test_qlgen.py b/misc/codegen/test/test_qlgen.py index 43617d5f9e42..eafbe672e770 100644 --- a/misc/codegen/test/test_qlgen.py +++ b/misc/codegen/test/test_qlgen.py @@ -388,11 +388,101 @@ def test_internal_property(generate_classes): def test_children(generate_classes): + expected_parent_property = ql.Property( + singular="ParentChild", + type="int", + is_child=True, + tablename="parents", + tableparams=["this", "result"], + doc="parent child of this parent", + ) + expected_properties = [ + ql.Property( + singular="A", + type="int", + tablename="my_objects", + tableparams=["this", "result", "_"], + doc="a of this my object", + ), + ql.Property( + singular="Child1", + type="int", + tablename="my_objects", + tableparams=["this", "_", "result"], + is_child=True, + doc="child 1 of this my object", + ), + ql.Property( + singular="B", + plural="Bs", + type="int", + tablename="my_object_bs", + tableparams=["this", "index", "result"], + doc="b of this my object", + doc_plural="bs of this my object", + ), + ql.Property( + singular="Child", + plural="Children", + type="int", + tablename="my_object_children", + tableparams=["this", "index", "result"], + is_child=True, + doc="child of this my object", + doc_plural="children of this my object", + ), + ql.Property( + singular="C", + type="int", + tablename="my_object_cs", + tableparams=["this", "result"], + is_optional=True, + doc="c of this my object", + ), + ql.Property( + singular="Child3", + type="int", + tablename="my_object_child_3s", + tableparams=["this", "result"], + is_optional=True, + is_child=True, + doc="child 3 of this my object", + ), + ql.Property( + singular="D", + plural="Ds", + type="int", + tablename="my_object_ds", + tableparams=["this", "index", "result"], + is_optional=True, + doc="d of this my object", + doc_plural="ds of this my object", + ), + ql.Property( + singular="Child4", + plural="Child4s", + type="int", + tablename="my_object_child_4s", + tableparams=["this", "index", "result"], + is_optional=True, + is_child=True, + doc="child 4 of this my object", + doc_plural="child 4s of this my object", + ), + ] assert generate_classes( [ schema.Class("FakeRoot"), + schema.Class( + "Parent", + derived={"MyObject"}, + properties=[ + schema.SingleProperty("parent_child", "int", is_child=True), + ], + ), schema.Class( "MyObject", + bases=["Parent"], properties=[ schema.SingleProperty("a", "int"), schema.SingleProperty("child_1", "int", is_child=True), @@ -413,87 +503,53 @@ def test_children(generate_classes): name="FakeRoot", final=True, imports=[stub_import_prefix + "FakeRoot"] ), ), + "Parent.qll": ( + a_ql_class_public(name="Parent"), + a_ql_stub(name="Parent"), + a_ql_class( + name="Parent", + imports=[stub_import_prefix + "Parent"], + properties=[expected_parent_property], + all_children=[ + ql.Child( + expected_parent_property, + ), + ], + ), + ), "MyObject.qll": ( - a_ql_class_public(name="MyObject"), + a_ql_class_public(name="MyObject", imports=[stub_import_prefix + "Parent"]), a_ql_stub(name="MyObject"), a_ql_class( name="MyObject", final=True, - properties=[ - ql.Property( - singular="A", - type="int", - tablename="my_objects", - tableparams=["this", "result", "_"], - doc="a of this my object", + bases=["Parent"], + bases_impl=["ParentImpl::Parent"], + properties=expected_properties, + all_children=[ + ql.Child( + expected_parent_property, ), - ql.Property( - singular="Child1", - type="int", - tablename="my_objects", - tableparams=["this", "_", "result"], - prev_child="", - doc="child 1 of this my object", + ql.Child( + expected_properties[1], + prev="ParentChild", ), - ql.Property( - singular="B", - plural="Bs", - type="int", - tablename="my_object_bs", - tableparams=["this", "index", "result"], - doc="b of this my object", - doc_plural="bs of this my object", - ), - ql.Property( - singular="Child", - plural="Children", - type="int", - tablename="my_object_children", - tableparams=["this", "index", "result"], - prev_child="Child1", - doc="child of this my object", - doc_plural="children of this my object", - ), - ql.Property( - singular="C", - type="int", - tablename="my_object_cs", - tableparams=["this", "result"], - is_optional=True, - doc="c of this my object", - ), - ql.Property( - singular="Child3", - type="int", - tablename="my_object_child_3s", - tableparams=["this", "result"], - is_optional=True, - prev_child="Child", - doc="child 3 of this my object", + ql.Child( + expected_properties[3], + prev="Child1", ), - ql.Property( - singular="D", - plural="Ds", - type="int", - tablename="my_object_ds", - tableparams=["this", "index", "result"], - is_optional=True, - doc="d of this my object", - doc_plural="ds of this my object", + ql.Child( + expected_properties[5], + prev="Child", ), - ql.Property( - singular="Child4", - plural="Child4s", - type="int", - tablename="my_object_child_4s", - tableparams=["this", "index", "result"], - is_optional=True, - prev_child="Child3", - doc="child 4 of this my object", - doc_plural="child 4s of this my object", + ql.Child( + expected_properties[7], + prev="Child3", ), ], - imports=[stub_import_prefix + "MyObject"], + imports=[ + stub_import_prefix + "internal.ParentImpl::Impl as ParentImpl" + ], ), ), } @@ -547,14 +603,13 @@ def test_single_properties(generate_classes): } -@pytest.mark.parametrize("is_child,prev_child", [(False, None), (True, "")]) -def test_optional_property(generate_classes, is_child, prev_child): +def test_optional_property(generate_classes): assert generate_classes( [ schema.Class("FakeRoot"), schema.Class( "MyObject", - properties=[schema.OptionalProperty("foo", "bar", is_child=is_child)], + properties=[schema.OptionalProperty("foo", "bar")], ), ] ) == { @@ -578,7 +633,6 @@ def test_optional_property(generate_classes, is_child, prev_child): tablename="my_object_foos", tableparams=["this", "result"], is_optional=True, - prev_child=prev_child, doc="foo of this my object", ), ], @@ -588,14 +642,13 @@ def test_optional_property(generate_classes, is_child, prev_child): } -@pytest.mark.parametrize("is_child,prev_child", [(False, None), (True, "")]) -def test_repeated_property(generate_classes, is_child, prev_child): +def test_repeated_property(generate_classes): assert generate_classes( [ schema.Class("FakeRoot"), schema.Class( "MyObject", - properties=[schema.RepeatedProperty("foo", "bar", is_child=is_child)], + properties=[schema.RepeatedProperty("foo", "bar")], ), ] ) == { @@ -619,7 +672,6 @@ def test_repeated_property(generate_classes, is_child, prev_child): type="bar", tablename="my_object_foos", tableparams=["this", "index", "result"], - prev_child=prev_child, doc="foo of this my object", doc_plural="foos of this my object", ), @@ -670,16 +722,13 @@ def test_repeated_unordered_property(generate_classes): } -@pytest.mark.parametrize("is_child,prev_child", [(False, None), (True, "")]) -def test_repeated_optional_property(generate_classes, is_child, prev_child): +def test_repeated_optional_property(generate_classes): assert generate_classes( [ schema.Class("FakeRoot"), schema.Class( "MyObject", - properties=[ - schema.RepeatedOptionalProperty("foo", "bar", is_child=is_child) - ], + properties=[schema.RepeatedOptionalProperty("foo", "bar")], ), ] ) == { @@ -704,7 +753,6 @@ def test_repeated_optional_property(generate_classes, is_child, prev_child): tablename="my_object_foos", tableparams=["this", "index", "result"], is_optional=True, - prev_child=prev_child, doc="foo of this my object", doc_plural="foos of this my object", ), @@ -743,14 +791,13 @@ def test_predicate_property(generate_classes): } -@pytest.mark.parametrize("is_child,prev_child", [(False, None), (True, "")]) -def test_single_class_property(generate_classes, is_child, prev_child): +def test_single_class_property(generate_classes): assert generate_classes( [ schema.Class("Bar"), schema.Class( "MyObject", - properties=[schema.SingleProperty("foo", "Bar", is_child=is_child)], + properties=[schema.SingleProperty("foo", "Bar")], ), ] ) == { @@ -767,7 +814,6 @@ def test_single_class_property(generate_classes, is_child, prev_child): type="Bar", tablename="my_objects", tableparams=["this", "result"], - prev_child=prev_child, doc="foo of this my object", type_is_codegen_class=True, ), diff --git a/rust/ql/.generated.list b/rust/ql/.generated.list index b53665e8af1d..829d1419752e 100644 --- a/rust/ql/.generated.list +++ b/rust/ql/.generated.list @@ -578,7 +578,7 @@ lib/codeql/rust/elements/internal/generated/ParamList.qll eaa0cd4402d3665013d47e lib/codeql/rust/elements/internal/generated/ParenExpr.qll 812d2ff65079277f39f15c084657a955a960a7c1c0e96dd60472a58d56b945eb eb8c607f43e1fcbb41f37a10de203a1db806690e10ff4f04d48ed874189cb0eb lib/codeql/rust/elements/internal/generated/ParenPat.qll 24f9dc7fce75827d6fddb856cd48f80168143151b27295c0bab6db5a06567a09 ebadbc6f5498e9ed754b39893ce0763840409a0721036a25b56e1ead7dcc09aa lib/codeql/rust/elements/internal/generated/ParenTypeRepr.qll 03f5c5b96a37adeb845352d7fcea3e098da9050e534972d14ac0f70d60a2d776 ed3d6e5d02086523087adebce4e89e35461eb95f2a66d1d4100fe23fc691b126 -lib/codeql/rust/elements/internal/generated/ParentChild.qll 24db280d50c02a657a862626ea611a6fa8dab2e03aa4fd86fb61dd69032df333 2b1b2da55bd6f8fe30192afb83843eebd24c9b3e2561a714da4977bccb4ef6cc +lib/codeql/rust/elements/internal/generated/ParentChild.qll ff51da9dd3d1f739057f764f46244fb361c950bf7d1f61007e33d92581ec45e1 bebe239202e79d5a31e29f42f5e9d88139cf07e0fb2541fdd95b8e65154d2776 lib/codeql/rust/elements/internal/generated/ParenthesizedArgList.qll d901fdc8142a5b8847cc98fc2afcfd16428b8ace4fbffb457e761b5fd3901a77 5dbb0aea5a13f937da666ccb042494af8f11e776ade1459d16b70a4dd193f9fb lib/codeql/rust/elements/internal/generated/Pat.qll 3605ac062be2f294ee73336e9669027b8b655f4ad55660e1eab35266275154ee 7f9400db2884d336dd1d21df2a8093759c2a110be9bf6482ce8e80ae0fd74ed4 lib/codeql/rust/elements/internal/generated/Path.qll 9b12afb46fc5a9ad3a811b05472621bbecccb900c47504feb7f29d96b28421ca bcacbffc36fb3e0c9b26523b5963af0ffa9fd6b19f00a2a31bdb2316071546bd @@ -837,7 +837,7 @@ test/extractor-tests/generated/FormatArgsExpr/FormatTemplateVariableAccess.ql 27 test/extractor-tests/generated/FormatArgsExpr/Format_getArgumentRef.ql 634efdffaae4199aa9d95652cf081a8dc26e88224e24678845f8a67dc24ce090 d0302fee5c50403214771d5c6b896ba7c6e52be10c9bea59720ef2bb954e6f40 test/extractor-tests/generated/FormatArgsExpr/Format_getPrecisionArgument.ql 0d2140f84d0220b0c72c48c6bd272f4cfe1863d1797eddd16a6e238552a61e4d f4fe9b29697041e30764fa3dea44f125546bfb648f32c3474a1e922a4255c534 test/extractor-tests/generated/FormatArgsExpr/Format_getWidthArgument.ql 01ef27dd0bfab273e1ddc57ada0e079ece8a2bfd195ce413261006964b444093 acd0161f86010759417015c5b58044467a7f760f288ec4e8525458c54ae9a715 -test/extractor-tests/generated/Function/Function.ql 66e6a81a80cdf30652f00fae1b060e93b9d7c61b08cb3d3c1cac16cad445e769 97ace9f51b9ae933c79484b06b92355164ff3582cadfc6e3bac5c00072cdeff3 +test/extractor-tests/generated/Function/Function.ql 01f0fdcd989648d7d648b3af617e296529c7c674d6bb0977d37306377ae75774 08fd3f595e05e24742f52a474a74b09753a9b565aedffdf4e727d58cc659c97f test/extractor-tests/generated/Function/Function_getAbi.ql e5c9c97de036ddd51cae5d99d41847c35c6b2eabbbd145f4467cb501edc606d8 0b81511528bd0ef9e63b19edfc3cb638d8af43eb87d018fad69d6ef8f8221454 test/extractor-tests/generated/Function/Function_getAttr.ql 44067ee11bdec8e91774ff10de0704a8c5c1b60816d587378e86bf3d82e1f660 b4bebf9441bda1f2d1e34e9261e07a7468cbabf53cf8047384f3c8b11869f04e test/extractor-tests/generated/Function/Function_getAttributeMacroExpansion.ql 17a346a9e5d28af99522520d1af3852db4cae01fb3d290a65c5f84d8d039c345 36fb06b55370828d9bc379cf5fad7f383cdb6f6db6f7377660276943ab0e1ec8 diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll index 30ae1ef0be93..0d2f567f798d 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll @@ -9,107 +9,29 @@ import codeql.rust.elements.internal.ExtractorStep import codeql.rust.elements.internal.NamedCrate private module Impl { - private Element getImmediateChildOfElement(Element e, int index, string partialPredicateCall) { - none() - } - private Element getImmediateChildOfExtractorStep( ExtractorStep 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) - ) - ) + none() } private Element getImmediateChildOfNamedCrate(NamedCrate 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 getImmediateChildOfUnextracted( - Unextracted 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) - ) - ) + none() } private Element getImmediateChildOfCrate(Crate 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) - ) - ) + none() } private Element getImmediateChildOfFormat(Format e, int index, string partialPredicateCall) { - exists( - int b, int bLocatable, int n, int nArgumentRef, int nWidthArgument, int nPrecisionArgument - | - b = 0 and - bLocatable = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocatable(e, i, _)) | i) and - n = bLocatable and + exists(int n, int nArgumentRef, int nWidthArgument, int nPrecisionArgument | + n = 0 and nArgumentRef = n + 1 and nWidthArgument = nArgumentRef + 1 and nPrecisionArgument = nWidthArgument + 1 and ( none() or - result = getImmediateChildOfLocatable(e, index - b, partialPredicateCall) - or index = n and result = e.getArgumentRef() and partialPredicateCall = "ArgumentRef()" or index = nArgumentRef and @@ -126,90 +48,36 @@ private module Impl { private Element getImmediateChildOfFormatArgument( FormatArgument e, int index, string partialPredicateCall ) { - exists(int b, int bLocatable, int n, int nVariable | - b = 0 and - bLocatable = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocatable(e, i, _)) | i) and - n = bLocatable and + exists(int n, int nVariable | + n = 0 and nVariable = n + 1 and ( none() or - result = getImmediateChildOfLocatable(e, index - b, partialPredicateCall) - or index = n and result = e.getVariable() and partialPredicateCall = "Variable()" ) ) } private Element getImmediateChildOfMissing(Missing e, int index, string partialPredicateCall) { - exists(int b, int bUnextracted, int n | - b = 0 and - bUnextracted = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfUnextracted(e, i, _)) | i) and - n = bUnextracted and - ( - none() - or - result = getImmediateChildOfUnextracted(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfUnimplemented( Unimplemented e, int index, string partialPredicateCall ) { - exists(int b, int bUnextracted, int n | - b = 0 and - bUnextracted = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfUnextracted(e, i, _)) | i) and - n = bUnextracted and - ( - none() - or - result = getImmediateChildOfUnextracted(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAbi(Abi 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) - ) - ) + none() } - private Element getImmediateChildOfAddressable( - Addressable 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 getImmediateChildOfAbi(Abi e, int index, string partialPredicateCall) { none() } private Element getImmediateChildOfArgList(ArgList e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nArg | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nArg | + n = 0 and nArg = n + 1 + max(int i | i = -1 or exists(e.getArg(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getArg(index - n) and partialPredicateCall = "Arg(" + (index - n).toString() + ")" ) @@ -217,45 +85,19 @@ private module Impl { } private Element getImmediateChildOfAsmDirSpec(AsmDirSpec 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 getImmediateChildOfAsmOperand(AsmOperand 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) - ) - ) + none() } private Element getImmediateChildOfAsmOperandExpr( AsmOperandExpr e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nInExpr, int nOutExpr | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nInExpr, int nOutExpr | + n = 0 and nInExpr = n + 1 and nOutExpr = nInExpr + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getInExpr() and partialPredicateCall = "InExpr()" or index = nInExpr and result = e.getOutExpr() and partialPredicateCall = "OutExpr()" @@ -264,74 +106,31 @@ private module Impl { } private Element getImmediateChildOfAsmOption(AsmOption 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 getImmediateChildOfAsmPiece(AsmPiece 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) - ) - ) + none() } private Element getImmediateChildOfAsmRegSpec(AsmRegSpec e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nIdentifier | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nIdentifier | + n = 0 and nIdentifier = n + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getIdentifier() and partialPredicateCall = "Identifier()" ) ) } - private Element getImmediateChildOfAssocItem(AssocItem 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 getImmediateChildOfAssocItemList( AssocItemList e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nAssocItem, int nAttr | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nAssocItem, int nAttr | + n = 0 and nAssocItem = n + 1 + max(int i | i = -1 or exists(e.getAssocItem(i)) | i) and nAttr = nAssocItem + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getAssocItem(index - n) and partialPredicateCall = "AssocItem(" + (index - n).toString() + ")" or @@ -342,54 +141,26 @@ private module Impl { } private Element getImmediateChildOfAttr(Attr e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nMeta | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nMeta | + n = 0 and nMeta = n + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getMeta() and partialPredicateCall = "Meta()" ) ) } - private Element getImmediateChildOfCallable(Callable e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nParamList, int nAttr | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - nParamList = n + 1 and - nAttr = nParamList + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or - index = n and result = e.getParamList() and partialPredicateCall = "ParamList()" - or - result = e.getAttr(index - nParamList) and - partialPredicateCall = "Attr(" + (index - nParamList).toString() + ")" - ) - ) - } - private Element getImmediateChildOfClosureBinder( ClosureBinder e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nGenericParamList | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nGenericParamList | + n = 0 and nGenericParamList = n + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getGenericParamList() and partialPredicateCall = "GenericParamList()" @@ -397,46 +168,16 @@ private module Impl { ) } - 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 getImmediateChildOfExternItem(ExternItem 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 getImmediateChildOfExternItemList( ExternItemList e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nAttr, int nExternItem | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nAttr, int nExternItem | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nExternItem = nAttr + 1 + max(int i | i = -1 or exists(e.getExternItem(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -446,33 +187,16 @@ private module Impl { ) } - private Element getImmediateChildOfFieldList(FieldList 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 getImmediateChildOfFormatArgsArg( FormatArgsArg e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nExpr, int nName | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nExpr, int nName | + n = 0 and nExpr = n + 1 and nName = nExpr + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getExpr() and partialPredicateCall = "Expr()" or index = nExpr and result = e.getName() and partialPredicateCall = "Name()" @@ -480,66 +204,30 @@ private module Impl { ) } - private Element getImmediateChildOfGenericArg(GenericArg 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 getImmediateChildOfGenericArgList( GenericArgList e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nGenericArg | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nGenericArg | + n = 0 and nGenericArg = n + 1 + max(int i | i = -1 or exists(e.getGenericArg(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getGenericArg(index - n) and partialPredicateCall = "GenericArg(" + (index - n).toString() + ")" ) ) } - private Element getImmediateChildOfGenericParam( - GenericParam 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 getImmediateChildOfGenericParamList( GenericParamList e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nGenericParam | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nGenericParam | + n = 0 and nGenericParam = n + 1 + max(int i | i = -1 or exists(e.getGenericParam(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getGenericParam(index - n) and partialPredicateCall = "GenericParam(" + (index - n).toString() + ")" ) @@ -547,17 +235,13 @@ private module Impl { } private Element getImmediateChildOfItemList(ItemList e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nAttr, int nItem | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nAttr, int nItem | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nItem = nAttr + 1 + max(int i | i = -1 or exists(e.getItem(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -568,48 +252,36 @@ private module Impl { } private Element getImmediateChildOfLabel(Label e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nLifetime | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nLifetime | + n = 0 and nLifetime = n + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getLifetime() and partialPredicateCall = "Lifetime()" ) ) } private Element getImmediateChildOfLetElse(LetElse e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nBlockExpr | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nBlockExpr | + n = 0 and nBlockExpr = n + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getBlockExpr() and partialPredicateCall = "BlockExpr()" ) ) } private Element getImmediateChildOfMacroItems(MacroItems e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nItem | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nItem | + n = 0 and nItem = n + 1 + max(int i | i = -1 or exists(e.getItem(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getItem(index - n) and partialPredicateCall = "Item(" + (index - n).toString() + ")" ) @@ -617,10 +289,8 @@ private module Impl { } private Element getImmediateChildOfMatchArm(MatchArm e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nAttr, int nExpr, int nGuard, int nPat | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nAttr, int nExpr, int nGuard, int nPat | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nExpr = nAttr + 1 and nGuard = nExpr + 1 and @@ -628,8 +298,6 @@ private module Impl { ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -645,17 +313,13 @@ private module Impl { private Element getImmediateChildOfMatchArmList( MatchArmList e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nArm, int nAttr | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nArm, int nAttr | + n = 0 and nArm = n + 1 + max(int i | i = -1 or exists(e.getArm(i)) | i) and nAttr = nArm + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getArm(index - n) and partialPredicateCall = "Arm(" + (index - n).toString() + ")" or @@ -666,34 +330,26 @@ private module Impl { } private Element getImmediateChildOfMatchGuard(MatchGuard e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nCondition | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nCondition | + n = 0 and nCondition = n + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getCondition() and partialPredicateCall = "Condition()" ) ) } private Element getImmediateChildOfMeta(Meta e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nExpr, int nPath, int nTokenTree | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nExpr, int nPath, int nTokenTree | + n = 0 and nExpr = n + 1 and nPath = nExpr + 1 and nTokenTree = nPath + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getExpr() and partialPredicateCall = "Expr()" or index = nExpr and result = e.getPath() and partialPredicateCall = "Path()" @@ -703,51 +359,16 @@ private module Impl { ) } - private Element getImmediateChildOfName(Name 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 getImmediateChildOfParamBase(ParamBase e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nAttr, int nTypeRepr | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - nTypeRepr = nAttr + 1 and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" - or - index = nAttr and result = e.getTypeRepr() and partialPredicateCall = "TypeRepr()" - ) - ) - } + private Element getImmediateChildOfName(Name e, int index, string partialPredicateCall) { none() } private Element getImmediateChildOfParamList(ParamList e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nParam, int nSelfParam | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nParam, int nSelfParam | + n = 0 and nParam = n + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and nSelfParam = nParam + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getParam(index - n) and partialPredicateCall = "Param(" + (index - n).toString() + ")" or @@ -759,47 +380,26 @@ private module Impl { private Element getImmediateChildOfParenthesizedArgList( ParenthesizedArgList e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nTypeArg | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nTypeArg | + n = 0 and nTypeArg = n + 1 + max(int i | i = -1 or exists(e.getTypeArg(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getTypeArg(index - n) and partialPredicateCall = "TypeArg(" + (index - n).toString() + ")" ) ) } - 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 getImmediateChildOfPath(Path e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nQualifier, int nSegment | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nQualifier, int nSegment | + n = 0 and nQualifier = n + 1 and nSegment = nQualifier + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getQualifier() and partialPredicateCall = "Qualifier()" or index = nQualifier and result = e.getSegment() and partialPredicateCall = "Segment()" @@ -811,12 +411,10 @@ private module Impl { PathSegment e, int index, string partialPredicateCall ) { exists( - int b, int bAstNode, int n, int nGenericArgList, int nIdentifier, int nParenthesizedArgList, - int nRetType, int nReturnTypeSyntax, int nTypeRepr, int nTraitTypeRepr + int n, int nGenericArgList, int nIdentifier, int nParenthesizedArgList, int nRetType, + int nReturnTypeSyntax, int nTypeRepr, int nTraitTypeRepr | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + n = 0 and nGenericArgList = n + 1 and nIdentifier = nGenericArgList + 1 and nParenthesizedArgList = nIdentifier + 1 and @@ -827,8 +425,6 @@ private module Impl { ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getGenericArgList() and partialPredicateCall = "GenericArgList()" or index = nGenericArgList and @@ -859,47 +455,26 @@ private module Impl { } private Element getImmediateChildOfRename(Rename e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nName | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nName | + n = 0 and nName = n + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getName() and partialPredicateCall = "Name()" ) ) } - private Element getImmediateChildOfResolvable(Resolvable 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 getImmediateChildOfRetTypeRepr( RetTypeRepr e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nTypeRepr | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nTypeRepr | + n = 0 and nTypeRepr = n + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getTypeRepr() and partialPredicateCall = "TypeRepr()" ) ) @@ -908,30 +483,17 @@ private module Impl { private Element getImmediateChildOfReturnTypeSyntax( ReturnTypeSyntax 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) - ) - ) + none() } private Element getImmediateChildOfSourceFile(SourceFile e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nAttr, int nItem | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nAttr, int nItem | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nItem = nAttr + 1 + max(int i | i = -1 or exists(e.getItem(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -941,32 +503,15 @@ private module Impl { ) } - 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 getImmediateChildOfStmtList(StmtList e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nAttr, int nStatement, int nTailExpr | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nAttr, int nStatement, int nTailExpr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nStatement = nAttr + 1 + max(int i | i = -1 or exists(e.getStatement(i)) | i) and nTailExpr = nStatement + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -981,18 +526,14 @@ private module Impl { private Element getImmediateChildOfStructExprField( StructExprField e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nAttr, int nExpr, int nIdentifier | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nAttr, int nExpr, int nIdentifier | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nExpr = nAttr + 1 and nIdentifier = nExpr + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -1006,18 +547,14 @@ private module Impl { private Element getImmediateChildOfStructExprFieldList( StructExprFieldList e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nAttr, int nField, int nSpread | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nAttr, int nField, int nSpread | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nField = nAttr + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and nSpread = nField + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -1032,12 +569,8 @@ private module Impl { private Element getImmediateChildOfStructField( StructField e, int index, string partialPredicateCall ) { - exists( - int b, int bAstNode, int n, int nAttr, int nDefault, int nName, int nTypeRepr, int nVisibility - | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nAttr, int nDefault, int nName, int nTypeRepr, int nVisibility | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nDefault = nAttr + 1 and nName = nDefault + 1 and @@ -1046,8 +579,6 @@ private module Impl { ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -1065,18 +596,14 @@ private module Impl { private Element getImmediateChildOfStructPatField( StructPatField e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nAttr, int nIdentifier, int nPat | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nAttr, int nIdentifier, int nPat | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nIdentifier = nAttr + 1 and nPat = nIdentifier + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -1090,17 +617,13 @@ private module Impl { private Element getImmediateChildOfStructPatFieldList( StructPatFieldList e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nField, int nRestPat | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nField, int nRestPat | + n = 0 and nField = n + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and nRestPat = nField + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getField(index - n) and partialPredicateCall = "Field(" + (index - n).toString() + ")" or @@ -1109,45 +632,19 @@ private module Impl { ) } - private Element getImmediateChildOfToken(Token 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 getImmediateChildOfTokenTree(TokenTree 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) - ) - ) + none() } private Element getImmediateChildOfTupleField(TupleField e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nAttr, int nTypeRepr, int nVisibility | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nAttr, int nTypeRepr, int nVisibility | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nTypeRepr = nAttr + 1 and nVisibility = nTypeRepr + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -1159,18 +656,14 @@ private module Impl { } private Element getImmediateChildOfTypeBound(TypeBound e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nLifetime, int nTypeRepr, int nUseBoundGenericArgs | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nLifetime, int nTypeRepr, int nUseBoundGenericArgs | + n = 0 and nLifetime = n + 1 and nTypeRepr = nLifetime + 1 and nUseBoundGenericArgs = nTypeRepr + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getLifetime() and partialPredicateCall = "Lifetime()" or index = nLifetime and result = e.getTypeRepr() and partialPredicateCall = "TypeRepr()" @@ -1185,63 +678,27 @@ private module Impl { private Element getImmediateChildOfTypeBoundList( TypeBoundList e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nBound | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nBound | + n = 0 and nBound = n + 1 + max(int i | i = -1 or exists(e.getBound(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getBound(index - n) and partialPredicateCall = "Bound(" + (index - n).toString() + ")" ) ) } - private Element getImmediateChildOfTypeRepr(TypeRepr 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 getImmediateChildOfUseBoundGenericArg( - UseBoundGenericArg 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 getImmediateChildOfUseBoundGenericArgs( UseBoundGenericArgs e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nUseBoundGenericArg | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nUseBoundGenericArg | + n = 0 and nUseBoundGenericArg = n + 1 + max(int i | i = -1 or exists(e.getUseBoundGenericArg(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getUseBoundGenericArg(index - n) and partialPredicateCall = "UseBoundGenericArg(" + (index - n).toString() + ")" ) @@ -1249,18 +706,14 @@ private module Impl { } private Element getImmediateChildOfUseTree(UseTree e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nPath, int nRename, int nUseTreeList | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nPath, int nRename, int nUseTreeList | + n = 0 and nPath = n + 1 and nRename = nPath + 1 and nUseTreeList = nRename + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getPath() and partialPredicateCall = "Path()" or index = nPath and result = e.getRename() and partialPredicateCall = "Rename()" @@ -1273,16 +726,12 @@ private module Impl { private Element getImmediateChildOfUseTreeList( UseTreeList e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nUseTree | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nUseTree | + n = 0 and nUseTree = n + 1 + max(int i | i = -1 or exists(e.getUseTree(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getUseTree(index - n) and partialPredicateCall = "UseTree(" + (index - n).toString() + ")" ) @@ -1292,16 +741,12 @@ private module Impl { private Element getImmediateChildOfVariantList( VariantList e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nVariant | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nVariant | + n = 0 and nVariant = n + 1 + max(int i | i = -1 or exists(e.getVariant(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getVariant(index - n) and partialPredicateCall = "Variant(" + (index - n).toString() + ")" ) @@ -1309,16 +754,12 @@ private module Impl { } private Element getImmediateChildOfVisibility(Visibility e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nPath | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nPath | + n = 0 and nPath = n + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getPath() and partialPredicateCall = "Path()" ) ) @@ -1327,16 +768,12 @@ private module Impl { private Element getImmediateChildOfWhereClause( WhereClause e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nPredicate | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nPredicate | + n = 0 and nPredicate = n + 1 + max(int i | i = -1 or exists(e.getPredicate(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getPredicate(index - n) and partialPredicateCall = "Predicate(" + (index - n).toString() + ")" ) @@ -1344,13 +781,8 @@ private module Impl { } private Element getImmediateChildOfWherePred(WherePred e, int index, string partialPredicateCall) { - exists( - int b, int bAstNode, int n, int nGenericParamList, int nLifetime, int nTypeRepr, - int nTypeBoundList - | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nGenericParamList, int nLifetime, int nTypeRepr, int nTypeBoundList | + n = 0 and nGenericParamList = n + 1 and nLifetime = nGenericParamList + 1 and nTypeRepr = nLifetime + 1 and @@ -1358,8 +790,6 @@ private module Impl { ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getGenericParamList() and partialPredicateCall = "GenericParamList()" @@ -1377,41 +807,16 @@ private module Impl { ) } - private Element getImmediateChildOfArrayExpr(ArrayExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nExpr, int nAttr | - 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 - nAttr = nExpr + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = e.getExpr(index - n) and - partialPredicateCall = "Expr(" + (index - n).toString() + ")" - or - result = e.getAttr(index - nExpr) and - partialPredicateCall = "Attr(" + (index - nExpr).toString() + ")" - ) - ) - } - private Element getImmediateChildOfArrayExprInternal( ArrayExprInternal e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nAttr, int nExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nExpr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nExpr = nAttr + 1 + max(int i | i = -1 or exists(e.getExpr(i)) | i) and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -1424,17 +829,13 @@ private module Impl { private Element getImmediateChildOfArrayTypeRepr( ArrayTypeRepr e, int index, string partialPredicateCall ) { - exists(int b, int bTypeRepr, int n, int nConstArg, int nElementTypeRepr | - b = 0 and - bTypeRepr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeRepr(e, i, _)) | i) and - n = bTypeRepr and + exists(int n, int nConstArg, int nElementTypeRepr | + n = 0 and nConstArg = n + 1 and nElementTypeRepr = nConstArg + 1 and ( none() or - result = getImmediateChildOfTypeRepr(e, index - b, partialPredicateCall) - or index = n and result = e.getConstArg() and partialPredicateCall = "ConstArg()" or index = nConstArg and @@ -1447,48 +848,30 @@ private module Impl { private Element getImmediateChildOfAsmClobberAbi( AsmClobberAbi e, int index, string partialPredicateCall ) { - exists(int b, int bAsmPiece, int n | - b = 0 and - bAsmPiece = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAsmPiece(e, i, _)) | i) and - n = bAsmPiece and - ( - none() - or - result = getImmediateChildOfAsmPiece(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfAsmConst(AsmConst e, int index, string partialPredicateCall) { - exists(int b, int bAsmOperand, int n, int nExpr | - b = 0 and - bAsmOperand = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAsmOperand(e, i, _)) | i) and - n = bAsmOperand and + exists(int n, int nExpr | + n = 0 and nExpr = n + 1 and ( none() or - result = getImmediateChildOfAsmOperand(e, index - b, partialPredicateCall) - or index = n and result = e.getExpr() and partialPredicateCall = "Expr()" ) ) } private Element getImmediateChildOfAsmExpr(AsmExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAsmPiece, int nAttr, int nTemplate | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAsmPiece, int nAttr, int nTemplate | + n = 0 and nAsmPiece = n + 1 + max(int i | i = -1 or exists(e.getAsmPiece(i)) | i) and nAttr = nAsmPiece + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nTemplate = nAttr + 1 + max(int i | i = -1 or exists(e.getTemplate(i)) | i) and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAsmPiece(index - n) and partialPredicateCall = "AsmPiece(" + (index - n).toString() + ")" or @@ -1502,17 +885,12 @@ private module Impl { } private Element getImmediateChildOfAsmLabel(AsmLabel e, int index, string partialPredicateCall) { - exists(int b, int bAsmOperand, int n, int nBlockExpr | - b = 0 and - bAsmOperand = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAsmOperand(e, i, _)) | i) and - n = bAsmOperand and + exists(int n, int nBlockExpr | + n = 0 and nBlockExpr = n + 1 and ( none() or - result = getImmediateChildOfAsmOperand(e, index - b, partialPredicateCall) - or index = n and result = e.getBlockExpr() and partialPredicateCall = "BlockExpr()" ) ) @@ -1521,17 +899,13 @@ private module Impl { private Element getImmediateChildOfAsmOperandNamed( AsmOperandNamed e, int index, string partialPredicateCall ) { - exists(int b, int bAsmPiece, int n, int nAsmOperand, int nName | - b = 0 and - bAsmPiece = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAsmPiece(e, i, _)) | i) and - n = bAsmPiece and + exists(int n, int nAsmOperand, int nName | + n = 0 and nAsmOperand = n + 1 and nName = nAsmOperand + 1 and ( none() or - result = getImmediateChildOfAsmPiece(e, index - b, partialPredicateCall) - or index = n and result = e.getAsmOperand() and partialPredicateCall = "AsmOperand()" or index = nAsmOperand and result = e.getName() and partialPredicateCall = "Name()" @@ -1542,16 +916,12 @@ private module Impl { private Element getImmediateChildOfAsmOptionsList( AsmOptionsList e, int index, string partialPredicateCall ) { - exists(int b, int bAsmPiece, int n, int nAsmOption | - b = 0 and - bAsmPiece = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAsmPiece(e, i, _)) | i) and - n = bAsmPiece and + exists(int n, int nAsmOption | + n = 0 and nAsmOption = n + 1 + max(int i | i = -1 or exists(e.getAsmOption(i)) | i) and ( none() or - result = getImmediateChildOfAsmPiece(e, index - b, partialPredicateCall) - or result = e.getAsmOption(index - n) and partialPredicateCall = "AsmOption(" + (index - n).toString() + ")" ) @@ -1561,19 +931,14 @@ private module Impl { private Element getImmediateChildOfAsmRegOperand( AsmRegOperand e, int index, string partialPredicateCall ) { - exists(int b, int bAsmOperand, int n, int nAsmDirSpec, int nAsmOperandExpr, int nAsmRegSpec | - b = 0 and - bAsmOperand = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAsmOperand(e, i, _)) | i) and - n = bAsmOperand and + exists(int n, int nAsmDirSpec, int nAsmOperandExpr, int nAsmRegSpec | + n = 0 and nAsmDirSpec = n + 1 and nAsmOperandExpr = nAsmDirSpec + 1 and nAsmRegSpec = nAsmOperandExpr + 1 and ( none() or - result = getImmediateChildOfAsmOperand(e, index - b, partialPredicateCall) - or index = n and result = e.getAsmDirSpec() and partialPredicateCall = "AsmDirSpec()" or index = nAsmDirSpec and @@ -1588,17 +953,12 @@ private module Impl { } private Element getImmediateChildOfAsmSym(AsmSym e, int index, string partialPredicateCall) { - exists(int b, int bAsmOperand, int n, int nPath | - b = 0 and - bAsmOperand = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAsmOperand(e, i, _)) | i) and - n = bAsmOperand and + exists(int n, int nPath | + n = 0 and nPath = n + 1 and ( none() or - result = getImmediateChildOfAsmOperand(e, index - b, partialPredicateCall) - or index = n and result = e.getPath() and partialPredicateCall = "Path()" ) ) @@ -1608,13 +968,10 @@ private module Impl { AssocTypeArg e, int index, string partialPredicateCall ) { exists( - int b, int bGenericArg, int n, int nConstArg, int nGenericArgList, int nIdentifier, - int nParamList, int nRetType, int nReturnTypeSyntax, int nTypeRepr, int nTypeBoundList + int n, int nConstArg, int nGenericArgList, int nIdentifier, int nParamList, int nRetType, + int nReturnTypeSyntax, int nTypeRepr, int nTypeBoundList | - b = 0 and - bGenericArg = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericArg(e, i, _)) | i) and - n = bGenericArg and + n = 0 and nConstArg = n + 1 and nGenericArgList = nConstArg + 1 and nIdentifier = nGenericArgList + 1 and @@ -1626,8 +983,6 @@ private module Impl { ( none() or - result = getImmediateChildOfGenericArg(e, index - b, partialPredicateCall) - or index = n and result = e.getConstArg() and partialPredicateCall = "ConstArg()" or index = nConstArg and @@ -1658,17 +1013,13 @@ private module Impl { } private Element getImmediateChildOfAwaitExpr(AwaitExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nExpr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nExpr = nAttr + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -1678,17 +1029,13 @@ private module Impl { } private Element getImmediateChildOfBecomeExpr(BecomeExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nExpr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nExpr = nAttr + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -1698,18 +1045,14 @@ private module Impl { } private Element getImmediateChildOfBinaryExpr(BinaryExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, 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 + exists(int n, int nAttr, int nLhs, int nRhs | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nLhs = nAttr + 1 and nRhs = nLhs + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -1721,34 +1064,26 @@ private module Impl { } private Element getImmediateChildOfBoxPat(BoxPat 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 + exists(int n, int nPat | + n = 0 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 getImmediateChildOfBreakExpr(BreakExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nExpr, int nLifetime | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nExpr, int nLifetime | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nExpr = nAttr + 1 and nLifetime = nExpr + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -1759,41 +1094,15 @@ private module Impl { ) } - private Element getImmediateChildOfCallExprBase( - CallExprBase e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nArgList, int nAttr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nArgList = n + 1 and - nAttr = nArgList + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getArgList() and partialPredicateCall = "ArgList()" - or - result = e.getAttr(index - nArgList) and - partialPredicateCall = "Attr(" + (index - nArgList).toString() + ")" - ) - ) - } - private Element getImmediateChildOfCastExpr(CastExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nExpr, int nTypeRepr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nExpr, int nTypeRepr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nExpr = nAttr + 1 and nTypeRepr = nExpr + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -1807,23 +1116,22 @@ private module Impl { private Element getImmediateChildOfClosureExpr( ClosureExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int bCallable, int n, int nBody, int nClosureBinder, int nRetType | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bCallable = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfCallable(e, i, _)) | i) and - n = bCallable and - nBody = n + 1 and + exists(int n, int nParamList, int nAttr, int nBody, int nClosureBinder, int nRetType | + n = 0 and + nParamList = n + 1 and + nAttr = nParamList + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nBody = nAttr + 1 and nClosureBinder = nBody + 1 and nRetType = nClosureBinder + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + index = n and result = e.getParamList() and partialPredicateCall = "ParamList()" or - result = getImmediateChildOfCallable(e, index - bExpr, partialPredicateCall) + result = e.getAttr(index - nParamList) and + partialPredicateCall = "Attr(" + (index - nParamList).toString() + ")" or - index = n and result = e.getBody() and partialPredicateCall = "Body()" + index = nAttr and result = e.getBody() and partialPredicateCall = "Body()" or index = nBody and result = e.getClosureBinder() and partialPredicateCall = "ClosureBinder()" or @@ -1833,30 +1141,16 @@ private module Impl { } private Element getImmediateChildOfComment(Comment e, int index, string partialPredicateCall) { - exists(int b, int bToken, int n | - b = 0 and - bToken = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfToken(e, i, _)) | i) and - n = bToken and - ( - none() - or - result = getImmediateChildOfToken(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfConstArg(ConstArg e, int index, string partialPredicateCall) { - exists(int b, int bGenericArg, int n, int nExpr | - b = 0 and - bGenericArg = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericArg(e, i, _)) | i) and - n = bGenericArg and + exists(int n, int nExpr | + n = 0 and nExpr = n + 1 and ( none() or - result = getImmediateChildOfGenericArg(e, index - b, partialPredicateCall) - or index = n and result = e.getExpr() and partialPredicateCall = "Expr()" ) ) @@ -1865,27 +1159,20 @@ private module Impl { private Element getImmediateChildOfConstBlockPat( ConstBlockPat e, int index, string partialPredicateCall ) { - exists(int b, int bPat, int n, int nBlockExpr | - b = 0 and - bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and - n = bPat and + exists(int n, int nBlockExpr | + n = 0 and nBlockExpr = n + 1 and ( none() or - result = getImmediateChildOfPat(e, index - b, partialPredicateCall) - or index = n and result = e.getBlockExpr() and partialPredicateCall = "BlockExpr()" ) ) } private Element getImmediateChildOfConstParam(ConstParam e, int index, string partialPredicateCall) { - exists(int b, int bGenericParam, int n, int nAttr, int nDefaultVal, int nName, int nTypeRepr | - b = 0 and - bGenericParam = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericParam(e, i, _)) | i) and - n = bGenericParam and + exists(int n, int nAttr, int nDefaultVal, int nName, int nTypeRepr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nDefaultVal = nAttr + 1 and nName = nDefaultVal + 1 and @@ -1893,8 +1180,6 @@ private module Impl { ( none() or - result = getImmediateChildOfGenericParam(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -1910,17 +1195,13 @@ private module Impl { private Element getImmediateChildOfContinueExpr( ContinueExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nAttr, int nLifetime | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nLifetime | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nLifetime = nAttr + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -1932,50 +1213,38 @@ private module Impl { private Element getImmediateChildOfDynTraitTypeRepr( DynTraitTypeRepr e, int index, string partialPredicateCall ) { - exists(int b, int bTypeRepr, int n, int nTypeBoundList | - b = 0 and - bTypeRepr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeRepr(e, i, _)) | i) and - n = bTypeRepr and + exists(int n, int nTypeBoundList | + n = 0 and nTypeBoundList = n + 1 and ( none() or - result = getImmediateChildOfTypeRepr(e, index - b, partialPredicateCall) - or index = n and result = e.getTypeBoundList() and partialPredicateCall = "TypeBoundList()" ) ) } 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 + exists(int n, int nExpr | + n = 0 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 nAttr, int nContainer, int nIdentifier | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nContainer, int nIdentifier | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nContainer = nAttr + 1 and nIdentifier = nContainer + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -1989,18 +1258,14 @@ private module Impl { private Element getImmediateChildOfFnPtrTypeRepr( FnPtrTypeRepr e, int index, string partialPredicateCall ) { - exists(int b, int bTypeRepr, int n, int nAbi, int nParamList, int nRetType | - b = 0 and - bTypeRepr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeRepr(e, i, _)) | i) and - n = bTypeRepr and + exists(int n, int nAbi, int nParamList, int nRetType | + n = 0 and nAbi = n + 1 and nParamList = nAbi + 1 and nRetType = nParamList + 1 and ( none() or - result = getImmediateChildOfTypeRepr(e, index - b, partialPredicateCall) - or index = n and result = e.getAbi() and partialPredicateCall = "Abi()" or index = nAbi and result = e.getParamList() and partialPredicateCall = "ParamList()" @@ -2013,17 +1278,13 @@ private module Impl { private Element getImmediateChildOfForTypeRepr( ForTypeRepr e, int index, string partialPredicateCall ) { - exists(int b, int bTypeRepr, int n, int nGenericParamList, int nTypeRepr | - b = 0 and - bTypeRepr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeRepr(e, i, _)) | i) and - n = bTypeRepr and + exists(int n, int nGenericParamList, int nTypeRepr | + n = 0 and nGenericParamList = n + 1 and nTypeRepr = nGenericParamList + 1 and ( none() or - result = getImmediateChildOfTypeRepr(e, index - b, partialPredicateCall) - or index = n and result = e.getGenericParamList() and partialPredicateCall = "GenericParamList()" @@ -2038,10 +1299,8 @@ private module Impl { private Element getImmediateChildOfFormatArgsExpr( FormatArgsExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nArg, int nAttr, int nTemplate, int nFormat | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nArg, int nAttr, int nTemplate, int nFormat | + n = 0 and nArg = n + 1 + max(int i | i = -1 or exists(e.getArg(i)) | i) and nAttr = nArg + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nTemplate = nAttr + 1 and @@ -2049,8 +1308,6 @@ private module Impl { ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getArg(index - n) and partialPredicateCall = "Arg(" + (index - n).toString() + ")" or @@ -2066,18 +1323,14 @@ private module Impl { } private Element getImmediateChildOfIdentPat(IdentPat e, int index, string partialPredicateCall) { - exists(int b, int bPat, int n, int nAttr, int nName, int nPat | - b = 0 and - bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and - n = bPat and + exists(int n, int nAttr, int nName, int nPat | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nName = nAttr + 1 and nPat = nName + 1 and ( none() or - result = getImmediateChildOfPat(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -2089,10 +1342,8 @@ private module Impl { } private Element getImmediateChildOfIfExpr(IfExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nCondition, int nElse, int nThen | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nCondition, int nElse, int nThen | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nCondition = nAttr + 1 and nElse = nCondition + 1 and @@ -2100,8 +1351,6 @@ private module Impl { ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -2117,34 +1366,26 @@ private module Impl { private Element getImmediateChildOfImplTraitTypeRepr( ImplTraitTypeRepr e, int index, string partialPredicateCall ) { - exists(int b, int bTypeRepr, int n, int nTypeBoundList | - b = 0 and - bTypeRepr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeRepr(e, i, _)) | i) and - n = bTypeRepr and + exists(int n, int nTypeBoundList | + n = 0 and nTypeBoundList = n + 1 and ( none() or - result = getImmediateChildOfTypeRepr(e, index - b, partialPredicateCall) - or index = n and result = e.getTypeBoundList() and partialPredicateCall = "TypeBoundList()" ) ) } private Element getImmediateChildOfIndexExpr(IndexExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, 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 + exists(int n, int nAttr, int nBase, int nIndex | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nBase = nAttr + 1 and nIndex = nBase + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -2158,71 +1399,18 @@ private module Impl { private Element getImmediateChildOfInferTypeRepr( InferTypeRepr e, int index, string partialPredicateCall ) { - exists(int b, int bTypeRepr, int n | - b = 0 and - bTypeRepr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeRepr(e, i, _)) | i) and - n = bTypeRepr and - ( - none() - or - result = getImmediateChildOfTypeRepr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfItem(Item e, int index, string partialPredicateCall) { - exists(int b, int bStmt, int bAddressable, int n, int nAttributeMacroExpansion | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - bAddressable = - bStmt + 1 + max(int i | i = -1 or exists(getImmediateChildOfAddressable(e, i, _)) | i) and - n = bAddressable and - nAttributeMacroExpansion = n + 1 and - ( - none() - or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfAddressable(e, index - bStmt, partialPredicateCall) - or - index = n and - result = e.getAttributeMacroExpansion() and - partialPredicateCall = "AttributeMacroExpansion()" - ) - ) - } - - private Element getImmediateChildOfLabelableExpr( - LabelableExpr 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()" - ) - ) + none() } private Element getImmediateChildOfLetExpr(LetExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nScrutinee, int nPat | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nScrutinee, int nPat | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nScrutinee = nAttr + 1 and nPat = nScrutinee + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -2234,12 +1422,8 @@ private module Impl { } private Element getImmediateChildOfLetStmt(LetStmt e, int index, string partialPredicateCall) { - exists( - int b, int bStmt, int n, int nAttr, int nInitializer, int nLetElse, int nPat, int nTypeRepr - | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and + exists(int n, int nAttr, int nInitializer, int nLetElse, int nPat, int nTypeRepr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nInitializer = nAttr + 1 and nLetElse = nInitializer + 1 and @@ -2248,8 +1432,6 @@ private module Impl { ( none() or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -2265,33 +1447,18 @@ private module Impl { } private Element getImmediateChildOfLifetime(Lifetime e, int index, string partialPredicateCall) { - exists(int b, int bUseBoundGenericArg, int n | - b = 0 and - bUseBoundGenericArg = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfUseBoundGenericArg(e, i, _)) | i) and - n = bUseBoundGenericArg and - ( - none() - or - result = getImmediateChildOfUseBoundGenericArg(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfLifetimeArg( LifetimeArg e, int index, string partialPredicateCall ) { - exists(int b, int bGenericArg, int n, int nLifetime | - b = 0 and - bGenericArg = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericArg(e, i, _)) | i) and - n = bGenericArg and + exists(int n, int nLifetime | + n = 0 and nLifetime = n + 1 and ( none() or - result = getImmediateChildOfGenericArg(e, index - b, partialPredicateCall) - or index = n and result = e.getLifetime() and partialPredicateCall = "Lifetime()" ) ) @@ -2300,19 +1467,14 @@ private module Impl { private Element getImmediateChildOfLifetimeParam( LifetimeParam e, int index, string partialPredicateCall ) { - exists(int b, int bGenericParam, int n, int nAttr, int nLifetime, int nTypeBoundList | - b = 0 and - bGenericParam = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericParam(e, i, _)) | i) and - n = bGenericParam and + exists(int n, int nAttr, int nLifetime, int nTypeBoundList | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nLifetime = nAttr + 1 and nTypeBoundList = nLifetime + 1 and ( none() or - result = getImmediateChildOfGenericParam(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -2328,16 +1490,12 @@ private module Impl { private Element getImmediateChildOfLiteralExpr( LiteralExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nAttr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" ) @@ -2345,16 +1503,12 @@ private module Impl { } private Element getImmediateChildOfLiteralPat(LiteralPat e, int index, string partialPredicateCall) { - exists(int b, int bPat, int n, int nLiteral | - b = 0 and - bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and - n = bPat and + exists(int n, int nLiteral | + n = 0 and nLiteral = n + 1 and ( none() or - result = getImmediateChildOfPat(e, index - b, partialPredicateCall) - or index = n and result = e.getLiteral() and partialPredicateCall = "Literal()" ) ) @@ -2363,17 +1517,13 @@ private module Impl { private Element getImmediateChildOfMacroBlockExpr( MacroBlockExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nTailExpr, int nStatement | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nTailExpr, int nStatement | + n = 0 and nTailExpr = n + 1 and nStatement = nTailExpr + 1 + max(int i | i = -1 or exists(e.getStatement(i)) | i) and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getTailExpr() and partialPredicateCall = "TailExpr()" or result = e.getStatement(index - nTailExpr) and @@ -2383,32 +1533,24 @@ private module Impl { } private Element getImmediateChildOfMacroExpr(MacroExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nMacroCall | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nMacroCall | + n = 0 and nMacroCall = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getMacroCall() and partialPredicateCall = "MacroCall()" ) ) } private Element getImmediateChildOfMacroPat(MacroPat e, int index, string partialPredicateCall) { - exists(int b, int bPat, int n, int nMacroCall | - b = 0 and - bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and - n = bPat and + exists(int n, int nMacroCall | + n = 0 and nMacroCall = n + 1 and ( none() or - result = getImmediateChildOfPat(e, index - b, partialPredicateCall) - or index = n and result = e.getMacroCall() and partialPredicateCall = "MacroCall()" ) ) @@ -2417,34 +1559,26 @@ private module Impl { private Element getImmediateChildOfMacroTypeRepr( MacroTypeRepr e, int index, string partialPredicateCall ) { - exists(int b, int bTypeRepr, int n, int nMacroCall | - b = 0 and - bTypeRepr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeRepr(e, i, _)) | i) and - n = bTypeRepr and + exists(int n, int nMacroCall | + n = 0 and nMacroCall = n + 1 and ( none() or - result = getImmediateChildOfTypeRepr(e, index - b, partialPredicateCall) - or index = n and result = e.getMacroCall() and partialPredicateCall = "MacroCall()" ) ) } private Element getImmediateChildOfMatchExpr(MatchExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nScrutinee, int nMatchArmList | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nScrutinee, int nMatchArmList | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nScrutinee = nAttr + 1 and nMatchArmList = nScrutinee + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -2458,49 +1592,26 @@ private module Impl { } private Element getImmediateChildOfNameRef(NameRef e, int index, string partialPredicateCall) { - exists(int b, int bUseBoundGenericArg, int n | - b = 0 and - bUseBoundGenericArg = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfUseBoundGenericArg(e, i, _)) | i) and - n = bUseBoundGenericArg and - ( - none() - or - result = getImmediateChildOfUseBoundGenericArg(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfNeverTypeRepr( NeverTypeRepr e, int index, string partialPredicateCall ) { - exists(int b, int bTypeRepr, int n | - b = 0 and - bTypeRepr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeRepr(e, i, _)) | i) and - n = bTypeRepr and - ( - none() - or - result = getImmediateChildOfTypeRepr(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfOffsetOfExpr( OffsetOfExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nAttr, int nField, int nTypeRepr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nField, int nTypeRepr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nField = nAttr + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and nTypeRepr = nField + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -2513,16 +1624,12 @@ private module Impl { } private Element getImmediateChildOfOrPat(OrPat 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 + exists(int n, int nPat | + n = 0 and nPat = n + 1 + max(int i | i = -1 or exists(e.getPat(i)) | i) and ( none() or - result = getImmediateChildOfPat(e, index - b, partialPredicateCall) - or result = e.getPat(index - n) and partialPredicateCall = "Pat(" + (index - n).toString() + ")" ) @@ -2530,33 +1637,32 @@ private module Impl { } private Element getImmediateChildOfParam(Param e, int index, string partialPredicateCall) { - exists(int b, int bParamBase, int n, int nPat | - b = 0 and - bParamBase = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfParamBase(e, i, _)) | i) and - n = bParamBase and - nPat = n + 1 and + exists(int n, int nAttr, int nTypeRepr, int nPat | + n = 0 and + nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nTypeRepr = nAttr + 1 and + nPat = nTypeRepr + 1 and ( none() or - result = getImmediateChildOfParamBase(e, index - b, partialPredicateCall) + result = e.getAttr(index - n) and + partialPredicateCall = "Attr(" + (index - n).toString() + ")" or - index = n and result = e.getPat() and partialPredicateCall = "Pat()" + index = nAttr and result = e.getTypeRepr() and partialPredicateCall = "TypeRepr()" + or + index = nTypeRepr and result = e.getPat() and partialPredicateCall = "Pat()" ) ) } private Element getImmediateChildOfParenExpr(ParenExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nExpr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nExpr = nAttr + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -2566,16 +1672,12 @@ private module Impl { } private Element getImmediateChildOfParenPat(ParenPat 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 + exists(int n, int nPat | + n = 0 and nPat = n + 1 and ( none() or - result = getImmediateChildOfPat(e, index - b, partialPredicateCall) - or index = n and result = e.getPat() and partialPredicateCall = "Pat()" ) ) @@ -2584,85 +1686,39 @@ private module Impl { private Element getImmediateChildOfParenTypeRepr( ParenTypeRepr e, int index, string partialPredicateCall ) { - exists(int b, int bTypeRepr, int n, int nTypeRepr | - b = 0 and - bTypeRepr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeRepr(e, i, _)) | i) and - n = bTypeRepr and + exists(int n, int nTypeRepr | + n = 0 and nTypeRepr = n + 1 and ( none() or - result = getImmediateChildOfTypeRepr(e, index - b, partialPredicateCall) - or index = n and result = e.getTypeRepr() and partialPredicateCall = "TypeRepr()" ) ) } - private Element getImmediateChildOfPathAstNode( - PathAstNode e, int index, string partialPredicateCall - ) { - exists(int b, int bResolvable, int n, int nPath | - b = 0 and - bResolvable = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfResolvable(e, i, _)) | i) and - n = bResolvable and - nPath = n + 1 and - ( - none() - or - result = getImmediateChildOfResolvable(e, index - b, partialPredicateCall) - or - index = n and result = e.getPath() and partialPredicateCall = "Path()" - ) - ) - } - - private Element getImmediateChildOfPathExprBase( - PathExprBase 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 getImmediateChildOfPathTypeRepr( PathTypeRepr e, int index, string partialPredicateCall ) { - exists(int b, int bTypeRepr, int n, int nPath | - b = 0 and - bTypeRepr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeRepr(e, i, _)) | i) and - n = bTypeRepr and + exists(int n, int nPath | + n = 0 and nPath = n + 1 and ( none() or - result = getImmediateChildOfTypeRepr(e, index - b, partialPredicateCall) - or index = n and result = e.getPath() and partialPredicateCall = "Path()" ) ) } private Element getImmediateChildOfPrefixExpr(PrefixExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nExpr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nExpr = nAttr + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -2674,34 +1730,26 @@ private module Impl { private Element getImmediateChildOfPtrTypeRepr( PtrTypeRepr e, int index, string partialPredicateCall ) { - exists(int b, int bTypeRepr, int n, int nTypeRepr | - b = 0 and - bTypeRepr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeRepr(e, i, _)) | i) and - n = bTypeRepr and + exists(int n, int nTypeRepr | + n = 0 and nTypeRepr = n + 1 and ( none() or - result = getImmediateChildOfTypeRepr(e, index - b, partialPredicateCall) - or index = n and result = e.getTypeRepr() and partialPredicateCall = "TypeRepr()" ) ) } private Element getImmediateChildOfRangeExpr(RangeExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nEnd, int nStart | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nEnd, int nStart | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nEnd = nAttr + 1 and nStart = nEnd + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -2713,17 +1761,13 @@ private module Impl { } private Element getImmediateChildOfRangePat(RangePat e, int index, string partialPredicateCall) { - exists(int b, int bPat, int n, int nEnd, int nStart | - b = 0 and - bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and - n = bPat and + exists(int n, int nEnd, int nStart | + n = 0 and nEnd = n + 1 and nStart = nEnd + 1 and ( none() or - result = getImmediateChildOfPat(e, index - b, partialPredicateCall) - or index = n and result = e.getEnd() and partialPredicateCall = "End()" or index = nEnd and result = e.getStart() and partialPredicateCall = "Start()" @@ -2732,17 +1776,13 @@ private module Impl { } private Element getImmediateChildOfRefExpr(RefExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nExpr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nExpr = nAttr + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -2752,16 +1792,12 @@ private module Impl { } 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 + exists(int n, int nPat | + n = 0 and nPat = n + 1 and ( none() or - result = getImmediateChildOfPat(e, index - b, partialPredicateCall) - or index = n and result = e.getPat() and partialPredicateCall = "Pat()" ) ) @@ -2770,17 +1806,13 @@ private module Impl { private Element getImmediateChildOfRefTypeRepr( RefTypeRepr e, int index, string partialPredicateCall ) { - exists(int b, int bTypeRepr, int n, int nLifetime, int nTypeRepr | - b = 0 and - bTypeRepr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeRepr(e, i, _)) | i) and - n = bTypeRepr and + exists(int n, int nLifetime, int nTypeRepr | + n = 0 and nLifetime = n + 1 and nTypeRepr = nLifetime + 1 and ( none() or - result = getImmediateChildOfTypeRepr(e, index - b, partialPredicateCall) - or index = n and result = e.getLifetime() and partialPredicateCall = "Lifetime()" or index = nLifetime and result = e.getTypeRepr() and partialPredicateCall = "TypeRepr()" @@ -2789,16 +1821,12 @@ private module Impl { } private Element getImmediateChildOfRestPat(RestPat e, int index, string partialPredicateCall) { - exists(int b, int bPat, int n, int nAttr | - b = 0 and - bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and - n = bPat and + exists(int n, int nAttr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and ( none() or - result = getImmediateChildOfPat(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" ) @@ -2806,17 +1834,13 @@ private module Impl { } private Element getImmediateChildOfReturnExpr(ReturnExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nExpr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nExpr = nAttr + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -2826,18 +1850,21 @@ private module Impl { } private Element getImmediateChildOfSelfParam(SelfParam e, int index, string partialPredicateCall) { - exists(int b, int bParamBase, int n, int nLifetime, int nName | - b = 0 and - bParamBase = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfParamBase(e, i, _)) | i) and - n = bParamBase and - nLifetime = n + 1 and + exists(int n, int nAttr, int nTypeRepr, int nLifetime, int nName | + n = 0 and + nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nTypeRepr = nAttr + 1 and + nLifetime = nTypeRepr + 1 and nName = nLifetime + 1 and ( none() or - result = getImmediateChildOfParamBase(e, index - b, partialPredicateCall) + result = e.getAttr(index - n) and + partialPredicateCall = "Attr(" + (index - n).toString() + ")" or - index = n and result = e.getLifetime() and partialPredicateCall = "Lifetime()" + index = nAttr and result = e.getTypeRepr() and partialPredicateCall = "TypeRepr()" + or + index = nTypeRepr and result = e.getLifetime() and partialPredicateCall = "Lifetime()" or index = nLifetime and result = e.getName() and partialPredicateCall = "Name()" ) @@ -2845,16 +1872,12 @@ private module Impl { } private Element getImmediateChildOfSlicePat(SlicePat 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 + exists(int n, int nPat | + n = 0 and nPat = n + 1 + max(int i | i = -1 or exists(e.getPat(i)) | i) and ( none() or - result = getImmediateChildOfPat(e, index - b, partialPredicateCall) - or result = e.getPat(index - n) and partialPredicateCall = "Pat(" + (index - n).toString() + ")" ) @@ -2864,16 +1887,12 @@ private module Impl { private Element getImmediateChildOfSliceTypeRepr( SliceTypeRepr e, int index, string partialPredicateCall ) { - exists(int b, int bTypeRepr, int n, int nTypeRepr | - b = 0 and - bTypeRepr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeRepr(e, i, _)) | i) and - n = bTypeRepr and + exists(int n, int nTypeRepr | + n = 0 and nTypeRepr = n + 1 and ( none() or - result = getImmediateChildOfTypeRepr(e, index - b, partialPredicateCall) - or index = n and result = e.getTypeRepr() and partialPredicateCall = "TypeRepr()" ) ) @@ -2882,16 +1901,12 @@ private module Impl { private Element getImmediateChildOfStructFieldList( StructFieldList e, int index, string partialPredicateCall ) { - exists(int b, int bFieldList, int n, int nField | - b = 0 and - bFieldList = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfFieldList(e, i, _)) | i) and - n = bFieldList and + exists(int n, int nField | + n = 0 and nField = n + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and ( none() or - result = getImmediateChildOfFieldList(e, index - b, partialPredicateCall) - or result = e.getField(index - n) and partialPredicateCall = "Field(" + (index - n).toString() + ")" ) @@ -2899,17 +1914,13 @@ private module Impl { } private Element getImmediateChildOfTryExpr(TryExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nExpr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nExpr = nAttr + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -2919,17 +1930,13 @@ private module Impl { } private Element getImmediateChildOfTupleExpr(TupleExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nField | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nField | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nField = nAttr + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -2942,16 +1949,12 @@ private module Impl { private Element getImmediateChildOfTupleFieldList( TupleFieldList e, int index, string partialPredicateCall ) { - exists(int b, int bFieldList, int n, int nField | - b = 0 and - bFieldList = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfFieldList(e, i, _)) | i) and - n = bFieldList and + exists(int n, int nField | + n = 0 and nField = n + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and ( none() or - result = getImmediateChildOfFieldList(e, index - b, partialPredicateCall) - or result = e.getField(index - n) and partialPredicateCall = "Field(" + (index - n).toString() + ")" ) @@ -2959,16 +1962,12 @@ private module Impl { } private Element getImmediateChildOfTuplePat(TuplePat e, int index, string partialPredicateCall) { - exists(int b, int bPat, int n, int nField | - b = 0 and - bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and - n = bPat and + exists(int n, int nField | + n = 0 and nField = n + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and ( none() or - result = getImmediateChildOfPat(e, index - b, partialPredicateCall) - or result = e.getField(index - n) and partialPredicateCall = "Field(" + (index - n).toString() + ")" ) @@ -2978,16 +1977,12 @@ private module Impl { private Element getImmediateChildOfTupleTypeRepr( TupleTypeRepr e, int index, string partialPredicateCall ) { - exists(int b, int bTypeRepr, int n, int nField | - b = 0 and - bTypeRepr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeRepr(e, i, _)) | i) and - n = bTypeRepr and + exists(int n, int nField | + n = 0 and nField = n + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and ( none() or - result = getImmediateChildOfTypeRepr(e, index - b, partialPredicateCall) - or result = e.getField(index - n) and partialPredicateCall = "Field(" + (index - n).toString() + ")" ) @@ -2995,30 +1990,20 @@ private module Impl { } private Element getImmediateChildOfTypeArg(TypeArg e, int index, string partialPredicateCall) { - exists(int b, int bGenericArg, int n, int nTypeRepr | - b = 0 and - bGenericArg = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericArg(e, i, _)) | i) and - n = bGenericArg and + exists(int n, int nTypeRepr | + n = 0 and nTypeRepr = n + 1 and ( none() or - result = getImmediateChildOfGenericArg(e, index - b, partialPredicateCall) - or index = n and result = e.getTypeRepr() and partialPredicateCall = "TypeRepr()" ) ) } private Element getImmediateChildOfTypeParam(TypeParam e, int index, string partialPredicateCall) { - exists( - int b, int bGenericParam, int n, int nAttr, int nDefaultType, int nName, int nTypeBoundList - | - b = 0 and - bGenericParam = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericParam(e, i, _)) | i) and - n = bGenericParam and + exists(int n, int nAttr, int nDefaultType, int nName, int nTypeBoundList | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nDefaultType = nAttr + 1 and nName = nDefaultType + 1 and @@ -3026,8 +2011,6 @@ private module Impl { ( none() or - result = getImmediateChildOfGenericParam(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -3043,16 +2026,12 @@ private module Impl { private Element getImmediateChildOfUnderscoreExpr( UnderscoreExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nAttr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" ) @@ -3060,14 +2039,8 @@ private module Impl { } private Element getImmediateChildOfVariant(Variant e, int index, string partialPredicateCall) { - exists( - int b, int bAddressable, int n, int nAttr, int nDiscriminant, int nFieldList, int nName, - int nVisibility - | - b = 0 and - bAddressable = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAddressable(e, i, _)) | i) and - n = bAddressable and + exists(int n, int nAttr, int nDiscriminant, int nFieldList, int nName, int nVisibility | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nDiscriminant = nAttr + 1 and nFieldList = nDiscriminant + 1 and @@ -3076,8 +2049,6 @@ private module Impl { ( none() or - result = getImmediateChildOfAddressable(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -3095,30 +2066,17 @@ private module Impl { private Element getImmediateChildOfWildcardPat( WildcardPat 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) - ) - ) + none() } private Element getImmediateChildOfYeetExpr(YeetExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nExpr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nExpr = nAttr + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -3128,17 +2086,13 @@ private module Impl { } private Element getImmediateChildOfYieldExpr(YieldExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nAttr, int nExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nAttr, int nExpr | + n = 0 and nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nExpr = nAttr + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getAttr(index - n) and partialPredicateCall = "Attr(" + (index - n).toString() + ")" or @@ -3147,35 +2101,21 @@ private module Impl { ) } - private Element getImmediateChildOfAdt(Adt e, int index, string partialPredicateCall) { - exists(int b, int bItem, int n, int nDeriveMacroExpansion | - b = 0 and - bItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and - n = bItem and - nDeriveMacroExpansion = - n + 1 + max(int i | i = -1 or exists(e.getDeriveMacroExpansion(i)) | i) and - ( - none() - or - result = getImmediateChildOfItem(e, index - b, partialPredicateCall) - or - result = e.getDeriveMacroExpansion(index - n) and - partialPredicateCall = "DeriveMacroExpansion(" + (index - n).toString() + ")" - ) - ) - } - private Element getImmediateChildOfArrayListExpr( ArrayListExpr e, int index, string partialPredicateCall ) { - exists(int b, int bArrayExpr, int n | - b = 0 and - bArrayExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArrayExpr(e, i, _)) | i) and - n = bArrayExpr and + exists(int n, int nExpr, int nAttr | + n = 0 and + nExpr = n + 1 + max(int i | i = -1 or exists(e.getExpr(i)) | i) and + nAttr = nExpr + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and ( none() or - result = getImmediateChildOfArrayExpr(e, index - b, partialPredicateCall) + result = e.getExpr(index - n) and + partialPredicateCall = "Expr(" + (index - n).toString() + ")" + or + result = e.getAttr(index - nExpr) and + partialPredicateCall = "Attr(" + (index - nExpr).toString() + ")" ) ) } @@ -3183,18 +2123,22 @@ private module Impl { private Element getImmediateChildOfArrayRepeatExpr( ArrayRepeatExpr e, int index, string partialPredicateCall ) { - exists(int b, int bArrayExpr, int n, int nRepeatOperand, int nRepeatLength | - b = 0 and - bArrayExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArrayExpr(e, i, _)) | i) and - n = bArrayExpr and - nRepeatOperand = n + 1 and + exists(int n, int nExpr, int nAttr, int nRepeatOperand, int nRepeatLength | + n = 0 and + nExpr = n + 1 + max(int i | i = -1 or exists(e.getExpr(i)) | i) and + nAttr = nExpr + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nRepeatOperand = nAttr + 1 and nRepeatLength = nRepeatOperand + 1 and ( none() or - result = getImmediateChildOfArrayExpr(e, index - b, partialPredicateCall) + result = e.getExpr(index - n) and + partialPredicateCall = "Expr(" + (index - n).toString() + ")" + or + result = e.getAttr(index - nExpr) and + partialPredicateCall = "Attr(" + (index - nExpr).toString() + ")" or - index = n and result = e.getRepeatOperand() and partialPredicateCall = "RepeatOperand()" + index = nAttr and result = e.getRepeatOperand() and partialPredicateCall = "RepeatOperand()" or index = nRepeatOperand and result = e.getRepeatLength() and @@ -3204,20 +2148,18 @@ private module Impl { } private Element getImmediateChildOfBlockExpr(BlockExpr e, int index, string partialPredicateCall) { - exists(int b, int bLabelableExpr, int n, int nAttr, int nStmtList | - b = 0 and - bLabelableExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabelableExpr(e, i, _)) | i) and - n = bLabelableExpr and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + exists(int n, int nLabel, int nAttr, int nStmtList | + n = 0 and + nLabel = n + 1 and + nAttr = nLabel + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nStmtList = nAttr + 1 and ( none() or - result = getImmediateChildOfLabelableExpr(e, index - b, partialPredicateCall) + index = n and result = e.getLabel() and partialPredicateCall = "Label()" or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" + result = e.getAttr(index - nLabel) and + partialPredicateCall = "Attr(" + (index - nLabel).toString() + ")" or index = nAttr and result = e.getStmtList() and partialPredicateCall = "StmtList()" ) @@ -3225,32 +2167,32 @@ private module Impl { } private Element getImmediateChildOfCallExpr(CallExpr e, int index, string partialPredicateCall) { - exists(int b, int bCallExprBase, int n, int nFunction | - b = 0 and - bCallExprBase = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCallExprBase(e, i, _)) | i) and - n = bCallExprBase and - nFunction = n + 1 and + exists(int n, int nArgList, int nAttr, int nFunction | + n = 0 and + nArgList = n + 1 and + nAttr = nArgList + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nFunction = nAttr + 1 and ( none() or - result = getImmediateChildOfCallExprBase(e, index - b, partialPredicateCall) + index = n and result = e.getArgList() and partialPredicateCall = "ArgList()" + or + result = e.getAttr(index - nArgList) and + partialPredicateCall = "Attr(" + (index - nArgList).toString() + ")" or - index = n and result = e.getFunction() and partialPredicateCall = "Function()" + index = nAttr and result = e.getFunction() and partialPredicateCall = "Function()" ) ) } private Element getImmediateChildOfConst(Const e, int index, string partialPredicateCall) { exists( - int b, int bAssocItem, int bItem, int n, int nAttr, int nBody, int nGenericParamList, - int nName, int nTypeRepr, int nVisibility, int nWhereClause + int n, int nAttributeMacroExpansion, int nAttr, int nBody, int nGenericParamList, int nName, + int nTypeRepr, int nVisibility, int nWhereClause | - b = 0 and - bAssocItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAssocItem(e, i, _)) | i) and - bItem = bAssocItem + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and - n = bItem and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nBody = nAttr + 1 and nGenericParamList = nBody + 1 and nName = nGenericParamList + 1 and @@ -3260,12 +2202,12 @@ private module Impl { ( none() or - result = getImmediateChildOfAssocItem(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfItem(e, index - bAssocItem, partialPredicateCall) + index = n and + result = e.getAttributeMacroExpansion() and + partialPredicateCall = "AttributeMacroExpansion()" or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" + result = e.getAttr(index - nAttributeMacroExpansion) and + partialPredicateCall = "Attr(" + (index - nAttributeMacroExpansion).toString() + ")" or index = nAttr and result = e.getBody() and partialPredicateCall = "Body()" or @@ -3289,19 +2231,20 @@ private module Impl { private Element getImmediateChildOfExternBlock( ExternBlock e, int index, string partialPredicateCall ) { - exists(int b, int bItem, int n, int nAbi, int nAttr, int nExternItemList | - b = 0 and - bItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and - n = bItem and - nAbi = n + 1 and + exists(int n, int nAttributeMacroExpansion, int nAbi, int nAttr, int nExternItemList | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAbi = nAttributeMacroExpansion + 1 and nAttr = nAbi + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nExternItemList = nAttr + 1 and ( none() or - result = getImmediateChildOfItem(e, index - b, partialPredicateCall) + index = n and + result = e.getAttributeMacroExpansion() and + partialPredicateCall = "AttributeMacroExpansion()" or - index = n and result = e.getAbi() and partialPredicateCall = "Abi()" + index = nAttributeMacroExpansion and result = e.getAbi() and partialPredicateCall = "Abi()" or result = e.getAttr(index - nAbi) and partialPredicateCall = "Attr(" + (index - nAbi).toString() + ")" @@ -3316,21 +2259,24 @@ private module Impl { private Element getImmediateChildOfExternCrate( ExternCrate e, int index, string partialPredicateCall ) { - exists(int b, int bItem, int n, int nAttr, int nIdentifier, int nRename, int nVisibility | - b = 0 and - bItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and - n = bItem and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + exists( + int n, int nAttributeMacroExpansion, int nAttr, int nIdentifier, int nRename, int nVisibility + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nIdentifier = nAttr + 1 and nRename = nIdentifier + 1 and nVisibility = nRename + 1 and ( none() or - result = getImmediateChildOfItem(e, index - b, partialPredicateCall) + index = n and + result = e.getAttributeMacroExpansion() and + partialPredicateCall = "AttributeMacroExpansion()" or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" + result = e.getAttr(index - nAttributeMacroExpansion) and + partialPredicateCall = "Attr(" + (index - nAttributeMacroExpansion).toString() + ")" or index = nAttr and result = e.getIdentifier() and partialPredicateCall = "Identifier()" or @@ -3344,33 +2290,19 @@ private module Impl { private Element getImmediateChildOfFormatTemplateVariableAccess( FormatTemplateVariableAccess e, int index, string partialPredicateCall ) { - exists(int b, int bPathExprBase, int n | - b = 0 and - bPathExprBase = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPathExprBase(e, i, _)) | i) and - n = bPathExprBase and - ( - none() - or - result = getImmediateChildOfPathExprBase(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfFunction(Function e, int index, string partialPredicateCall) { exists( - int b, int bAssocItem, int bExternItem, int bItem, int bCallable, int n, int nAbi, int nBody, + int n, int nAttributeMacroExpansion, int nParamList, int nAttr, int nAbi, int nBody, int nGenericParamList, int nName, int nRetType, int nVisibility, int nWhereClause | - b = 0 and - bAssocItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAssocItem(e, i, _)) | i) and - bExternItem = - bAssocItem + 1 + max(int i | i = -1 or exists(getImmediateChildOfExternItem(e, i, _)) | i) and - bItem = bExternItem + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and - bCallable = - bItem + 1 + max(int i | i = -1 or exists(getImmediateChildOfCallable(e, i, _)) | i) and - n = bCallable and - nAbi = n + 1 and + n = 0 and + nAttributeMacroExpansion = n + 1 and + nParamList = nAttributeMacroExpansion + 1 and + nAttr = nParamList + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nAbi = nAttr + 1 and nBody = nAbi + 1 and nGenericParamList = nBody + 1 and nName = nGenericParamList + 1 and @@ -3380,15 +2312,18 @@ private module Impl { ( none() or - result = getImmediateChildOfAssocItem(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfExternItem(e, index - bAssocItem, partialPredicateCall) + index = n and + result = e.getAttributeMacroExpansion() and + partialPredicateCall = "AttributeMacroExpansion()" or - result = getImmediateChildOfItem(e, index - bExternItem, partialPredicateCall) + index = nAttributeMacroExpansion and + result = e.getParamList() and + partialPredicateCall = "ParamList()" or - result = getImmediateChildOfCallable(e, index - bItem, partialPredicateCall) + result = e.getAttr(index - nParamList) and + partialPredicateCall = "Attr(" + (index - nParamList).toString() + ")" or - index = n and result = e.getAbi() and partialPredicateCall = "Abi()" + index = nAttr and result = e.getAbi() and partialPredicateCall = "Abi()" or index = nAbi and result = e.getBody() and partialPredicateCall = "Body()" or @@ -3411,13 +2346,12 @@ private module Impl { private Element getImmediateChildOfImpl(Impl e, int index, string partialPredicateCall) { exists( - int b, int bItem, int n, int nAssocItemList, int nAttr, int nGenericParamList, int nSelfTy, - int nTrait, int nVisibility, int nWhereClause + int n, int nAttributeMacroExpansion, int nAssocItemList, int nAttr, int nGenericParamList, + int nSelfTy, int nTrait, int nVisibility, int nWhereClause | - b = 0 and - bItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and - n = bItem and - nAssocItemList = n + 1 and + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAssocItemList = nAttributeMacroExpansion + 1 and nAttr = nAssocItemList + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nGenericParamList = nAttr + 1 and nSelfTy = nGenericParamList + 1 and @@ -3427,9 +2361,13 @@ private module Impl { ( none() or - result = getImmediateChildOfItem(e, index - b, partialPredicateCall) + index = n and + result = e.getAttributeMacroExpansion() and + partialPredicateCall = "AttributeMacroExpansion()" or - index = n and result = e.getAssocItemList() and partialPredicateCall = "AssocItemList()" + index = nAttributeMacroExpansion and + result = e.getAssocItemList() and + partialPredicateCall = "AssocItemList()" or result = e.getAttr(index - nAssocItemList) and partialPredicateCall = "Attr(" + (index - nAssocItemList).toString() + ")" @@ -3451,51 +2389,26 @@ private module Impl { ) } - private Element getImmediateChildOfLoopingExpr( - LoopingExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bLabelableExpr, int n, int nLoopBody | - b = 0 and - bLabelableExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabelableExpr(e, i, _)) | i) and - n = bLabelableExpr and - nLoopBody = n + 1 and - ( - none() - or - result = getImmediateChildOfLabelableExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getLoopBody() and partialPredicateCall = "LoopBody()" - ) - ) - } - private Element getImmediateChildOfMacroCall(MacroCall e, int index, string partialPredicateCall) { exists( - int b, int bAssocItem, int bExternItem, int bItem, int n, int nAttr, int nPath, - int nTokenTree, int nMacroCallExpansion + int n, int nAttributeMacroExpansion, int nAttr, int nPath, int nTokenTree, + int nMacroCallExpansion | - b = 0 and - bAssocItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAssocItem(e, i, _)) | i) and - bExternItem = - bAssocItem + 1 + max(int i | i = -1 or exists(getImmediateChildOfExternItem(e, i, _)) | i) and - bItem = bExternItem + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and - n = bItem and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nPath = nAttr + 1 and nTokenTree = nPath + 1 and nMacroCallExpansion = nTokenTree + 1 and ( none() or - result = getImmediateChildOfAssocItem(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfExternItem(e, index - bAssocItem, partialPredicateCall) - or - result = getImmediateChildOfItem(e, index - bExternItem, partialPredicateCall) + index = n and + result = e.getAttributeMacroExpansion() and + partialPredicateCall = "AttributeMacroExpansion()" or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" + result = e.getAttr(index - nAttributeMacroExpansion) and + partialPredicateCall = "Attr(" + (index - nAttributeMacroExpansion).toString() + ")" or index = nAttr and result = e.getPath() and partialPredicateCall = "Path()" or @@ -3509,11 +2422,13 @@ private module Impl { } private Element getImmediateChildOfMacroDef(MacroDef e, int index, string partialPredicateCall) { - exists(int b, int bItem, int n, int nArgs, int nAttr, int nBody, int nName, int nVisibility | - b = 0 and - bItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and - n = bItem and - nArgs = n + 1 and + exists( + int n, int nAttributeMacroExpansion, int nArgs, int nAttr, int nBody, int nName, + int nVisibility + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nArgs = nAttributeMacroExpansion + 1 and nAttr = nArgs + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nBody = nAttr + 1 and nName = nBody + 1 and @@ -3521,9 +2436,13 @@ private module Impl { ( none() or - result = getImmediateChildOfItem(e, index - b, partialPredicateCall) + index = n and + result = e.getAttributeMacroExpansion() and + partialPredicateCall = "AttributeMacroExpansion()" or - index = n and result = e.getArgs() and partialPredicateCall = "Args()" + index = nAttributeMacroExpansion and + result = e.getArgs() and + partialPredicateCall = "Args()" or result = e.getAttr(index - nArgs) and partialPredicateCall = "Attr(" + (index - nArgs).toString() + ")" @@ -3538,21 +2457,24 @@ private module Impl { } private Element getImmediateChildOfMacroRules(MacroRules e, int index, string partialPredicateCall) { - exists(int b, int bItem, int n, int nAttr, int nName, int nTokenTree, int nVisibility | - b = 0 and - bItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and - n = bItem and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + exists( + int n, int nAttributeMacroExpansion, int nAttr, int nName, int nTokenTree, int nVisibility + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nName = nAttr + 1 and nTokenTree = nName + 1 and nVisibility = nTokenTree + 1 and ( none() or - result = getImmediateChildOfItem(e, index - b, partialPredicateCall) + index = n and + result = e.getAttributeMacroExpansion() and + partialPredicateCall = "AttributeMacroExpansion()" or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" + result = e.getAttr(index - nAttributeMacroExpansion) and + partialPredicateCall = "Attr(" + (index - nAttributeMacroExpansion).toString() + ")" or index = nAttr and result = e.getName() and partialPredicateCall = "Name()" or @@ -3566,28 +2488,24 @@ private module Impl { private Element getImmediateChildOfMethodCallExpr( MethodCallExpr e, int index, string partialPredicateCall ) { - exists( - int b, int bCallExprBase, int bResolvable, int n, int nGenericArgList, int nIdentifier, - int nReceiver - | - b = 0 and - bCallExprBase = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCallExprBase(e, i, _)) | i) and - bResolvable = - bCallExprBase + 1 + - max(int i | i = -1 or exists(getImmediateChildOfResolvable(e, i, _)) | i) and - n = bResolvable and - nGenericArgList = n + 1 and + exists(int n, int nArgList, int nAttr, int nGenericArgList, int nIdentifier, int nReceiver | + n = 0 and + nArgList = n + 1 and + nAttr = nArgList + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + nGenericArgList = nAttr + 1 and nIdentifier = nGenericArgList + 1 and nReceiver = nIdentifier + 1 and ( none() or - result = getImmediateChildOfCallExprBase(e, index - b, partialPredicateCall) + index = n and result = e.getArgList() and partialPredicateCall = "ArgList()" or - result = getImmediateChildOfResolvable(e, index - bCallExprBase, partialPredicateCall) + result = e.getAttr(index - nArgList) and + partialPredicateCall = "Attr(" + (index - nArgList).toString() + ")" or - index = n and result = e.getGenericArgList() and partialPredicateCall = "GenericArgList()" + index = nAttr and + result = e.getGenericArgList() and + partialPredicateCall = "GenericArgList()" or index = nGenericArgList and result = e.getIdentifier() and @@ -3599,21 +2517,24 @@ private module Impl { } private Element getImmediateChildOfModule(Module e, int index, string partialPredicateCall) { - exists(int b, int bItem, int n, int nAttr, int nItemList, int nName, int nVisibility | - b = 0 and - bItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and - n = bItem and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + exists( + int n, int nAttributeMacroExpansion, int nAttr, int nItemList, int nName, int nVisibility + | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nItemList = nAttr + 1 and nName = nItemList + 1 and nVisibility = nName + 1 and ( none() or - result = getImmediateChildOfItem(e, index - b, partialPredicateCall) + index = n and + result = e.getAttributeMacroExpansion() and + partialPredicateCall = "AttributeMacroExpansion()" or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" + result = e.getAttr(index - nAttributeMacroExpansion) and + partialPredicateCall = "Attr(" + (index - nAttributeMacroExpansion).toString() + ")" or index = nAttr and result = e.getItemList() and partialPredicateCall = "ItemList()" or @@ -3625,56 +2546,41 @@ private module Impl { } private Element getImmediateChildOfPathExpr(PathExpr e, int index, string partialPredicateCall) { - exists(int b, int bPathExprBase, int bPathAstNode, int n, int nAttr | - b = 0 and - bPathExprBase = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPathExprBase(e, i, _)) | i) and - bPathAstNode = - bPathExprBase + 1 + - max(int i | i = -1 or exists(getImmediateChildOfPathAstNode(e, i, _)) | i) and - n = bPathAstNode and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + exists(int n, int nPath, int nAttr | + n = 0 and + nPath = n + 1 and + nAttr = nPath + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and ( none() or - result = getImmediateChildOfPathExprBase(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfPathAstNode(e, index - bPathExprBase, partialPredicateCall) + index = n and result = e.getPath() and partialPredicateCall = "Path()" or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" + result = e.getAttr(index - nPath) and + partialPredicateCall = "Attr(" + (index - nPath).toString() + ")" ) ) } private Element getImmediateChildOfPathPat(PathPat e, int index, string partialPredicateCall) { - exists(int b, int bPat, int bPathAstNode, int n | - b = 0 and - bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and - bPathAstNode = - bPat + 1 + max(int i | i = -1 or exists(getImmediateChildOfPathAstNode(e, i, _)) | i) and - n = bPathAstNode and + exists(int n, int nPath | + n = 0 and + nPath = n + 1 and ( none() or - result = getImmediateChildOfPat(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfPathAstNode(e, index - bPat, partialPredicateCall) + index = n and result = e.getPath() and partialPredicateCall = "Path()" ) ) } private Element getImmediateChildOfStatic(Static e, int index, string partialPredicateCall) { exists( - int b, int bExternItem, int bItem, int n, int nAttr, int nBody, int nName, int nTypeRepr, + int n, int nAttributeMacroExpansion, int nAttr, int nBody, int nName, int nTypeRepr, int nVisibility | - b = 0 and - bExternItem = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExternItem(e, i, _)) | i) and - bItem = bExternItem + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and - n = bItem and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nBody = nAttr + 1 and nName = nBody + 1 and nTypeRepr = nName + 1 and @@ -3682,12 +2588,12 @@ private module Impl { ( none() or - result = getImmediateChildOfExternItem(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfItem(e, index - bExternItem, partialPredicateCall) + index = n and + result = e.getAttributeMacroExpansion() and + partialPredicateCall = "AttributeMacroExpansion()" or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" + result = e.getAttr(index - nAttributeMacroExpansion) and + partialPredicateCall = "Attr(" + (index - nAttributeMacroExpansion).toString() + ")" or index = nAttr and result = e.getBody() and partialPredicateCall = "Body()" or @@ -3701,21 +2607,16 @@ private module Impl { } private Element getImmediateChildOfStructExpr(StructExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int bPathAstNode, int n, int nStructExprFieldList | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bPathAstNode = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfPathAstNode(e, i, _)) | i) and - n = bPathAstNode and - nStructExprFieldList = n + 1 and + exists(int n, int nPath, int nStructExprFieldList | + n = 0 and + nPath = n + 1 and + nStructExprFieldList = nPath + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfPathAstNode(e, index - bExpr, partialPredicateCall) + index = n and result = e.getPath() and partialPredicateCall = "Path()" or - index = n and + index = nPath and result = e.getStructExprFieldList() and partialPredicateCall = "StructExprFieldList()" ) @@ -3723,21 +2624,16 @@ private module Impl { } private Element getImmediateChildOfStructPat(StructPat e, int index, string partialPredicateCall) { - exists(int b, int bPat, int bPathAstNode, int n, int nStructPatFieldList | - b = 0 and - bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and - bPathAstNode = - bPat + 1 + max(int i | i = -1 or exists(getImmediateChildOfPathAstNode(e, i, _)) | i) and - n = bPathAstNode and - nStructPatFieldList = n + 1 and + exists(int n, int nPath, int nStructPatFieldList | + n = 0 and + nPath = n + 1 and + nStructPatFieldList = nPath + 1 and ( none() or - result = getImmediateChildOfPat(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfPathAstNode(e, index - bPat, partialPredicateCall) + index = n and result = e.getPath() and partialPredicateCall = "Path()" or - index = n and + index = nPath and result = e.getStructPatFieldList() and partialPredicateCall = "StructPatFieldList()" ) @@ -3746,13 +2642,12 @@ private module Impl { private Element getImmediateChildOfTrait(Trait e, int index, string partialPredicateCall) { exists( - int b, int bItem, int n, int nAssocItemList, int nAttr, int nGenericParamList, int nName, - int nTypeBoundList, int nVisibility, int nWhereClause + int n, int nAttributeMacroExpansion, int nAssocItemList, int nAttr, int nGenericParamList, + int nName, int nTypeBoundList, int nVisibility, int nWhereClause | - b = 0 and - bItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and - n = bItem and - nAssocItemList = n + 1 and + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAssocItemList = nAttributeMacroExpansion + 1 and nAttr = nAssocItemList + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nGenericParamList = nAttr + 1 and nName = nGenericParamList + 1 and @@ -3762,9 +2657,13 @@ private module Impl { ( none() or - result = getImmediateChildOfItem(e, index - b, partialPredicateCall) + index = n and + result = e.getAttributeMacroExpansion() and + partialPredicateCall = "AttributeMacroExpansion()" or - index = n and result = e.getAssocItemList() and partialPredicateCall = "AssocItemList()" + index = nAttributeMacroExpansion and + result = e.getAssocItemList() and + partialPredicateCall = "AssocItemList()" or result = e.getAttr(index - nAssocItemList) and partialPredicateCall = "Attr(" + (index - nAssocItemList).toString() + ")" @@ -3790,13 +2689,12 @@ private module Impl { private Element getImmediateChildOfTraitAlias(TraitAlias e, int index, string partialPredicateCall) { exists( - int b, int bItem, int n, int nAttr, int nGenericParamList, int nName, int nTypeBoundList, - int nVisibility, int nWhereClause + int n, int nAttributeMacroExpansion, int nAttr, int nGenericParamList, int nName, + int nTypeBoundList, int nVisibility, int nWhereClause | - b = 0 and - bItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and - n = bItem and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nGenericParamList = nAttr + 1 and nName = nGenericParamList + 1 and nTypeBoundList = nName + 1 and @@ -3805,10 +2703,12 @@ private module Impl { ( none() or - result = getImmediateChildOfItem(e, index - b, partialPredicateCall) + index = n and + result = e.getAttributeMacroExpansion() and + partialPredicateCall = "AttributeMacroExpansion()" or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" + result = e.getAttr(index - nAttributeMacroExpansion) and + partialPredicateCall = "Attr(" + (index - nAttributeMacroExpansion).toString() + ")" or index = nAttr and result = e.getGenericParamList() and @@ -3832,38 +2732,29 @@ private module Impl { private Element getImmediateChildOfTupleStructPat( TupleStructPat e, int index, string partialPredicateCall ) { - exists(int b, int bPat, int bPathAstNode, int n, int nField | - b = 0 and - bPat = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPat(e, i, _)) | i) and - bPathAstNode = - bPat + 1 + max(int i | i = -1 or exists(getImmediateChildOfPathAstNode(e, i, _)) | i) and - n = bPathAstNode and - nField = n + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and + exists(int n, int nPath, int nField | + n = 0 and + nPath = n + 1 and + nField = nPath + 1 + max(int i | i = -1 or exists(e.getField(i)) | i) and ( none() or - result = getImmediateChildOfPat(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfPathAstNode(e, index - bPat, partialPredicateCall) + index = n and result = e.getPath() and partialPredicateCall = "Path()" or - result = e.getField(index - n) and - partialPredicateCall = "Field(" + (index - n).toString() + ")" + result = e.getField(index - nPath) and + partialPredicateCall = "Field(" + (index - nPath).toString() + ")" ) ) } private Element getImmediateChildOfTypeAlias(TypeAlias e, int index, string partialPredicateCall) { exists( - int b, int bAssocItem, int bExternItem, int bItem, int n, int nAttr, int nGenericParamList, - int nName, int nTypeRepr, int nTypeBoundList, int nVisibility, int nWhereClause + int n, int nAttributeMacroExpansion, int nAttr, int nGenericParamList, int nName, + int nTypeRepr, int nTypeBoundList, int nVisibility, int nWhereClause | - b = 0 and - bAssocItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAssocItem(e, i, _)) | i) and - bExternItem = - bAssocItem + 1 + max(int i | i = -1 or exists(getImmediateChildOfExternItem(e, i, _)) | i) and - bItem = bExternItem + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and - n = bItem and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nGenericParamList = nAttr + 1 and nName = nGenericParamList + 1 and nTypeRepr = nName + 1 and @@ -3873,14 +2764,12 @@ private module Impl { ( none() or - result = getImmediateChildOfAssocItem(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfExternItem(e, index - bAssocItem, partialPredicateCall) - or - result = getImmediateChildOfItem(e, index - bExternItem, partialPredicateCall) + index = n and + result = e.getAttributeMacroExpansion() and + partialPredicateCall = "AttributeMacroExpansion()" or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" + result = e.getAttr(index - nAttributeMacroExpansion) and + partialPredicateCall = "Attr(" + (index - nAttributeMacroExpansion).toString() + ")" or index = nAttr and result = e.getGenericParamList() and @@ -3906,20 +2795,21 @@ private module Impl { } private Element getImmediateChildOfUse(Use e, int index, string partialPredicateCall) { - exists(int b, int bItem, int n, int nAttr, int nUseTree, int nVisibility | - b = 0 and - bItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and - n = bItem and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + exists(int n, int nAttributeMacroExpansion, int nAttr, int nUseTree, int nVisibility | + n = 0 and + nAttributeMacroExpansion = n + 1 and + nAttr = nAttributeMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nUseTree = nAttr + 1 and nVisibility = nUseTree + 1 and ( none() or - result = getImmediateChildOfItem(e, index - b, partialPredicateCall) + index = n and + result = e.getAttributeMacroExpansion() and + partialPredicateCall = "AttributeMacroExpansion()" or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" + result = e.getAttr(index - nAttributeMacroExpansion) and + partialPredicateCall = "Attr(" + (index - nAttributeMacroExpansion).toString() + ")" or index = nAttr and result = e.getUseTree() and partialPredicateCall = "UseTree()" or @@ -3930,13 +2820,15 @@ private module Impl { private Element getImmediateChildOfEnum(Enum e, int index, string partialPredicateCall) { exists( - int b, int bAdt, int n, int nAttr, int nGenericParamList, int nName, int nVariantList, - int nVisibility, int nWhereClause + int n, int nAttributeMacroExpansion, int nDeriveMacroExpansion, int nAttr, + int nGenericParamList, int nName, int nVariantList, int nVisibility, int nWhereClause | - b = 0 and - bAdt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAdt(e, i, _)) | i) and - n = bAdt and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + n = 0 and + nAttributeMacroExpansion = n + 1 and + nDeriveMacroExpansion = + nAttributeMacroExpansion + 1 + + max(int i | i = -1 or exists(e.getDeriveMacroExpansion(i)) | i) and + nAttr = nDeriveMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nGenericParamList = nAttr + 1 and nName = nGenericParamList + 1 and nVariantList = nName + 1 and @@ -3945,10 +2837,16 @@ private module Impl { ( none() or - result = getImmediateChildOfAdt(e, index - b, partialPredicateCall) + index = n and + result = e.getAttributeMacroExpansion() and + partialPredicateCall = "AttributeMacroExpansion()" + or + result = e.getDeriveMacroExpansion(index - nAttributeMacroExpansion) and + partialPredicateCall = + "DeriveMacroExpansion(" + (index - nAttributeMacroExpansion).toString() + ")" or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" + result = e.getAttr(index - nDeriveMacroExpansion) and + partialPredicateCall = "Attr(" + (index - nDeriveMacroExpansion).toString() + ")" or index = nAttr and result = e.getGenericParamList() and @@ -3970,21 +2868,22 @@ private module Impl { } private Element getImmediateChildOfForExpr(ForExpr e, int index, string partialPredicateCall) { - exists(int b, int bLoopingExpr, int n, int nAttr, int nIterable, int nPat | - b = 0 and - bLoopingExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLoopingExpr(e, i, _)) | i) and - n = bLoopingExpr and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + exists(int n, int nLabel, int nLoopBody, int nAttr, int nIterable, int nPat | + n = 0 and + nLabel = n + 1 and + nLoopBody = nLabel + 1 and + nAttr = nLoopBody + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nIterable = nAttr + 1 and nPat = nIterable + 1 and ( none() or - result = getImmediateChildOfLoopingExpr(e, index - b, partialPredicateCall) + index = n and result = e.getLabel() and partialPredicateCall = "Label()" or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" + index = nLabel and result = e.getLoopBody() and partialPredicateCall = "LoopBody()" + or + result = e.getAttr(index - nLoopBody) and + partialPredicateCall = "Attr(" + (index - nLoopBody).toString() + ")" or index = nAttr and result = e.getIterable() and partialPredicateCall = "Iterable()" or @@ -3994,32 +2893,35 @@ private module Impl { } private Element getImmediateChildOfLoopExpr(LoopExpr e, int index, string partialPredicateCall) { - exists(int b, int bLoopingExpr, int n, int nAttr | - b = 0 and - bLoopingExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLoopingExpr(e, i, _)) | i) and - n = bLoopingExpr and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + exists(int n, int nLabel, int nLoopBody, int nAttr | + n = 0 and + nLabel = n + 1 and + nLoopBody = nLabel + 1 and + nAttr = nLoopBody + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and ( none() or - result = getImmediateChildOfLoopingExpr(e, index - b, partialPredicateCall) + index = n and result = e.getLabel() and partialPredicateCall = "Label()" or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" + index = nLabel and result = e.getLoopBody() and partialPredicateCall = "LoopBody()" + or + result = e.getAttr(index - nLoopBody) and + partialPredicateCall = "Attr(" + (index - nLoopBody).toString() + ")" ) ) } private Element getImmediateChildOfStruct(Struct e, int index, string partialPredicateCall) { exists( - int b, int bAdt, int n, int nAttr, int nFieldList, int nGenericParamList, int nName, - int nVisibility, int nWhereClause + int n, int nAttributeMacroExpansion, int nDeriveMacroExpansion, int nAttr, int nFieldList, + int nGenericParamList, int nName, int nVisibility, int nWhereClause | - b = 0 and - bAdt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAdt(e, i, _)) | i) and - n = bAdt and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + n = 0 and + nAttributeMacroExpansion = n + 1 and + nDeriveMacroExpansion = + nAttributeMacroExpansion + 1 + + max(int i | i = -1 or exists(e.getDeriveMacroExpansion(i)) | i) and + nAttr = nDeriveMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nFieldList = nAttr + 1 and nGenericParamList = nFieldList + 1 and nName = nGenericParamList + 1 and @@ -4028,10 +2930,16 @@ private module Impl { ( none() or - result = getImmediateChildOfAdt(e, index - b, partialPredicateCall) + index = n and + result = e.getAttributeMacroExpansion() and + partialPredicateCall = "AttributeMacroExpansion()" or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" + result = e.getDeriveMacroExpansion(index - nAttributeMacroExpansion) and + partialPredicateCall = + "DeriveMacroExpansion(" + (index - nAttributeMacroExpansion).toString() + ")" + or + result = e.getAttr(index - nDeriveMacroExpansion) and + partialPredicateCall = "Attr(" + (index - nDeriveMacroExpansion).toString() + ")" or index = nAttr and result = e.getFieldList() and partialPredicateCall = "FieldList()" or @@ -4052,13 +2960,15 @@ private module Impl { private Element getImmediateChildOfUnion(Union e, int index, string partialPredicateCall) { exists( - int b, int bAdt, int n, int nAttr, int nGenericParamList, int nName, int nStructFieldList, - int nVisibility, int nWhereClause + int n, int nAttributeMacroExpansion, int nDeriveMacroExpansion, int nAttr, + int nGenericParamList, int nName, int nStructFieldList, int nVisibility, int nWhereClause | - b = 0 and - bAdt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAdt(e, i, _)) | i) and - n = bAdt and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + n = 0 and + nAttributeMacroExpansion = n + 1 and + nDeriveMacroExpansion = + nAttributeMacroExpansion + 1 + + max(int i | i = -1 or exists(e.getDeriveMacroExpansion(i)) | i) and + nAttr = nDeriveMacroExpansion + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nGenericParamList = nAttr + 1 and nName = nGenericParamList + 1 and nStructFieldList = nName + 1 and @@ -4067,10 +2977,16 @@ private module Impl { ( none() or - result = getImmediateChildOfAdt(e, index - b, partialPredicateCall) + index = n and + result = e.getAttributeMacroExpansion() and + partialPredicateCall = "AttributeMacroExpansion()" or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" + result = e.getDeriveMacroExpansion(index - nAttributeMacroExpansion) and + partialPredicateCall = + "DeriveMacroExpansion(" + (index - nAttributeMacroExpansion).toString() + ")" + or + result = e.getAttr(index - nDeriveMacroExpansion) and + partialPredicateCall = "Attr(" + (index - nDeriveMacroExpansion).toString() + ")" or index = nAttr and result = e.getGenericParamList() and @@ -4094,20 +3010,21 @@ private module Impl { } private Element getImmediateChildOfWhileExpr(WhileExpr e, int index, string partialPredicateCall) { - exists(int b, int bLoopingExpr, int n, int nAttr, int nCondition | - b = 0 and - bLoopingExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLoopingExpr(e, i, _)) | i) and - n = bLoopingExpr and - nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and + exists(int n, int nLabel, int nLoopBody, int nAttr, int nCondition | + n = 0 and + nLabel = n + 1 and + nLoopBody = nLabel + 1 and + nAttr = nLoopBody + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and nCondition = nAttr + 1 and ( none() or - result = getImmediateChildOfLoopingExpr(e, index - b, partialPredicateCall) + index = n and result = e.getLabel() and partialPredicateCall = "Label()" or - result = e.getAttr(index - n) and - partialPredicateCall = "Attr(" + (index - n).toString() + ")" + index = nLabel and result = e.getLoopBody() and partialPredicateCall = "LoopBody()" + or + result = e.getAttr(index - nLoopBody) and + partialPredicateCall = "Attr(" + (index - nLoopBody).toString() + ")" or index = nAttr and result = e.getCondition() and partialPredicateCall = "Condition()" ) diff --git a/rust/ql/test/extractor-tests/generated/Function/Cargo.lock b/rust/ql/test/extractor-tests/generated/Function/Cargo.lock new file mode 100644 index 000000000000..b9856cfaf77d --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/Function/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "test" +version = "0.0.1" diff --git a/rust/ql/test/extractor-tests/generated/Function/Function.expected b/rust/ql/test/extractor-tests/generated/Function/Function.expected index 967606c2542f..d8dba069c8d1 100644 --- a/rust/ql/test/extractor-tests/generated/Function/Function.expected +++ b/rust/ql/test/extractor-tests/generated/Function/Function.expected @@ -1,2 +1,2 @@ -| gen_function.rs:3:1:4:38 | fn foo | hasParamList: | yes | getNumberOfAttrs: | 0 | getNumberOfParams: | 1 | hasExtendedCanonicalPath: | yes | hasCrateOrigin: | yes | hasAttributeMacroExpansion: | no | hasAbi: | no | hasBody: | yes | hasGenericParamList: | no | isAsync: | no | isConst: | no | isDefault: | no | isGen: | no | isUnsafe: | no | hasName: | yes | hasRetType: | yes | hasVisibility: | no | hasWhereClause: | no | hasImplementation: | yes | -| gen_function.rs:7:5:7:13 | fn bar | hasParamList: | yes | getNumberOfAttrs: | 0 | getNumberOfParams: | 0 | hasExtendedCanonicalPath: | yes | hasCrateOrigin: | yes | hasAttributeMacroExpansion: | no | hasAbi: | no | hasBody: | no | hasGenericParamList: | no | isAsync: | no | isConst: | no | isDefault: | no | isGen: | no | isUnsafe: | no | hasName: | yes | hasRetType: | no | hasVisibility: | no | hasWhereClause: | no | hasImplementation: | no | +| gen_function.rs:3:1:4:38 | fn foo | hasExtendedCanonicalPath: | yes | hasCrateOrigin: | yes | hasAttributeMacroExpansion: | no | hasParamList: | yes | getNumberOfAttrs: | 0 | getNumberOfParams: | 1 | hasAbi: | no | hasBody: | yes | hasGenericParamList: | no | isAsync: | no | isConst: | no | isDefault: | no | isGen: | no | isUnsafe: | no | hasName: | yes | hasRetType: | yes | hasVisibility: | no | hasWhereClause: | no | hasImplementation: | yes | +| gen_function.rs:7:5:7:13 | fn bar | hasExtendedCanonicalPath: | yes | hasCrateOrigin: | yes | hasAttributeMacroExpansion: | no | hasParamList: | yes | getNumberOfAttrs: | 0 | getNumberOfParams: | 0 | hasAbi: | no | hasBody: | no | hasGenericParamList: | no | isAsync: | no | isConst: | no | isDefault: | no | isGen: | no | isUnsafe: | no | hasName: | yes | hasRetType: | no | hasVisibility: | no | hasWhereClause: | no | hasImplementation: | no | diff --git a/rust/ql/test/extractor-tests/generated/Function/Function.ql b/rust/ql/test/extractor-tests/generated/Function/Function.ql index 5e50f7a4ac0b..32832f61d24b 100644 --- a/rust/ql/test/extractor-tests/generated/Function/Function.ql +++ b/rust/ql/test/extractor-tests/generated/Function/Function.ql @@ -3,17 +3,14 @@ import codeql.rust.elements import TestUtils from - Function x, string hasParamList, int getNumberOfAttrs, int getNumberOfParams, - string hasExtendedCanonicalPath, string hasCrateOrigin, string hasAttributeMacroExpansion, - string hasAbi, string hasBody, string hasGenericParamList, string isAsync, string isConst, - string isDefault, string isGen, string isUnsafe, string hasName, string hasRetType, - string hasVisibility, string hasWhereClause, string hasImplementation + Function x, string hasExtendedCanonicalPath, string hasCrateOrigin, + string hasAttributeMacroExpansion, string hasParamList, int getNumberOfAttrs, + int getNumberOfParams, string hasAbi, string hasBody, string hasGenericParamList, string isAsync, + string isConst, string isDefault, string isGen, string isUnsafe, string hasName, + string hasRetType, string hasVisibility, string hasWhereClause, string hasImplementation where toBeTested(x) and not x.isUnknown() and - (if x.hasParamList() then hasParamList = "yes" else hasParamList = "no") and - getNumberOfAttrs = x.getNumberOfAttrs() and - getNumberOfParams = x.getNumberOfParams() and ( if x.hasExtendedCanonicalPath() then hasExtendedCanonicalPath = "yes" @@ -25,6 +22,9 @@ where then hasAttributeMacroExpansion = "yes" else hasAttributeMacroExpansion = "no" ) and + (if x.hasParamList() then hasParamList = "yes" else hasParamList = "no") and + getNumberOfAttrs = x.getNumberOfAttrs() and + getNumberOfParams = x.getNumberOfParams() and (if x.hasAbi() then hasAbi = "yes" else hasAbi = "no") and (if x.hasBody() then hasBody = "yes" else hasBody = "no") and (if x.hasGenericParamList() then hasGenericParamList = "yes" else hasGenericParamList = "no") and @@ -38,10 +38,10 @@ where (if x.hasVisibility() then hasVisibility = "yes" else hasVisibility = "no") and (if x.hasWhereClause() then hasWhereClause = "yes" else hasWhereClause = "no") and if x.hasImplementation() then hasImplementation = "yes" else hasImplementation = "no" -select x, "hasParamList:", hasParamList, "getNumberOfAttrs:", getNumberOfAttrs, - "getNumberOfParams:", getNumberOfParams, "hasExtendedCanonicalPath:", hasExtendedCanonicalPath, - "hasCrateOrigin:", hasCrateOrigin, "hasAttributeMacroExpansion:", hasAttributeMacroExpansion, - "hasAbi:", hasAbi, "hasBody:", hasBody, "hasGenericParamList:", hasGenericParamList, "isAsync:", - isAsync, "isConst:", isConst, "isDefault:", isDefault, "isGen:", isGen, "isUnsafe:", isUnsafe, - "hasName:", hasName, "hasRetType:", hasRetType, "hasVisibility:", hasVisibility, - "hasWhereClause:", hasWhereClause, "hasImplementation:", hasImplementation +select x, "hasExtendedCanonicalPath:", hasExtendedCanonicalPath, "hasCrateOrigin:", hasCrateOrigin, + "hasAttributeMacroExpansion:", hasAttributeMacroExpansion, "hasParamList:", hasParamList, + "getNumberOfAttrs:", getNumberOfAttrs, "getNumberOfParams:", getNumberOfParams, "hasAbi:", hasAbi, + "hasBody:", hasBody, "hasGenericParamList:", hasGenericParamList, "isAsync:", isAsync, "isConst:", + isConst, "isDefault:", isDefault, "isGen:", isGen, "isUnsafe:", isUnsafe, "hasName:", hasName, + "hasRetType:", hasRetType, "hasVisibility:", hasVisibility, "hasWhereClause:", hasWhereClause, + "hasImplementation:", hasImplementation diff --git a/swift/ql/.generated.list b/swift/ql/.generated.list index f693ce9e9fc5..714f7f77e851 100644 --- a/swift/ql/.generated.list +++ b/swift/ql/.generated.list @@ -733,7 +733,7 @@ lib/codeql/swift/generated/Locatable.qll 1d37fa20de71c0b9986bfd7a7c0cb82ab7bf3fd lib/codeql/swift/generated/Location.qll 5e20316c3e480ddfe632b7e88e016c19f10a67df1f6ae9c8f128755a6907d6f5 5a0af2d070bcb2ed53d6d0282bf9c60dc64c2dce89c21fdd485e9c7893c1c8fa lib/codeql/swift/generated/MacroRole.qll facf907e75490d69cd401c491215e4719324d751f40ea46c86ccf24cf3663c1f 969d8d4b44e3f1a9c193a152a4d83a303e56d2dbb871fc920c47a33f699cf018 lib/codeql/swift/generated/OtherAvailabilitySpec.qll d9feaa2a71acff3184ca389045b0a49d09156210df0e034923d715b432ad594b 046737621a8bcf69bf805afb0cff476bd15259f12f0d77fce3206dd01b31518f -lib/codeql/swift/generated/ParentChild.qll d66e5c28e93a3085fbae0ada238a96577ad21fd64a37ce967032bf5df8bdfb1d 2d440ad9c0304f658d54c6c53a8b1db1d3e032ee5522b51c46116413d0cf5dbb +lib/codeql/swift/generated/ParentChild.qll 86a6c9ba4c79d72bf7a0786274f6fba49e6f37cf82de0451a6dad0d319224ebd f7b99ceb052a23d7c25d1615d1453d421b5ddddcec60b7d8d6f956d0d3fd7a2d lib/codeql/swift/generated/PlatformVersionAvailabilitySpec.qll dc17b49a90a18a8f7607adf2433bc8f0c194fa3e803aa3822f809d4d4fbd6793 be48ea9f8ae17354c8508aaed24337a9e57ce01f288fece3dcecd99776cabcec lib/codeql/swift/generated/PureSynthConstructors.qll bc31a6c4d142fa3fbdcae69d5ba6f1cec00eb9ad92b46c8d7b91ebfa7ef6c1f4 bc31a6c4d142fa3fbdcae69d5ba6f1cec00eb9ad92b46c8d7b91ebfa7ef6c1f4 lib/codeql/swift/generated/Raw.qll 96d5f8778f25cd396b5cc56c38dce597c5a9a5c2b1e9ed8b9a4d2eca89e49323 d65072b5c508dad1dd813e19f7431087d8bfc0e5d85aa3d19beffbcbbec585ec @@ -1043,7 +1043,7 @@ test/extractor-tests/generated/KeyPathComponent/KeyPathComponent_getSubscriptArg test/extractor-tests/generated/KeyPathComponent/KeyPathComponent_getTupleIndex.ql c55da7366086c0a927e23fbaf5cb2ebab50ac4eafde206b59efad96edd0545ff dc1cd851d68fd307a1f101a4cd94ec971475bdd2b26fb82a8566b4a99d0aa505 test/extractor-tests/generated/OtherAvailabilitySpec/MISSING_SOURCE.txt 35fb32ea5393152eb7a875b20b4e3e4b8c7a997a8959c32417140d57a16a052d 35fb32ea5393152eb7a875b20b4e3e4b8c7a997a8959c32417140d57a16a052d test/extractor-tests/generated/PlatformVersionAvailabilitySpec/MISSING_SOURCE.txt 35fb32ea5393152eb7a875b20b4e3e4b8c7a997a8959c32417140d57a16a052d 35fb32ea5393152eb7a875b20b4e3e4b8c7a997a8959c32417140d57a16a052d -test/extractor-tests/generated/decl/Accessor/Accessor.ql fb3e3b8096ed6f9de299f73383194520bcd0a96f4e215e1945456e0c2beaa2a0 cc66788194840b4c5c57e9cbd8f7072655fa9947f2da36cf9f59463ea070d409 +test/extractor-tests/generated/decl/Accessor/Accessor.ql 60bcf87ed351242567504396baf88eb041d21f16564ed64a67aa0b3ed0d148d8 74687e423971ec7055aba12b5a58a4bae3ddf51ea17f83f7a142cbca6c48d309 test/extractor-tests/generated/decl/Accessor/Accessor_getBody.ql 89660097038fe210b72373ed6ea4d6e6cc6505a45d8e0892b53e265bb1d2c398 9abec75977ca2f5328ff6730b3b40c264cc385961c2685351c869a359c5afeb4 test/extractor-tests/generated/decl/Accessor/Accessor_getCapture.ql 15011012186c6111d5eace2f5ad34747adaa5e84d044a98bb7da17b08695c69d 60411e7886e5cfc211c10881b6e061e02597690eccd714fff2a51874e4088d27 test/extractor-tests/generated/decl/Accessor/Accessor_getGenericTypeParam.ql 92b13b69f0b64abd16eecbf38eae4ff1a7006617639b80c0f22b651caeb40da6 06113682dda3ff88688b6689953e21b0b8ead5d019fc56ff7752b19b46711a4d @@ -1081,7 +1081,7 @@ test/extractor-tests/generated/decl/EnumDecl/EnumDecl_getMember.ql 5a4de48886bd8 test/extractor-tests/generated/decl/EnumDecl/EnumElementDecl.ql bd00c56cf1d05707f29c4f31defc6a3ff25f41928688c2be992a92d4c5624859 3bd69b639f883e164fa6d1d4a3ad18aed86f88b93358636c5e118f1ca96eb878 test/extractor-tests/generated/decl/EnumDecl/EnumElementDecl_getMember.ql e40260a5689d26c9bf2dfe17617e8a1480c720523e47f50273aeb7160a69f244 7ee294373de5bd22fc2c64a7acae4a94e9bdebf808c8e73a16a57b0dc3c295ac test/extractor-tests/generated/decl/EnumDecl/EnumElementDecl_getParam.ql a507e55efcc13544d93c91c343a3df14b79114f259cb4dbec56d6f56e804d4e8 587bf774b4c4451ff873506624ccd379dd2fd7689460b4e24af96fbccadc0e6d -test/extractor-tests/generated/decl/ExtensionDecl/ExtensionDecl.ql 11a15a67f7b19e3d1fb5a2616420c23fde400848c8dbfcadb8e52a40130b92ad 502831fd3465ff06eba1dc6be365bee5fc2fcec96be44967a6579bbbdd395a32 +test/extractor-tests/generated/decl/ExtensionDecl/ExtensionDecl.ql be2fa0832e1d01c2f4c0ac09fb1075166b05d19fa46828f10e81d9ca4aac3033 b5bc89103f2f04964a8e66835f81a52184e9d890f80ba27c8aef5bfcf65daee7 test/extractor-tests/generated/decl/ExtensionDecl/ExtensionDecl_getGenericTypeParam.ql bc57c794b106df3b9da47432ef3241849145d5e86ebf601cec08729f05e15956 bce4e2150ca2efe495e544a3a074c7ebc81f68bd2f3280a76f565d31acb091e2 test/extractor-tests/generated/decl/ExtensionDecl/ExtensionDecl_getMember.ql 0883fcc244e06329738f242a36d0c33ee5228500e8f9d4508e4b5b32d863edfe 4fa99729397085d19b25415ed40e62dc2a555d7581c6c98895e635f7d502689b test/extractor-tests/generated/decl/ExtensionDecl/ExtensionDecl_getProtocol.ql 040731ade8fb6cfe989fb62874c405a24256ca3947251d6799c8f53e144d2ce9 d5b37f663a19fba137735b85c070405d687d3e84c1850d93f43b50f77524357f @@ -1108,7 +1108,7 @@ test/extractor-tests/generated/decl/ModuleDecl/ModuleDecl_getAnExportedModule.ql test/extractor-tests/generated/decl/ModuleDecl/ModuleDecl_getAnImportedModule.ql d85c12bc7fe2732594ca27cf85de1649ab3ecb64c49439b48a18353386e250ea ed58651f5d1c767dcb17a679a780d4248d5de779d7fb1ffff13675867071ef6f test/extractor-tests/generated/decl/ModuleDecl/ModuleDecl_getInheritedType.ql 624711472413d1bbcdcd01a805667bdebce7f4959f39016a5b4df60610eed019 e30f3e09e160784ae6170e05075b10cc03df7d3e44b9647be193abd7733e19e9 test/extractor-tests/generated/decl/ModuleDecl/ModuleDecl_getMember.ql 2e6fad621c4a301b124336977ba5a6489e143d37e33deb330b993a06bf263069 c4622cd12ecf94fa1e413413ee3e5d38625d8c8ea6694473baf6b6e05d222ad9 -test/extractor-tests/generated/decl/NamedFunction/NamedFunction.ql bf58ac96d6fbc3294c5780000539486d52b7ed9ff797647b83c5914ee9c12cf2 5294555db2567fd78e7580ff899819ed4bb3000c8046a806828ae67098b3e743 +test/extractor-tests/generated/decl/NamedFunction/NamedFunction.ql b4cd0ecfb1768898b8115874e168bbe780c06ddd09f8337f99096dd2c80af090 838b2d5e94f632b8f2f0b89eb5c06fed515ff82c78f5dd2063610485f4d949dc test/extractor-tests/generated/decl/NamedFunction/NamedFunction_getBody.ql 365c3f2bcf802880455e0523bc6d992740d08119cc307751f6accb031f60a8b9 0f0b9ff9c0dbebb0b7b177e01d9082647f5544fa4cb9fd4c2ac228538f37cd87 test/extractor-tests/generated/decl/NamedFunction/NamedFunction_getCapture.ql 25d10d0d28cdf5eb73dc2be56eaefed13ccd9bf5808480a950f9d91a26db93e9 fcb2af9a0032c60d08a2025688886905c5f3792a6d017f0552bdfbb8c736c118 test/extractor-tests/generated/decl/NamedFunction/NamedFunction_getGenericTypeParam.ql 60873ee0c149f7a66572c79a7e86e2c15e7b13bae618988e6a70b7f62ea01b65 be346e023edd258cd050645b6bcb2b1dfbab8a3012b473abd33ea1386471a4ea diff --git a/swift/ql/lib/codeql/swift/generated/ParentChild.qll b/swift/ql/lib/codeql/swift/generated/ParentChild.qll index 49ffc37a473c..4185644abe17 100644 --- a/swift/ql/lib/codeql/swift/generated/ParentChild.qll +++ b/swift/ql/lib/codeql/swift/generated/ParentChild.qll @@ -10,235 +10,60 @@ import codeql.swift.elements.expr.internal.InitializerRefCallExpr import codeql.swift.elements.expr.internal.SelfApplyExpr 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 getImmediateChildOfComment(Comment 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) - ) - ) + none() } 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) - ) - ) + none() } 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) - ) - ) + none() } private Element getImmediateChildOfDiagnostics( Diagnostics 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 getImmediateChildOfErrorElement( - ErrorElement 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) - ) - ) + none() } 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) - ) - ) + none() } 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) - ) - ) + none() } private Element getImmediateChildOfAvailabilityInfo( AvailabilityInfo e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nSpec | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nSpec | + n = 0 and nSpec = n + 1 + max(int i | i = -1 or exists(e.getSpec(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getSpec(index - n) and partialPredicateCall = "Spec(" + (index - n).toString() + ")" ) ) } - private Element getImmediateChildOfAvailabilitySpec( - AvailabilitySpec 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 getImmediateChildOfCallable(Callable e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nSelfParam, int nParam, int nBody, int nCapture | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - nSelfParam = n + 1 and - nParam = nSelfParam + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and - nBody = nParam + 1 and - nCapture = nBody + 1 + max(int i | i = -1 or exists(e.getCapture(i)) | i) and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or - index = n and result = e.getSelfParam() and partialPredicateCall = "SelfParam()" - or - result = e.getParam(index - nSelfParam) and - partialPredicateCall = "Param(" + (index - nSelfParam).toString() + ")" - or - index = nParam and result = e.getBody() and partialPredicateCall = "Body()" - or - result = e.getCapture(index - nBody) and - partialPredicateCall = "Capture(" + (index - nBody).toString() + ")" - ) - ) - } - private Element getImmediateChildOfKeyPathComponent( KeyPathComponent e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nSubscriptArgument | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nSubscriptArgument | + n = 0 and nSubscriptArgument = n + 1 + max(int i | i = -1 or exists(e.getSubscriptArgument(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getSubscriptArgument(index - n) and partialPredicateCall = "SubscriptArgument(" + (index - n).toString() + ")" ) @@ -246,32 +71,18 @@ private module Impl { } private Element getImmediateChildOfMacroRole(MacroRole 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) - ) - ) + none() } private Element getImmediateChildOfUnspecifiedElement( UnspecifiedElement e, int index, string partialPredicateCall ) { - exists(int b, int bErrorElement, int n, int nChild | - b = 0 and - bErrorElement = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and + exists(int n, int nChild | + n = 0 and nChild = n + 1 + max(int i | i = -1 or exists(e.getImmediateChild(i)) | i) and ( none() or - result = getImmediateChildOfErrorElement(e, index - b, partialPredicateCall) - or result = e.getImmediateChild(index - n) and partialPredicateCall = "Child(" + (index - n).toString() + ")" ) @@ -281,82 +92,26 @@ private module Impl { private Element getImmediateChildOfOtherAvailabilitySpec( OtherAvailabilitySpec e, int index, string partialPredicateCall ) { - exists(int b, int bAvailabilitySpec, int n | - b = 0 and - bAvailabilitySpec = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAvailabilitySpec(e, i, _)) | i) and - n = bAvailabilitySpec and - ( - none() - or - result = getImmediateChildOfAvailabilitySpec(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfPlatformVersionAvailabilitySpec( PlatformVersionAvailabilitySpec e, int index, string partialPredicateCall ) { - exists(int b, int bAvailabilitySpec, int n | - b = 0 and - bAvailabilitySpec = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAvailabilitySpec(e, i, _)) | i) and - n = bAvailabilitySpec and - ( - none() - or - result = getImmediateChildOfAvailabilitySpec(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDecl(Decl e, int index, string partialPredicateCall) { - exists(int b, int bAstNode, int n, int nMember | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and - nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and - ( - none() - or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or - result = e.getMember(index - n) and - partialPredicateCall = "Member(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfGenericContext( - GenericContext e, int index, string partialPredicateCall - ) { - exists(int b, int bElement, int n, int nGenericTypeParam | - b = 0 and - bElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfElement(e, i, _)) | i) and - n = bElement and - nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and - ( - none() - or - result = getImmediateChildOfElement(e, index - b, partialPredicateCall) - or - result = e.getGenericTypeParam(index - n) and - partialPredicateCall = "GenericTypeParam(" + (index - n).toString() + ")" - ) - ) + none() } private Element getImmediateChildOfCapturedDecl( CapturedDecl e, int index, string partialPredicateCall ) { - exists(int b, int bDecl, int n | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and + exists(int n, int nMember | + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" ) ) } @@ -364,14 +119,14 @@ private module Impl { private Element getImmediateChildOfEnumCaseDecl( EnumCaseDecl e, int index, string partialPredicateCall ) { - exists(int b, int bDecl, int n | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and + exists(int n, int nMember | + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" ) ) } @@ -379,19 +134,18 @@ private module Impl { private Element getImmediateChildOfExtensionDecl( ExtensionDecl e, int index, string partialPredicateCall ) { - exists(int b, int bGenericContext, int bDecl, int n | - b = 0 and - bGenericContext = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericContext(e, i, _)) | i) and - bDecl = - bGenericContext + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and + exists(int n, int nGenericTypeParam, int nMember | + n = 0 and + nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and + nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfGenericContext(e, index - b, partialPredicateCall) + result = e.getGenericTypeParam(index - n) and + partialPredicateCall = "GenericTypeParam(" + (index - n).toString() + ")" or - result = getImmediateChildOfDecl(e, index - bGenericContext, partialPredicateCall) + result = e.getMember(index - nGenericTypeParam) and + partialPredicateCall = "Member(" + (index - nGenericTypeParam).toString() + ")" ) ) } @@ -399,27 +153,27 @@ private module Impl { private Element getImmediateChildOfIfConfigDecl( IfConfigDecl e, int index, string partialPredicateCall ) { - exists(int b, int bDecl, int n | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and + exists(int n, int nMember | + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" ) ) } private Element getImmediateChildOfImportDecl(ImportDecl e, int index, string partialPredicateCall) { - exists(int b, int bDecl, int n | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and + exists(int n, int nMember | + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" ) ) } @@ -427,29 +181,14 @@ private module Impl { private Element getImmediateChildOfMissingMemberDecl( MissingMemberDecl e, int index, string partialPredicateCall ) { - exists(int b, int bDecl, int n | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and - ( - none() - or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfOperatorDecl( - OperatorDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bDecl, int n | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and + exists(int n, int nMember | + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" ) ) } @@ -457,19 +196,19 @@ private module Impl { private Element getImmediateChildOfPatternBindingDecl( PatternBindingDecl e, int index, string partialPredicateCall ) { - exists(int b, int bDecl, int n, int nInit, int nPattern | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and - nInit = n + 1 + max(int i | i = -1 or exists(e.getImmediateInit(i)) | i) and + exists(int n, int nMember, int nInit, int nPattern | + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nInit = nMember + 1 + max(int i | i = -1 or exists(e.getImmediateInit(i)) | i) and nPattern = nInit + 1 + max(int i | i = -1 or exists(e.getImmediatePattern(i)) | i) and ( none() or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" or - result = e.getImmediateInit(index - n) and - partialPredicateCall = "Init(" + (index - n).toString() + ")" + result = e.getImmediateInit(index - nMember) and + partialPredicateCall = "Init(" + (index - nMember).toString() + ")" or result = e.getImmediatePattern(index - nInit) and partialPredicateCall = "Pattern(" + (index - nInit).toString() + ")" @@ -480,17 +219,17 @@ private module Impl { private Element getImmediateChildOfPoundDiagnosticDecl( PoundDiagnosticDecl e, int index, string partialPredicateCall ) { - exists(int b, int bDecl, int n, int nMessage | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and - nMessage = n + 1 and + exists(int n, int nMember, int nMessage | + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nMessage = nMember + 1 and ( none() or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" or - index = n and result = e.getImmediateMessage() and partialPredicateCall = "Message()" + index = nMember and result = e.getImmediateMessage() and partialPredicateCall = "Message()" ) ) } @@ -498,14 +237,14 @@ private module Impl { private Element getImmediateChildOfPrecedenceGroupDecl( PrecedenceGroupDecl e, int index, string partialPredicateCall ) { - exists(int b, int bDecl, int n | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and + exists(int n, int nMember | + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" ) ) } @@ -513,49 +252,17 @@ private module Impl { private Element getImmediateChildOfTopLevelCodeDecl( TopLevelCodeDecl e, int index, string partialPredicateCall ) { - exists(int b, int bDecl, int n, int nBody | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and - nBody = n + 1 and - ( - none() - or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) - or - index = n and result = e.getBody() and partialPredicateCall = "Body()" - ) - ) - } - - private Element getImmediateChildOfValueDecl(ValueDecl e, int index, string partialPredicateCall) { - exists(int b, int bDecl, int n | - b = 0 and - bDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDecl(e, i, _)) | i) and - n = bDecl and - ( - none() - or - result = getImmediateChildOfDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAbstractStorageDecl( - AbstractStorageDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bValueDecl, int n, int nAccessor | - b = 0 and - bValueDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfValueDecl(e, i, _)) | i) and - n = bValueDecl and - nAccessor = n + 1 + max(int i | i = -1 or exists(e.getAccessor(i)) | i) and + exists(int n, int nMember, int nBody | + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nBody = nMember + 1 and ( none() or - result = getImmediateChildOfValueDecl(e, index - b, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" or - result = e.getAccessor(index - n) and - partialPredicateCall = "Accessor(" + (index - n).toString() + ")" + index = nMember and result = e.getBody() and partialPredicateCall = "Body()" ) ) } @@ -563,41 +270,18 @@ private module Impl { private Element getImmediateChildOfEnumElementDecl( EnumElementDecl e, int index, string partialPredicateCall ) { - exists(int b, int bValueDecl, int n, int nParam | - b = 0 and - bValueDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfValueDecl(e, i, _)) | i) and - n = bValueDecl and - nParam = n + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and - ( - none() - or - result = getImmediateChildOfValueDecl(e, index - b, partialPredicateCall) - or - result = e.getParam(index - n) and - partialPredicateCall = "Param(" + (index - n).toString() + ")" - ) - ) - } - - private Element getImmediateChildOfFunction(Function e, int index, string partialPredicateCall) { - exists(int b, int bGenericContext, int bValueDecl, int bCallable, int n | - b = 0 and - bGenericContext = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericContext(e, i, _)) | i) and - bValueDecl = - bGenericContext + 1 + - max(int i | i = -1 or exists(getImmediateChildOfValueDecl(e, i, _)) | i) and - bCallable = - bValueDecl + 1 + max(int i | i = -1 or exists(getImmediateChildOfCallable(e, i, _)) | i) and - n = bCallable and + exists(int n, int nMember, int nParam | + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nParam = nMember + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and ( none() or - result = getImmediateChildOfGenericContext(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfValueDecl(e, index - bGenericContext, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" or - result = getImmediateChildOfCallable(e, index - bValueDecl, partialPredicateCall) + result = e.getParam(index - nMember) and + partialPredicateCall = "Param(" + (index - nMember).toString() + ")" ) ) } @@ -605,34 +289,31 @@ private module Impl { private Element getImmediateChildOfInfixOperatorDecl( InfixOperatorDecl e, int index, string partialPredicateCall ) { - exists(int b, int bOperatorDecl, int n | - b = 0 and - bOperatorDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfOperatorDecl(e, i, _)) | i) and - n = bOperatorDecl and + exists(int n, int nMember | + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfOperatorDecl(e, index - b, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" ) ) } private Element getImmediateChildOfMacroDecl(MacroDecl e, int index, string partialPredicateCall) { - exists(int b, int bGenericContext, int bValueDecl, int n | - b = 0 and - bGenericContext = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericContext(e, i, _)) | i) and - bValueDecl = - bGenericContext + 1 + - max(int i | i = -1 or exists(getImmediateChildOfValueDecl(e, i, _)) | i) and - n = bValueDecl and + exists(int n, int nGenericTypeParam, int nMember | + n = 0 and + nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and + nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfGenericContext(e, index - b, partialPredicateCall) + result = e.getGenericTypeParam(index - n) and + partialPredicateCall = "GenericTypeParam(" + (index - n).toString() + ")" or - result = getImmediateChildOfValueDecl(e, index - bGenericContext, partialPredicateCall) + result = e.getMember(index - nGenericTypeParam) and + partialPredicateCall = "Member(" + (index - nGenericTypeParam).toString() + ")" ) ) } @@ -640,15 +321,14 @@ private module Impl { private Element getImmediateChildOfPostfixOperatorDecl( PostfixOperatorDecl e, int index, string partialPredicateCall ) { - exists(int b, int bOperatorDecl, int n | - b = 0 and - bOperatorDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfOperatorDecl(e, i, _)) | i) and - n = bOperatorDecl and + exists(int n, int nMember | + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfOperatorDecl(e, index - b, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" ) ) } @@ -656,172 +336,202 @@ private module Impl { private Element getImmediateChildOfPrefixOperatorDecl( PrefixOperatorDecl e, int index, string partialPredicateCall ) { - exists(int b, int bOperatorDecl, int n | - b = 0 and - bOperatorDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfOperatorDecl(e, i, _)) | i) and - n = bOperatorDecl and - ( - none() - or - result = getImmediateChildOfOperatorDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfTypeDecl(TypeDecl e, int index, string partialPredicateCall) { - exists(int b, int bValueDecl, int n | - b = 0 and - bValueDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfValueDecl(e, i, _)) | i) and - n = bValueDecl and + exists(int n, int nMember | + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfValueDecl(e, index - b, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" ) ) } - private Element getImmediateChildOfAbstractTypeParamDecl( - AbstractTypeParamDecl e, int index, string partialPredicateCall + private Element getImmediateChildOfDeinitializer( + Deinitializer e, int index, string partialPredicateCall ) { - exists(int b, int bTypeDecl, int n | - b = 0 and - bTypeDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeDecl(e, i, _)) | i) and - n = bTypeDecl and + exists( + int n, int nGenericTypeParam, int nMember, int nSelfParam, int nParam, int nBody, int nCapture + | + n = 0 and + nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and + nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nSelfParam = nMember + 1 and + nParam = nSelfParam + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and + nBody = nParam + 1 and + nCapture = nBody + 1 + max(int i | i = -1 or exists(e.getCapture(i)) | i) and ( none() or - result = getImmediateChildOfTypeDecl(e, index - b, partialPredicateCall) + result = e.getGenericTypeParam(index - n) and + partialPredicateCall = "GenericTypeParam(" + (index - n).toString() + ")" + or + result = e.getMember(index - nGenericTypeParam) and + partialPredicateCall = "Member(" + (index - nGenericTypeParam).toString() + ")" + or + index = nMember and result = e.getSelfParam() and partialPredicateCall = "SelfParam()" + or + result = e.getParam(index - nSelfParam) and + partialPredicateCall = "Param(" + (index - nSelfParam).toString() + ")" + or + index = nParam and result = e.getBody() and partialPredicateCall = "Body()" + or + result = e.getCapture(index - nBody) and + partialPredicateCall = "Capture(" + (index - nBody).toString() + ")" ) ) } - private Element getImmediateChildOfAccessorOrNamedFunction( - AccessorOrNamedFunction e, int index, string partialPredicateCall - ) { - exists(int b, int bFunction, int n | - b = 0 and - bFunction = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfFunction(e, i, _)) | i) and - n = bFunction and + private Element getImmediateChildOfInitializer( + Initializer e, int index, string partialPredicateCall + ) { + exists( + int n, int nGenericTypeParam, int nMember, int nSelfParam, int nParam, int nBody, int nCapture + | + n = 0 and + nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and + nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nSelfParam = nMember + 1 and + nParam = nSelfParam + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and + nBody = nParam + 1 and + nCapture = nBody + 1 + max(int i | i = -1 or exists(e.getCapture(i)) | i) and ( none() or - result = getImmediateChildOfFunction(e, index - b, partialPredicateCall) + result = e.getGenericTypeParam(index - n) and + partialPredicateCall = "GenericTypeParam(" + (index - n).toString() + ")" + or + result = e.getMember(index - nGenericTypeParam) and + partialPredicateCall = "Member(" + (index - nGenericTypeParam).toString() + ")" + or + index = nMember and result = e.getSelfParam() and partialPredicateCall = "SelfParam()" + or + result = e.getParam(index - nSelfParam) and + partialPredicateCall = "Param(" + (index - nSelfParam).toString() + ")" + or + index = nParam and result = e.getBody() and partialPredicateCall = "Body()" + or + result = e.getCapture(index - nBody) and + partialPredicateCall = "Capture(" + (index - nBody).toString() + ")" ) ) } - private Element getImmediateChildOfDeinitializer( - Deinitializer e, int index, string partialPredicateCall - ) { - exists(int b, int bFunction, int n | - b = 0 and - bFunction = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfFunction(e, i, _)) | i) and - n = bFunction and + private Element getImmediateChildOfModuleDecl(ModuleDecl e, int index, string partialPredicateCall) { + exists(int n, int nMember | + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfFunction(e, index - b, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" ) ) } - private Element getImmediateChildOfGenericTypeDecl( - GenericTypeDecl e, int index, string partialPredicateCall + private Element getImmediateChildOfSubscriptDecl( + SubscriptDecl e, int index, string partialPredicateCall ) { - exists(int b, int bGenericContext, int bTypeDecl, int n | - b = 0 and - bGenericContext = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericContext(e, i, _)) | i) and - bTypeDecl = - bGenericContext + 1 + - max(int i | i = -1 or exists(getImmediateChildOfTypeDecl(e, i, _)) | i) and - n = bTypeDecl and + exists(int n, int nMember, int nAccessor, int nGenericTypeParam, int nParam | + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nAccessor = nMember + 1 + max(int i | i = -1 or exists(e.getAccessor(i)) | i) and + nGenericTypeParam = + nAccessor + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and + nParam = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and ( none() or - result = getImmediateChildOfGenericContext(e, index - b, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" + or + result = e.getAccessor(index - nMember) and + partialPredicateCall = "Accessor(" + (index - nMember).toString() + ")" or - result = getImmediateChildOfTypeDecl(e, index - bGenericContext, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfInitializer( - Initializer e, int index, string partialPredicateCall - ) { - exists(int b, int bFunction, int n | - b = 0 and - bFunction = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfFunction(e, i, _)) | i) and - n = bFunction and - ( - none() + result = e.getGenericTypeParam(index - nAccessor) and + partialPredicateCall = "GenericTypeParam(" + (index - nAccessor).toString() + ")" or - result = getImmediateChildOfFunction(e, index - b, partialPredicateCall) + result = e.getParam(index - nGenericTypeParam) and + partialPredicateCall = "Param(" + (index - nGenericTypeParam).toString() + ")" ) ) } - private Element getImmediateChildOfModuleDecl(ModuleDecl e, int index, string partialPredicateCall) { - exists(int b, int bTypeDecl, int n | - b = 0 and - bTypeDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfTypeDecl(e, i, _)) | i) and - n = bTypeDecl and + private Element getImmediateChildOfAccessor(Accessor e, int index, string partialPredicateCall) { + exists( + int n, int nGenericTypeParam, int nMember, int nSelfParam, int nParam, int nBody, int nCapture + | + n = 0 and + nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and + nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nSelfParam = nMember + 1 and + nParam = nSelfParam + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and + nBody = nParam + 1 and + nCapture = nBody + 1 + max(int i | i = -1 or exists(e.getCapture(i)) | i) and ( none() or - result = getImmediateChildOfTypeDecl(e, index - b, partialPredicateCall) + result = e.getGenericTypeParam(index - n) and + partialPredicateCall = "GenericTypeParam(" + (index - n).toString() + ")" + or + result = e.getMember(index - nGenericTypeParam) and + partialPredicateCall = "Member(" + (index - nGenericTypeParam).toString() + ")" + or + index = nMember and result = e.getSelfParam() and partialPredicateCall = "SelfParam()" + or + result = e.getParam(index - nSelfParam) and + partialPredicateCall = "Param(" + (index - nSelfParam).toString() + ")" + or + index = nParam and result = e.getBody() and partialPredicateCall = "Body()" + or + result = e.getCapture(index - nBody) and + partialPredicateCall = "Capture(" + (index - nBody).toString() + ")" ) ) } - private Element getImmediateChildOfSubscriptDecl( - SubscriptDecl e, int index, string partialPredicateCall + private Element getImmediateChildOfAssociatedTypeDecl( + AssociatedTypeDecl e, int index, string partialPredicateCall ) { - exists(int b, int bAbstractStorageDecl, int bGenericContext, int n, int nParam | - b = 0 and - bAbstractStorageDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAbstractStorageDecl(e, i, _)) | i) and - bGenericContext = - bAbstractStorageDecl + 1 + - max(int i | i = -1 or exists(getImmediateChildOfGenericContext(e, i, _)) | i) and - n = bGenericContext and - nParam = n + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and + exists(int n, int nMember | + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfAbstractStorageDecl(e, index - b, partialPredicateCall) - or - result = - getImmediateChildOfGenericContext(e, index - bAbstractStorageDecl, partialPredicateCall) - or - result = e.getParam(index - n) and - partialPredicateCall = "Param(" + (index - n).toString() + ")" + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" ) ) } - private Element getImmediateChildOfVarDecl(VarDecl e, int index, string partialPredicateCall) { + private Element getImmediateChildOfConcreteVarDecl( + ConcreteVarDecl e, int index, string partialPredicateCall + ) { exists( - int b, int bAbstractStorageDecl, int n, int nPropertyWrapperBackingVarBinding, + int n, int nMember, int nAccessor, int nPropertyWrapperBackingVarBinding, int nPropertyWrapperBackingVar, int nPropertyWrapperProjectionVarBinding, int nPropertyWrapperProjectionVar | - b = 0 and - bAbstractStorageDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAbstractStorageDecl(e, i, _)) | i) and - n = bAbstractStorageDecl and - nPropertyWrapperBackingVarBinding = n + 1 and + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nAccessor = nMember + 1 + max(int i | i = -1 or exists(e.getAccessor(i)) | i) and + nPropertyWrapperBackingVarBinding = nAccessor + 1 and nPropertyWrapperBackingVar = nPropertyWrapperBackingVarBinding + 1 and nPropertyWrapperProjectionVarBinding = nPropertyWrapperBackingVar + 1 and nPropertyWrapperProjectionVar = nPropertyWrapperProjectionVarBinding + 1 and ( none() or - result = getImmediateChildOfAbstractStorageDecl(e, index - b, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" or - index = n and + result = e.getAccessor(index - nMember) and + partialPredicateCall = "Accessor(" + (index - nMember).toString() + ")" + or + index = nAccessor and result = e.getPropertyWrapperBackingVarBinding() and partialPredicateCall = "PropertyWrapperBackingVarBinding()" or @@ -840,64 +550,17 @@ private module Impl { ) } - private Element getImmediateChildOfAccessor(Accessor e, int index, string partialPredicateCall) { - exists(int b, int bAccessorOrNamedFunction, int n | - b = 0 and - bAccessorOrNamedFunction = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfAccessorOrNamedFunction(e, i, _)) | i) and - n = bAccessorOrNamedFunction and - ( - none() - or - result = getImmediateChildOfAccessorOrNamedFunction(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAssociatedTypeDecl( - AssociatedTypeDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bAbstractTypeParamDecl, int n | - b = 0 and - bAbstractTypeParamDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAbstractTypeParamDecl(e, i, _)) | i) and - n = bAbstractTypeParamDecl and - ( - none() - or - result = getImmediateChildOfAbstractTypeParamDecl(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfConcreteVarDecl( - ConcreteVarDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bVarDecl, int n | - b = 0 and - bVarDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfVarDecl(e, i, _)) | i) and - n = bVarDecl and - ( - none() - or - result = getImmediateChildOfVarDecl(e, index - b, partialPredicateCall) - ) - ) - } - private Element getImmediateChildOfGenericTypeParamDecl( GenericTypeParamDecl e, int index, string partialPredicateCall ) { - exists(int b, int bAbstractTypeParamDecl, int n | - b = 0 and - bAbstractTypeParamDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAbstractTypeParamDecl(e, i, _)) | i) and - n = bAbstractTypeParamDecl and + exists(int n, int nMember | + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfAbstractTypeParamDecl(e, index - b, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" ) ) } @@ -905,32 +568,34 @@ private module Impl { private Element getImmediateChildOfNamedFunction( NamedFunction e, int index, string partialPredicateCall ) { - exists(int b, int bAccessorOrNamedFunction, int n | - b = 0 and - bAccessorOrNamedFunction = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfAccessorOrNamedFunction(e, i, _)) | i) and - n = bAccessorOrNamedFunction and + exists( + int n, int nGenericTypeParam, int nMember, int nSelfParam, int nParam, int nBody, int nCapture + | + n = 0 and + nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and + nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nSelfParam = nMember + 1 and + nParam = nSelfParam + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and + nBody = nParam + 1 and + nCapture = nBody + 1 + max(int i | i = -1 or exists(e.getCapture(i)) | i) and ( none() or - result = getImmediateChildOfAccessorOrNamedFunction(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfNominalTypeDecl( - NominalTypeDecl e, int index, string partialPredicateCall - ) { - exists(int b, int bGenericTypeDecl, int n | - b = 0 and - bGenericTypeDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericTypeDecl(e, i, _)) | i) and - n = bGenericTypeDecl and - ( - none() + result = e.getGenericTypeParam(index - n) and + partialPredicateCall = "GenericTypeParam(" + (index - n).toString() + ")" + or + result = e.getMember(index - nGenericTypeParam) and + partialPredicateCall = "Member(" + (index - nGenericTypeParam).toString() + ")" + or + index = nMember and result = e.getSelfParam() and partialPredicateCall = "SelfParam()" or - result = getImmediateChildOfGenericTypeDecl(e, index - b, partialPredicateCall) + result = e.getParam(index - nSelfParam) and + partialPredicateCall = "Param(" + (index - nSelfParam).toString() + ")" + or + index = nParam and result = e.getBody() and partialPredicateCall = "Body()" + or + result = e.getCapture(index - nBody) and + partialPredicateCall = "Capture(" + (index - nBody).toString() + ")" ) ) } @@ -938,35 +603,64 @@ private module Impl { private Element getImmediateChildOfOpaqueTypeDecl( OpaqueTypeDecl e, int index, string partialPredicateCall ) { - exists(int b, int bGenericTypeDecl, int n | - b = 0 and - bGenericTypeDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericTypeDecl(e, i, _)) | i) and - n = bGenericTypeDecl and + exists(int n, int nGenericTypeParam, int nMember | + n = 0 and + nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and + nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfGenericTypeDecl(e, index - b, partialPredicateCall) + result = e.getGenericTypeParam(index - n) and + partialPredicateCall = "GenericTypeParam(" + (index - n).toString() + ")" + or + result = e.getMember(index - nGenericTypeParam) and + partialPredicateCall = "Member(" + (index - nGenericTypeParam).toString() + ")" ) ) } private Element getImmediateChildOfParamDecl(ParamDecl e, int index, string partialPredicateCall) { exists( - int b, int bVarDecl, int n, int nPropertyWrapperLocalWrappedVarBinding, + int n, int nMember, int nAccessor, int nPropertyWrapperBackingVarBinding, + int nPropertyWrapperBackingVar, int nPropertyWrapperProjectionVarBinding, + int nPropertyWrapperProjectionVar, int nPropertyWrapperLocalWrappedVarBinding, int nPropertyWrapperLocalWrappedVar | - b = 0 and - bVarDecl = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfVarDecl(e, i, _)) | i) and - n = bVarDecl and - nPropertyWrapperLocalWrappedVarBinding = n + 1 and + n = 0 and + nMember = n + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and + nAccessor = nMember + 1 + max(int i | i = -1 or exists(e.getAccessor(i)) | i) and + nPropertyWrapperBackingVarBinding = nAccessor + 1 and + nPropertyWrapperBackingVar = nPropertyWrapperBackingVarBinding + 1 and + nPropertyWrapperProjectionVarBinding = nPropertyWrapperBackingVar + 1 and + nPropertyWrapperProjectionVar = nPropertyWrapperProjectionVarBinding + 1 and + nPropertyWrapperLocalWrappedVarBinding = nPropertyWrapperProjectionVar + 1 and nPropertyWrapperLocalWrappedVar = nPropertyWrapperLocalWrappedVarBinding + 1 and ( none() or - result = getImmediateChildOfVarDecl(e, index - b, partialPredicateCall) + result = e.getMember(index - n) and + partialPredicateCall = "Member(" + (index - n).toString() + ")" or - index = n and + result = e.getAccessor(index - nMember) and + partialPredicateCall = "Accessor(" + (index - nMember).toString() + ")" + or + index = nAccessor and + result = e.getPropertyWrapperBackingVarBinding() and + partialPredicateCall = "PropertyWrapperBackingVarBinding()" + or + index = nPropertyWrapperBackingVarBinding and + result = e.getPropertyWrapperBackingVar() and + partialPredicateCall = "PropertyWrapperBackingVar()" + or + index = nPropertyWrapperBackingVar and + result = e.getPropertyWrapperProjectionVarBinding() and + partialPredicateCall = "PropertyWrapperProjectionVarBinding()" + or + index = nPropertyWrapperProjectionVarBinding and + result = e.getPropertyWrapperProjectionVar() and + partialPredicateCall = "PropertyWrapperProjectionVar()" + or + index = nPropertyWrapperProjectionVar and result = e.getPropertyWrapperLocalWrappedVarBinding() and partialPredicateCall = "PropertyWrapperLocalWrappedVarBinding()" or @@ -980,43 +674,52 @@ private module Impl { private Element getImmediateChildOfTypeAliasDecl( TypeAliasDecl e, int index, string partialPredicateCall ) { - exists(int b, int bGenericTypeDecl, int n | - b = 0 and - bGenericTypeDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericTypeDecl(e, i, _)) | i) and - n = bGenericTypeDecl and + exists(int n, int nGenericTypeParam, int nMember | + n = 0 and + nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and + nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfGenericTypeDecl(e, index - b, partialPredicateCall) + result = e.getGenericTypeParam(index - n) and + partialPredicateCall = "GenericTypeParam(" + (index - n).toString() + ")" + or + result = e.getMember(index - nGenericTypeParam) and + partialPredicateCall = "Member(" + (index - nGenericTypeParam).toString() + ")" ) ) } private Element getImmediateChildOfClassDecl(ClassDecl e, int index, string partialPredicateCall) { - exists(int b, int bNominalTypeDecl, int n | - b = 0 and - bNominalTypeDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalTypeDecl(e, i, _)) | i) and - n = bNominalTypeDecl and + exists(int n, int nGenericTypeParam, int nMember | + n = 0 and + nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and + nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfNominalTypeDecl(e, index - b, partialPredicateCall) + result = e.getGenericTypeParam(index - n) and + partialPredicateCall = "GenericTypeParam(" + (index - n).toString() + ")" + or + result = e.getMember(index - nGenericTypeParam) and + partialPredicateCall = "Member(" + (index - nGenericTypeParam).toString() + ")" ) ) } private Element getImmediateChildOfEnumDecl(EnumDecl e, int index, string partialPredicateCall) { - exists(int b, int bNominalTypeDecl, int n | - b = 0 and - bNominalTypeDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalTypeDecl(e, i, _)) | i) and - n = bNominalTypeDecl and + exists(int n, int nGenericTypeParam, int nMember | + n = 0 and + nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and + nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfNominalTypeDecl(e, index - b, partialPredicateCall) + result = e.getGenericTypeParam(index - n) and + partialPredicateCall = "GenericTypeParam(" + (index - n).toString() + ")" + or + result = e.getMember(index - nGenericTypeParam) and + partialPredicateCall = "Member(" + (index - nGenericTypeParam).toString() + ")" ) ) } @@ -1024,128 +727,73 @@ private module Impl { private Element getImmediateChildOfProtocolDecl( ProtocolDecl e, int index, string partialPredicateCall ) { - exists(int b, int bNominalTypeDecl, int n | - b = 0 and - bNominalTypeDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalTypeDecl(e, i, _)) | i) and - n = bNominalTypeDecl and + exists(int n, int nGenericTypeParam, int nMember | + n = 0 and + nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and + nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfNominalTypeDecl(e, index - b, partialPredicateCall) + result = e.getGenericTypeParam(index - n) and + partialPredicateCall = "GenericTypeParam(" + (index - n).toString() + ")" + or + result = e.getMember(index - nGenericTypeParam) and + partialPredicateCall = "Member(" + (index - nGenericTypeParam).toString() + ")" ) ) } private Element getImmediateChildOfStructDecl(StructDecl e, int index, string partialPredicateCall) { - exists(int b, int bNominalTypeDecl, int n | - b = 0 and - bNominalTypeDecl = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalTypeDecl(e, i, _)) | i) and - n = bNominalTypeDecl and + exists(int n, int nGenericTypeParam, int nMember | + n = 0 and + nGenericTypeParam = n + 1 + max(int i | i = -1 or exists(e.getGenericTypeParam(i)) | i) and + nMember = nGenericTypeParam + 1 + max(int i | i = -1 or exists(e.getMember(i)) | i) and ( none() or - result = getImmediateChildOfNominalTypeDecl(e, index - b, partialPredicateCall) + result = e.getGenericTypeParam(index - n) and + partialPredicateCall = "GenericTypeParam(" + (index - n).toString() + ")" + or + result = e.getMember(index - nGenericTypeParam) and + partialPredicateCall = "Member(" + (index - nGenericTypeParam).toString() + ")" ) ) } private Element getImmediateChildOfArgument(Argument e, int index, string partialPredicateCall) { - exists(int b, int bLocatable, int n, int nExpr | - b = 0 and - bLocatable = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocatable(e, i, _)) | i) and - n = bLocatable and + exists(int n, int nExpr | + n = 0 and nExpr = n + 1 and ( none() or - result = getImmediateChildOfLocatable(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateExpr() and partialPredicateCall = "Expr()" ) ) } - 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 getImmediateChildOfAnyTryExpr(AnyTryExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - private Element getImmediateChildOfAppliedPropertyWrapperExpr( AppliedPropertyWrapperExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nValue | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nValue | + n = 0 and nValue = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateValue() and partialPredicateCall = "Value()" ) ) } - private Element getImmediateChildOfApplyExpr(ApplyExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nFunction, int nArgument | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nFunction = n + 1 and - nArgument = nFunction + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateFunction() and partialPredicateCall = "Function()" - or - result = e.getArgument(index - nFunction) and - partialPredicateCall = "Argument(" + (index - nFunction).toString() + ")" - ) - ) - } - private Element getImmediateChildOfAssignExpr(AssignExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nDest, int nSource | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nDest, int nSource | + n = 0 and nDest = n + 1 and nSource = nDest + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateDest() and partialPredicateCall = "Dest()" or index = nDest and result = e.getImmediateSource() and partialPredicateCall = "Source()" @@ -1156,16 +804,12 @@ private module Impl { private Element getImmediateChildOfBindOptionalExpr( BindOptionalExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) @@ -1174,18 +818,14 @@ private module Impl { private Element getImmediateChildOfCaptureListExpr( CaptureListExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nBindingDecl, int nVariable, int nClosureBody | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nBindingDecl, int nVariable, int nClosureBody | + n = 0 and nBindingDecl = n + 1 + max(int i | i = -1 or exists(e.getBindingDecl(i)) | i) and nVariable = nBindingDecl + 1 + max(int i | i = -1 or exists(e.getVariable(i)) | i) and nClosureBody = nVariable + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getBindingDecl(index - n) and partialPredicateCall = "BindingDecl(" + (index - n).toString() + ")" or @@ -1199,69 +839,27 @@ private module Impl { ) } - private Element getImmediateChildOfClosureExpr( - ClosureExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int bCallable, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bCallable = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfCallable(e, i, _)) | i) and - n = bCallable and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfCallable(e, index - bExpr, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfCollectionExpr( - CollectionExpr 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 getImmediateChildOfConsumeExpr( ConsumeExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } private Element getImmediateChildOfCopyExpr(CopyExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) @@ -1270,77 +868,37 @@ private module Impl { private Element getImmediateChildOfCurrentContextIsolationExpr( CurrentContextIsolationExpr 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) - ) - ) + none() } private Element getImmediateChildOfDeclRefExpr( DeclRefExpr 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) - ) - ) + none() } private Element getImmediateChildOfDefaultArgumentExpr( DefaultArgumentExpr 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) - ) - ) + none() } private Element getImmediateChildOfDiscardAssignmentExpr( DiscardAssignmentExpr 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) - ) - ) + none() } private Element getImmediateChildOfDotSyntaxBaseIgnoredExpr( DotSyntaxBaseIgnoredExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nQualifier, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nQualifier, int nSubExpr | + n = 0 and nQualifier = n + 1 and nSubExpr = nQualifier + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateQualifier() and partialPredicateCall = "Qualifier()" or index = nQualifier and @@ -1353,16 +911,12 @@ private module Impl { private Element getImmediateChildOfDynamicTypeExpr( DynamicTypeExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nBase | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nBase | + n = 0 and nBase = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateBase() and partialPredicateCall = "Base()" ) ) @@ -1371,69 +925,30 @@ private module Impl { private Element getImmediateChildOfEnumIsCaseExpr( EnumIsCaseExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } private Element getImmediateChildOfErrorExpr(ErrorExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int bErrorElement, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bErrorElement = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfExplicitCastExpr( - ExplicitCastExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) + none() } private Element getImmediateChildOfExtractFunctionIsolationExpr( ExtractFunctionIsolationExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nFunctionExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nFunctionExpr | + n = 0 and nFunctionExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateFunctionExpr() and partialPredicateCall = "FunctionExpr()" @@ -1444,52 +959,26 @@ private module Impl { private Element getImmediateChildOfForceValueExpr( ForceValueExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - - private Element getImmediateChildOfIdentityExpr( - IdentityExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } private Element getImmediateChildOfIfExpr(IfExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nCondition, int nThenExpr, int nElseExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nCondition, int nThenExpr, int nElseExpr | + n = 0 and nCondition = n + 1 and nThenExpr = nCondition + 1 and nElseExpr = nThenExpr + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateCondition() and partialPredicateCall = "Condition()" or index = nCondition and @@ -1503,35 +992,13 @@ private module Impl { ) } - private Element getImmediateChildOfImplicitConversionExpr( - ImplicitConversionExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and - nSubExpr = n + 1 and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" - ) - ) - } - private Element getImmediateChildOfInOutExpr(InOutExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) @@ -1540,17 +1007,13 @@ private module Impl { private Element getImmediateChildOfKeyPathApplicationExpr( KeyPathApplicationExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nBase, int nKeyPath | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nBase, int nKeyPath | + n = 0 and nBase = n + 1 and nKeyPath = nBase + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateBase() and partialPredicateCall = "Base()" or index = nBase and result = e.getImmediateKeyPath() and partialPredicateCall = "KeyPath()" @@ -1561,32 +1024,19 @@ private module Impl { private Element getImmediateChildOfKeyPathDotExpr( KeyPathDotExpr 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) - ) - ) + none() } private Element getImmediateChildOfKeyPathExpr( KeyPathExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nRoot, int nComponent | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nRoot, int nComponent | + n = 0 and nRoot = n + 1 and nComponent = nRoot + 1 + max(int i | i = -1 or exists(e.getComponent(i)) | i) and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getRoot() and partialPredicateCall = "Root()" or result = e.getComponent(index - nRoot) and @@ -1598,67 +1048,28 @@ private module Impl { private Element getImmediateChildOfLazyInitializationExpr( LazyInitializationExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } - 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 getImmediateChildOfLookupExpr(LookupExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nBase | - 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 - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - index = n and result = e.getImmediateBase() and partialPredicateCall = "Base()" - ) - ) - } - private Element getImmediateChildOfMakeTemporarilyEscapableExpr( MakeTemporarilyEscapableExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nEscapingClosure, int nNonescapingClosure, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nEscapingClosure, int nNonescapingClosure, int nSubExpr | + n = 0 and nEscapingClosure = n + 1 and nNonescapingClosure = nEscapingClosure + 1 and nSubExpr = nNonescapingClosure + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateEscapingClosure() and partialPredicateCall = "EscapingClosure()" @@ -1677,16 +1088,12 @@ private module Impl { private Element getImmediateChildOfMaterializePackExpr( MaterializePackExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) @@ -1695,32 +1102,24 @@ private module Impl { private Element getImmediateChildOfObjCSelectorExpr( ObjCSelectorExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } private Element getImmediateChildOfOneWayExpr(OneWayExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) @@ -1729,32 +1128,19 @@ private module Impl { private Element getImmediateChildOfOpaqueValueExpr( OpaqueValueExpr 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) - ) - ) + none() } private Element getImmediateChildOfOpenExistentialExpr( OpenExistentialExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nSubExpr, int nExistential | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nSubExpr, int nExistential | + n = 0 and nSubExpr = n + 1 and nExistential = nSubExpr + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" or index = nSubExpr and @@ -1767,16 +1153,12 @@ private module Impl { private Element getImmediateChildOfOptionalEvaluationExpr( OptionalEvaluationExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) @@ -1785,50 +1167,24 @@ private module Impl { private Element getImmediateChildOfOtherInitializerRefExpr( OtherInitializerRefExpr 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) - ) - ) + none() } private Element getImmediateChildOfOverloadedDeclRefExpr( OverloadedDeclRefExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int bErrorElement, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bErrorElement = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfPackElementExpr( PackElementExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) @@ -1837,16 +1193,12 @@ private module Impl { private Element getImmediateChildOfPackExpansionExpr( PackExpansionExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nPatternExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nPatternExpr | + n = 0 and nPatternExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediatePatternExpr() and partialPredicateCall = "PatternExpr()" @@ -1857,31 +1209,18 @@ private module Impl { private Element getImmediateChildOfPropertyWrapperValuePlaceholderExpr( PropertyWrapperValuePlaceholderExpr 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) - ) - ) + none() } private Element getImmediateChildOfRebindSelfInInitializerExpr( RebindSelfInInitializerExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) @@ -1890,16 +1229,12 @@ private module Impl { private Element getImmediateChildOfSequenceExpr( SequenceExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nElement | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nElement | + n = 0 and nElement = n + 1 + max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getImmediateElement(index - n) and partialPredicateCall = "Element(" + (index - n).toString() + ")" ) @@ -1909,16 +1244,12 @@ private module Impl { private Element getImmediateChildOfSingleValueStmtExpr( SingleValueStmtExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nStmt | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nStmt | + n = 0 and nStmt = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getStmt() and partialPredicateCall = "Stmt()" ) ) @@ -1927,30 +1258,17 @@ private module Impl { private Element getImmediateChildOfSuperRefExpr( SuperRefExpr 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) - ) - ) + none() } private Element getImmediateChildOfTapExpr(TapExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nSubExpr, int nBody | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nSubExpr, int nBody | + n = 0 and nSubExpr = n + 1 and nBody = nSubExpr + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" or index = nSubExpr and result = e.getBody() and partialPredicateCall = "Body()" @@ -1961,32 +1279,24 @@ private module Impl { private Element getImmediateChildOfTupleElementExpr( TupleElementExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } private Element getImmediateChildOfTupleExpr(TupleExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nElement | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nElement | + n = 0 and nElement = n + 1 + max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or result = e.getImmediateElement(index - n) and partialPredicateCall = "Element(" + (index - n).toString() + ")" ) @@ -1994,16 +1304,12 @@ private module Impl { } private Element getImmediateChildOfTypeExpr(TypeExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nTypeRepr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nTypeRepr | + n = 0 and nTypeRepr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getTypeRepr() and partialPredicateCall = "TypeRepr()" ) ) @@ -2012,16 +1318,12 @@ private module Impl { private Element getImmediateChildOfTypeValueExpr( TypeValueExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nTypeRepr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nTypeRepr | + n = 0 and nTypeRepr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getTypeRepr() and partialPredicateCall = "TypeRepr()" ) ) @@ -2030,39 +1332,18 @@ private module Impl { private Element getImmediateChildOfUnresolvedDeclRefExpr( UnresolvedDeclRefExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int bErrorElement, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bErrorElement = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfUnresolvedDotExpr( UnresolvedDotExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int bErrorElement, int n, int nBase | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bErrorElement = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and + exists(int n, int nBase | + n = 0 and nBase = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) - or index = n and result = e.getImmediateBase() and partialPredicateCall = "Base()" ) ) @@ -2071,39 +1352,18 @@ private module Impl { private Element getImmediateChildOfUnresolvedMemberExpr( UnresolvedMemberExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int bErrorElement, int n | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bErrorElement = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - ( - none() - or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfUnresolvedPatternExpr( UnresolvedPatternExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int bErrorElement, int n, int nSubPattern | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bErrorElement = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and + exists(int n, int nSubPattern | + n = 0 and nSubPattern = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) - or index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" ) ) @@ -2112,20 +1372,12 @@ private module Impl { private Element getImmediateChildOfUnresolvedSpecializeExpr( UnresolvedSpecializeExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int bErrorElement, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - bErrorElement = - bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bExpr, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) @@ -2134,16 +1386,12 @@ private module Impl { private Element getImmediateChildOfVarargExpansionExpr( VarargExpansionExpr e, int index, string partialPredicateCall ) { - exists(int b, int bExpr, int n, int nSubExpr | - b = 0 and - bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and - n = bExpr and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) @@ -2152,16 +1400,13 @@ private module Impl { private Element getImmediateChildOfAbiSafeConversionExpr( AbiSafeConversionExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2169,16 +1414,13 @@ private module Impl { private Element getImmediateChildOfActorIsolationErasureExpr( ActorIsolationErasureExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2186,16 +1428,13 @@ private module Impl { private Element getImmediateChildOfAnyHashableErasureExpr( AnyHashableErasureExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2203,32 +1442,24 @@ private module Impl { private Element getImmediateChildOfArchetypeToSuperExpr( ArchetypeToSuperExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } private Element getImmediateChildOfArrayExpr(ArrayExpr e, int index, string partialPredicateCall) { - exists(int b, int bCollectionExpr, int n, int nElement | - b = 0 and - bCollectionExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCollectionExpr(e, i, _)) | i) and - n = bCollectionExpr and + exists(int n, int nElement | + n = 0 and nElement = n + 1 + max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) and ( none() or - result = getImmediateChildOfCollectionExpr(e, index - b, partialPredicateCall) - or result = e.getImmediateElement(index - n) and partialPredicateCall = "Element(" + (index - n).toString() + ")" ) @@ -2238,16 +1469,13 @@ private module Impl { private Element getImmediateChildOfArrayToPointerExpr( ArrayToPointerExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2255,56 +1483,64 @@ private module Impl { private Element getImmediateChildOfAutoClosureExpr( AutoClosureExpr e, int index, string partialPredicateCall ) { - exists(int b, int bClosureExpr, int n | - b = 0 and - bClosureExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfClosureExpr(e, i, _)) | i) and - n = bClosureExpr and + exists(int n, int nSelfParam, int nParam, int nBody, int nCapture | + n = 0 and + nSelfParam = n + 1 and + nParam = nSelfParam + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and + nBody = nParam + 1 and + nCapture = nBody + 1 + max(int i | i = -1 or exists(e.getCapture(i)) | i) and ( none() or - result = getImmediateChildOfClosureExpr(e, index - b, partialPredicateCall) + index = n and result = e.getSelfParam() and partialPredicateCall = "SelfParam()" + or + result = e.getParam(index - nSelfParam) and + partialPredicateCall = "Param(" + (index - nSelfParam).toString() + ")" + or + index = nParam and result = e.getBody() and partialPredicateCall = "Body()" + or + result = e.getCapture(index - nBody) and + partialPredicateCall = "Capture(" + (index - nBody).toString() + ")" ) ) } private Element getImmediateChildOfAwaitExpr(AwaitExpr e, int index, string partialPredicateCall) { - exists(int b, int bIdentityExpr, int n | - b = 0 and - bIdentityExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfIdentityExpr(e, i, _)) | i) and - n = bIdentityExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfIdentityExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } private Element getImmediateChildOfBinaryExpr(BinaryExpr e, int index, string partialPredicateCall) { - exists(int b, int bApplyExpr, int n | - b = 0 and - bApplyExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfApplyExpr(e, i, _)) | i) and - n = bApplyExpr and + exists(int n, int nFunction, int nArgument | + n = 0 and + nFunction = n + 1 and + nArgument = nFunction + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and ( none() or - result = getImmediateChildOfApplyExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateFunction() and partialPredicateCall = "Function()" + or + result = e.getArgument(index - nFunction) and + partialPredicateCall = "Argument(" + (index - nFunction).toString() + ")" ) ) } private Element getImmediateChildOfBorrowExpr(BorrowExpr e, int index, string partialPredicateCall) { - exists(int b, int bIdentityExpr, int n | - b = 0 and - bIdentityExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfIdentityExpr(e, i, _)) | i) and - n = bIdentityExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfIdentityExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2312,16 +1548,13 @@ private module Impl { private Element getImmediateChildOfBridgeFromObjCExpr( BridgeFromObjCExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2329,61 +1562,29 @@ private module Impl { private Element getImmediateChildOfBridgeToObjCExpr( BridgeToObjCExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and - ( - none() - or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBuiltinLiteralExpr( - BuiltinLiteralExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bLiteralExpr, int n | - b = 0 and - bLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLiteralExpr(e, i, _)) | i) and - n = bLiteralExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfLiteralExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } private Element getImmediateChildOfCallExpr(CallExpr e, int index, string partialPredicateCall) { - exists(int b, int bApplyExpr, int n | - b = 0 and - bApplyExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfApplyExpr(e, i, _)) | i) and - n = bApplyExpr and + exists(int n, int nFunction, int nArgument | + n = 0 and + nFunction = n + 1 and + nArgument = nFunction + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and ( none() or - result = getImmediateChildOfApplyExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfCheckedCastExpr( - CheckedCastExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bExplicitCastExpr, int n | - b = 0 and - bExplicitCastExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExplicitCastExpr(e, i, _)) | i) and - n = bExplicitCastExpr and - ( - none() + index = n and result = e.getImmediateFunction() and partialPredicateCall = "Function()" or - result = getImmediateChildOfExplicitCastExpr(e, index - b, partialPredicateCall) + result = e.getArgument(index - nFunction) and + partialPredicateCall = "Argument(" + (index - nFunction).toString() + ")" ) ) } @@ -2391,30 +1592,25 @@ private module Impl { private Element getImmediateChildOfClassMetatypeToObjectExpr( ClassMetatypeToObjectExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } private Element getImmediateChildOfCoerceExpr(CoerceExpr e, int index, string partialPredicateCall) { - exists(int b, int bExplicitCastExpr, int n | - b = 0 and - bExplicitCastExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExplicitCastExpr(e, i, _)) | i) and - n = bExplicitCastExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfExplicitCastExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2422,16 +1618,13 @@ private module Impl { private Element getImmediateChildOfCollectionUpcastConversionExpr( CollectionUpcastConversionExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2439,16 +1632,13 @@ private module Impl { private Element getImmediateChildOfConditionalBridgeFromObjCExpr( ConditionalBridgeFromObjCExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2456,16 +1646,13 @@ private module Impl { private Element getImmediateChildOfCovariantFunctionConversionExpr( CovariantFunctionConversionExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2473,16 +1660,13 @@ private module Impl { private Element getImmediateChildOfCovariantReturnConversionExpr( CovariantReturnConversionExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2490,16 +1674,13 @@ private module Impl { private Element getImmediateChildOfDerivedToBaseExpr( DerivedToBaseExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2507,16 +1688,13 @@ private module Impl { private Element getImmediateChildOfDestructureTupleExpr( DestructureTupleExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2524,17 +1702,12 @@ private module Impl { private Element getImmediateChildOfDictionaryExpr( DictionaryExpr e, int index, string partialPredicateCall ) { - exists(int b, int bCollectionExpr, int n, int nElement | - b = 0 and - bCollectionExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCollectionExpr(e, i, _)) | i) and - n = bCollectionExpr and + exists(int n, int nElement | + n = 0 and nElement = n + 1 + max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) and ( none() or - result = getImmediateChildOfCollectionExpr(e, index - b, partialPredicateCall) - or result = e.getImmediateElement(index - n) and partialPredicateCall = "Element(" + (index - n).toString() + ")" ) @@ -2544,16 +1717,13 @@ private module Impl { private Element getImmediateChildOfDifferentiableFunctionExpr( DifferentiableFunctionExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2561,16 +1731,13 @@ private module Impl { private Element getImmediateChildOfDifferentiableFunctionExtractOriginalExpr( DifferentiableFunctionExtractOriginalExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2578,31 +1745,13 @@ private module Impl { private Element getImmediateChildOfDotSelfExpr( DotSelfExpr e, int index, string partialPredicateCall ) { - exists(int b, int bIdentityExpr, int n | - b = 0 and - bIdentityExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfIdentityExpr(e, i, _)) | i) and - n = bIdentityExpr and - ( - none() - or - result = getImmediateChildOfIdentityExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfDynamicLookupExpr( - DynamicLookupExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bLookupExpr, int n | - b = 0 and - bLookupExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLookupExpr(e, i, _)) | i) and - n = bLookupExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfLookupExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2610,16 +1759,13 @@ private module Impl { private Element getImmediateChildOfErasureExpr( ErasureExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2627,16 +1773,13 @@ private module Impl { private Element getImmediateChildOfExistentialMetatypeToObjectExpr( ExistentialMetatypeToObjectExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2644,15 +1787,24 @@ private module Impl { private Element getImmediateChildOfExplicitClosureExpr( ExplicitClosureExpr e, int index, string partialPredicateCall ) { - exists(int b, int bClosureExpr, int n | - b = 0 and - bClosureExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfClosureExpr(e, i, _)) | i) and - n = bClosureExpr and + exists(int n, int nSelfParam, int nParam, int nBody, int nCapture | + n = 0 and + nSelfParam = n + 1 and + nParam = nSelfParam + 1 + max(int i | i = -1 or exists(e.getParam(i)) | i) and + nBody = nParam + 1 and + nCapture = nBody + 1 + max(int i | i = -1 or exists(e.getCapture(i)) | i) and ( none() or - result = getImmediateChildOfClosureExpr(e, index - b, partialPredicateCall) + index = n and result = e.getSelfParam() and partialPredicateCall = "SelfParam()" + or + result = e.getParam(index - nSelfParam) and + partialPredicateCall = "Param(" + (index - nSelfParam).toString() + ")" + or + index = nParam and result = e.getBody() and partialPredicateCall = "Body()" + or + result = e.getCapture(index - nBody) and + partialPredicateCall = "Capture(" + (index - nBody).toString() + ")" ) ) } @@ -2660,15 +1812,13 @@ private module Impl { private Element getImmediateChildOfForceTryExpr( ForceTryExpr e, int index, string partialPredicateCall ) { - exists(int b, int bAnyTryExpr, int n | - b = 0 and - bAnyTryExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyTryExpr(e, i, _)) | i) and - n = bAnyTryExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfAnyTryExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2676,16 +1826,13 @@ private module Impl { private Element getImmediateChildOfForeignObjectConversionExpr( ForeignObjectConversionExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2693,16 +1840,13 @@ private module Impl { private Element getImmediateChildOfFunctionConversionExpr( FunctionConversionExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2710,16 +1854,13 @@ private module Impl { private Element getImmediateChildOfInOutToPointerExpr( InOutToPointerExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2727,16 +1868,13 @@ private module Impl { private Element getImmediateChildOfInjectIntoOptionalExpr( InjectIntoOptionalExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2744,17 +1882,12 @@ private module Impl { private Element getImmediateChildOfInterpolatedStringLiteralExpr( InterpolatedStringLiteralExpr e, int index, string partialPredicateCall ) { - exists(int b, int bLiteralExpr, int n, int nAppendingExpr | - b = 0 and - bLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLiteralExpr(e, i, _)) | i) and - n = bLiteralExpr and + exists(int n, int nAppendingExpr | + n = 0 and nAppendingExpr = n + 1 and ( none() or - result = getImmediateChildOfLiteralExpr(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateAppendingExpr() and partialPredicateCall = "AppendingExpr()" @@ -2765,16 +1898,13 @@ private module Impl { private Element getImmediateChildOfLinearFunctionExpr( LinearFunctionExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2782,16 +1912,13 @@ private module Impl { private Element getImmediateChildOfLinearFunctionExtractOriginalExpr( LinearFunctionExtractOriginalExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2799,31 +1926,25 @@ private module Impl { private Element getImmediateChildOfLinearToDifferentiableFunctionExpr( LinearToDifferentiableFunctionExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } private Element getImmediateChildOfLoadExpr(LoadExpr e, int index, string partialPredicateCall) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2831,15 +1952,13 @@ private module Impl { private Element getImmediateChildOfMemberRefExpr( MemberRefExpr e, int index, string partialPredicateCall ) { - exists(int b, int bLookupExpr, int n | - b = 0 and - bLookupExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLookupExpr(e, i, _)) | i) and - n = bLookupExpr and + exists(int n, int nBase | + n = 0 and + nBase = n + 1 and ( none() or - result = getImmediateChildOfLookupExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateBase() and partialPredicateCall = "Base()" ) ) } @@ -2847,16 +1966,13 @@ private module Impl { private Element getImmediateChildOfMetatypeConversionExpr( MetatypeConversionExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2864,18 +1980,18 @@ private module Impl { private Element getImmediateChildOfMethodLookupExpr( MethodLookupExpr e, int index, string partialPredicateCall ) { - exists(int b, int bLookupExpr, int n, int nMethodRef | - b = 0 and - bLookupExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLookupExpr(e, i, _)) | i) and - n = bLookupExpr and - nMethodRef = n + 1 and + exists(int n, int nBase, int nMethodRef | + n = 0 and + nBase = n + 1 and + nMethodRef = nBase + 1 and ( none() or - result = getImmediateChildOfLookupExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateBase() and partialPredicateCall = "Base()" or - index = n and result = e.getImmediateMethodRef() and partialPredicateCall = "MethodRef()" + index = nBase and + result = e.getImmediateMethodRef() and + partialPredicateCall = "MethodRef()" ) ) } @@ -2883,33 +1999,18 @@ private module Impl { private Element getImmediateChildOfNilLiteralExpr( NilLiteralExpr e, int index, string partialPredicateCall ) { - exists(int b, int bLiteralExpr, int n | - b = 0 and - bLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLiteralExpr(e, i, _)) | i) and - n = bLiteralExpr and - ( - none() - or - result = getImmediateChildOfLiteralExpr(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfObjectLiteralExpr( ObjectLiteralExpr e, int index, string partialPredicateCall ) { - exists(int b, int bLiteralExpr, int n, int nArgument | - b = 0 and - bLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLiteralExpr(e, i, _)) | i) and - n = bLiteralExpr and + exists(int n, int nArgument | + n = 0 and nArgument = n + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and ( none() or - result = getImmediateChildOfLiteralExpr(e, index - b, partialPredicateCall) - or result = e.getArgument(index - n) and partialPredicateCall = "Argument(" + (index - n).toString() + ")" ) @@ -2919,29 +2020,25 @@ private module Impl { private Element getImmediateChildOfOptionalTryExpr( OptionalTryExpr e, int index, string partialPredicateCall ) { - exists(int b, int bAnyTryExpr, int n | - b = 0 and - bAnyTryExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyTryExpr(e, i, _)) | i) and - n = bAnyTryExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfAnyTryExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } private Element getImmediateChildOfParenExpr(ParenExpr e, int index, string partialPredicateCall) { - exists(int b, int bIdentityExpr, int n | - b = 0 and - bIdentityExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfIdentityExpr(e, i, _)) | i) and - n = bIdentityExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfIdentityExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2949,16 +2046,13 @@ private module Impl { private Element getImmediateChildOfPointerToPointerExpr( PointerToPointerExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -2966,14 +2060,17 @@ private module Impl { private Element getImmediateChildOfPostfixUnaryExpr( PostfixUnaryExpr e, int index, string partialPredicateCall ) { - exists(int b, int bApplyExpr, int n | - b = 0 and - bApplyExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfApplyExpr(e, i, _)) | i) and - n = bApplyExpr and + exists(int n, int nFunction, int nArgument | + n = 0 and + nFunction = n + 1 and + nArgument = nFunction + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and ( none() or - result = getImmediateChildOfApplyExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateFunction() and partialPredicateCall = "Function()" + or + result = e.getArgument(index - nFunction) and + partialPredicateCall = "Argument(" + (index - nFunction).toString() + ")" ) ) } @@ -2981,14 +2078,17 @@ private module Impl { private Element getImmediateChildOfPrefixUnaryExpr( PrefixUnaryExpr e, int index, string partialPredicateCall ) { - exists(int b, int bApplyExpr, int n | - b = 0 and - bApplyExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfApplyExpr(e, i, _)) | i) and - n = bApplyExpr and + exists(int n, int nFunction, int nArgument | + n = 0 and + nFunction = n + 1 and + nArgument = nFunction + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and ( none() or - result = getImmediateChildOfApplyExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateFunction() and partialPredicateCall = "Function()" + or + result = e.getArgument(index - nFunction) and + partialPredicateCall = "Argument(" + (index - nFunction).toString() + ")" ) ) } @@ -2996,16 +2096,13 @@ private module Impl { private Element getImmediateChildOfProtocolMetatypeToObjectExpr( ProtocolMetatypeToObjectExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -3013,47 +2110,19 @@ private module Impl { private Element getImmediateChildOfRegexLiteralExpr( RegexLiteralExpr e, int index, string partialPredicateCall ) { - exists(int b, int bLiteralExpr, int n | - b = 0 and - bLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLiteralExpr(e, i, _)) | i) and - n = bLiteralExpr and - ( - none() - or - result = getImmediateChildOfLiteralExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfSelfApplyExpr( - SelfApplyExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bApplyExpr, int n | - b = 0 and - bApplyExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfApplyExpr(e, i, _)) | i) and - n = bApplyExpr and - ( - none() - or - result = getImmediateChildOfApplyExpr(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfStringToPointerExpr( StringToPointerExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -3061,33 +2130,29 @@ private module Impl { private Element getImmediateChildOfSubscriptExpr( SubscriptExpr e, int index, string partialPredicateCall ) { - exists(int b, int bLookupExpr, int n, int nArgument | - b = 0 and - bLookupExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLookupExpr(e, i, _)) | i) and - n = bLookupExpr and - nArgument = n + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and + exists(int n, int nBase, int nArgument | + n = 0 and + nBase = n + 1 and + nArgument = nBase + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and ( none() or - result = getImmediateChildOfLookupExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateBase() and partialPredicateCall = "Base()" or - result = e.getArgument(index - n) and - partialPredicateCall = "Argument(" + (index - n).toString() + ")" + result = e.getArgument(index - nBase) and + partialPredicateCall = "Argument(" + (index - nBase).toString() + ")" ) ) } private Element getImmediateChildOfTryExpr(TryExpr e, int index, string partialPredicateCall) { - exists(int b, int bAnyTryExpr, int n | - b = 0 and - bAnyTryExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyTryExpr(e, i, _)) | i) and - n = bAnyTryExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfAnyTryExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -3095,16 +2160,13 @@ private module Impl { private Element getImmediateChildOfUnderlyingToOpaqueExpr( UnderlyingToOpaqueExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -3112,16 +2174,13 @@ private module Impl { private Element getImmediateChildOfUnevaluatedInstanceExpr( UnevaluatedInstanceExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -3129,16 +2188,13 @@ private module Impl { private Element getImmediateChildOfUnreachableExpr( UnreachableExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -3146,20 +2202,13 @@ private module Impl { private Element getImmediateChildOfUnresolvedMemberChainResultExpr( UnresolvedMemberChainResultExpr e, int index, string partialPredicateCall ) { - exists(int b, int bIdentityExpr, int bErrorElement, int n | - b = 0 and - bIdentityExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfIdentityExpr(e, i, _)) | i) and - bErrorElement = - bIdentityExpr + 1 + - max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfIdentityExpr(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bIdentityExpr, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -3167,22 +2216,13 @@ private module Impl { private Element getImmediateChildOfUnresolvedTypeConversionExpr( UnresolvedTypeConversionExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int bErrorElement, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - bErrorElement = - bImplicitConversionExpr + 1 + - max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) - or - result = - getImmediateChildOfErrorElement(e, index - bImplicitConversionExpr, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -3190,16 +2230,13 @@ private module Impl { private Element getImmediateChildOfUnsafeCastExpr( UnsafeCastExpr e, int index, string partialPredicateCall ) { - exists(int b, int bImplicitConversionExpr, int n | - b = 0 and - bImplicitConversionExpr = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfImplicitConversionExpr(e, i, _)) | i) and - n = bImplicitConversionExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfImplicitConversionExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -3207,31 +2244,19 @@ private module Impl { private Element getImmediateChildOfBooleanLiteralExpr( BooleanLiteralExpr e, int index, string partialPredicateCall ) { - exists(int b, int bBuiltinLiteralExpr, int n | - b = 0 and - bBuiltinLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinLiteralExpr(e, i, _)) | i) and - n = bBuiltinLiteralExpr and - ( - none() - or - result = getImmediateChildOfBuiltinLiteralExpr(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfConditionalCheckedCastExpr( ConditionalCheckedCastExpr e, int index, string partialPredicateCall ) { - exists(int b, int bCheckedCastExpr, int n | - b = 0 and - bCheckedCastExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCheckedCastExpr(e, i, _)) | i) and - n = bCheckedCastExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfCheckedCastExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -3239,15 +2264,17 @@ private module Impl { private Element getImmediateChildOfDotSyntaxCallExpr( DotSyntaxCallExpr e, int index, string partialPredicateCall ) { - exists(int b, int bSelfApplyExpr, int n | - b = 0 and - bSelfApplyExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSelfApplyExpr(e, i, _)) | i) and - n = bSelfApplyExpr and + exists(int n, int nFunction, int nArgument | + n = 0 and + nFunction = n + 1 and + nArgument = nFunction + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and ( none() or - result = getImmediateChildOfSelfApplyExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateFunction() and partialPredicateCall = "Function()" + or + result = e.getArgument(index - nFunction) and + partialPredicateCall = "Argument(" + (index - nFunction).toString() + ")" ) ) } @@ -3255,15 +2282,13 @@ private module Impl { private Element getImmediateChildOfDynamicMemberRefExpr( DynamicMemberRefExpr e, int index, string partialPredicateCall ) { - exists(int b, int bDynamicLookupExpr, int n | - b = 0 and - bDynamicLookupExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDynamicLookupExpr(e, i, _)) | i) and - n = bDynamicLookupExpr and + exists(int n, int nBase | + n = 0 and + nBase = n + 1 and ( none() or - result = getImmediateChildOfDynamicLookupExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateBase() and partialPredicateCall = "Base()" ) ) } @@ -3271,15 +2296,13 @@ private module Impl { private Element getImmediateChildOfDynamicSubscriptExpr( DynamicSubscriptExpr e, int index, string partialPredicateCall ) { - exists(int b, int bDynamicLookupExpr, int n | - b = 0 and - bDynamicLookupExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfDynamicLookupExpr(e, i, _)) | i) and - n = bDynamicLookupExpr and + exists(int n, int nBase | + n = 0 and + nBase = n + 1 and ( none() or - result = getImmediateChildOfDynamicLookupExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateBase() and partialPredicateCall = "Base()" ) ) } @@ -3287,15 +2310,13 @@ private module Impl { private Element getImmediateChildOfForcedCheckedCastExpr( ForcedCheckedCastExpr e, int index, string partialPredicateCall ) { - exists(int b, int bCheckedCastExpr, int n | - b = 0 and - bCheckedCastExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCheckedCastExpr(e, i, _)) | i) and - n = bCheckedCastExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfCheckedCastExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -3303,29 +2324,29 @@ private module Impl { private Element getImmediateChildOfInitializerRefCallExpr( InitializerRefCallExpr e, int index, string partialPredicateCall ) { - exists(int b, int bSelfApplyExpr, int n | - b = 0 and - bSelfApplyExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSelfApplyExpr(e, i, _)) | i) and - n = bSelfApplyExpr and + exists(int n, int nFunction, int nArgument | + n = 0 and + nFunction = n + 1 and + nArgument = nFunction + 1 + max(int i | i = -1 or exists(e.getArgument(i)) | i) and ( none() or - result = getImmediateChildOfSelfApplyExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateFunction() and partialPredicateCall = "Function()" + or + result = e.getArgument(index - nFunction) and + partialPredicateCall = "Argument(" + (index - nFunction).toString() + ")" ) ) } private Element getImmediateChildOfIsExpr(IsExpr e, int index, string partialPredicateCall) { - exists(int b, int bCheckedCastExpr, int n | - b = 0 and - bCheckedCastExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfCheckedCastExpr(e, i, _)) | i) and - n = bCheckedCastExpr and + exists(int n, int nSubExpr | + n = 0 and + nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfCheckedCastExpr(e, index - b, partialPredicateCall) + index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } @@ -3333,122 +2354,40 @@ private module Impl { private Element getImmediateChildOfMagicIdentifierLiteralExpr( MagicIdentifierLiteralExpr e, int index, string partialPredicateCall ) { - exists(int b, int bBuiltinLiteralExpr, int n | - b = 0 and - bBuiltinLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinLiteralExpr(e, i, _)) | i) and - n = bBuiltinLiteralExpr and - ( - none() - or - result = getImmediateChildOfBuiltinLiteralExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfNumberLiteralExpr( - NumberLiteralExpr e, int index, string partialPredicateCall - ) { - exists(int b, int bBuiltinLiteralExpr, int n | - b = 0 and - bBuiltinLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinLiteralExpr(e, i, _)) | i) and - n = bBuiltinLiteralExpr and - ( - none() - or - result = getImmediateChildOfBuiltinLiteralExpr(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfStringLiteralExpr( StringLiteralExpr e, int index, string partialPredicateCall ) { - exists(int b, int bBuiltinLiteralExpr, int n | - b = 0 and - bBuiltinLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinLiteralExpr(e, i, _)) | i) and - n = bBuiltinLiteralExpr and - ( - none() - or - result = getImmediateChildOfBuiltinLiteralExpr(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfFloatLiteralExpr( FloatLiteralExpr e, int index, string partialPredicateCall ) { - exists(int b, int bNumberLiteralExpr, int n | - b = 0 and - bNumberLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNumberLiteralExpr(e, i, _)) | i) and - n = bNumberLiteralExpr and - ( - none() - or - result = getImmediateChildOfNumberLiteralExpr(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfIntegerLiteralExpr( IntegerLiteralExpr e, int index, string partialPredicateCall ) { - exists(int b, int bNumberLiteralExpr, int n | - b = 0 and - bNumberLiteralExpr = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNumberLiteralExpr(e, i, _)) | i) and - n = bNumberLiteralExpr and - ( - none() - or - result = getImmediateChildOfNumberLiteralExpr(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfPattern(Pattern 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) - ) - ) + none() } private Element getImmediateChildOfAnyPattern(AnyPattern e, int index, string partialPredicateCall) { - exists(int b, int bPattern, int n | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and - ( - none() - or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfBindingPattern( BindingPattern e, int index, string partialPredicateCall ) { - exists(int b, int bPattern, int n, int nSubPattern | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and + exists(int n, int nSubPattern | + n = 0 and nSubPattern = n + 1 and ( none() or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" ) ) @@ -3457,31 +2396,18 @@ private module Impl { private Element getImmediateChildOfBoolPattern( BoolPattern e, int index, string partialPredicateCall ) { - exists(int b, int bPattern, int n | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and - ( - none() - or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfEnumElementPattern( EnumElementPattern e, int index, string partialPredicateCall ) { - exists(int b, int bPattern, int n, int nSubPattern | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and + exists(int n, int nSubPattern | + n = 0 and nSubPattern = n + 1 and ( none() or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" ) ) @@ -3490,33 +2416,25 @@ private module Impl { private Element getImmediateChildOfExprPattern( ExprPattern e, int index, string partialPredicateCall ) { - exists(int b, int bPattern, int n, int nSubExpr | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } private Element getImmediateChildOfIsPattern(IsPattern e, int index, string partialPredicateCall) { - exists(int b, int bPattern, int n, int nCastTypeRepr, int nSubPattern | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and + exists(int n, int nCastTypeRepr, int nSubPattern | + n = 0 and nCastTypeRepr = n + 1 and nSubPattern = nCastTypeRepr + 1 and ( none() or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - or index = n and result = e.getCastTypeRepr() and partialPredicateCall = "CastTypeRepr()" or index = nCastTypeRepr and @@ -3529,31 +2447,18 @@ private module Impl { private Element getImmediateChildOfNamedPattern( NamedPattern e, int index, string partialPredicateCall ) { - exists(int b, int bPattern, int n | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and - ( - none() - or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfOptionalSomePattern( OptionalSomePattern e, int index, string partialPredicateCall ) { - exists(int b, int bPattern, int n, int nSubPattern | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and + exists(int n, int nSubPattern | + n = 0 and nSubPattern = n + 1 and ( none() or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" ) ) @@ -3562,16 +2467,12 @@ private module Impl { private Element getImmediateChildOfParenPattern( ParenPattern e, int index, string partialPredicateCall ) { - exists(int b, int bPattern, int n, int nSubPattern | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and + exists(int n, int nSubPattern | + n = 0 and nSubPattern = n + 1 and ( none() or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" ) ) @@ -3580,16 +2481,12 @@ private module Impl { private Element getImmediateChildOfTuplePattern( TuplePattern e, int index, string partialPredicateCall ) { - exists(int b, int bPattern, int n, int nElement | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and + exists(int n, int nElement | + n = 0 and nElement = n + 1 + max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) and ( none() or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - or result = e.getImmediateElement(index - n) and partialPredicateCall = "Element(" + (index - n).toString() + ")" ) @@ -3599,17 +2496,13 @@ private module Impl { private Element getImmediateChildOfTypedPattern( TypedPattern e, int index, string partialPredicateCall ) { - exists(int b, int bPattern, int n, int nSubPattern, int nTypeRepr | - b = 0 and - bPattern = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfPattern(e, i, _)) | i) and - n = bPattern and + exists(int n, int nSubPattern, int nTypeRepr | + n = 0 and nSubPattern = n + 1 and nTypeRepr = nSubPattern + 1 and ( none() or - result = getImmediateChildOfPattern(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubPattern() and partialPredicateCall = "SubPattern()" or index = nSubPattern and result = e.getTypeRepr() and partialPredicateCall = "TypeRepr()" @@ -3620,17 +2513,13 @@ private module Impl { private Element getImmediateChildOfCaseLabelItem( CaseLabelItem e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nPattern, int nGuard | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nPattern, int nGuard | + n = 0 and nPattern = n + 1 and nGuard = nPattern + 1 and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediatePattern() and partialPredicateCall = "Pattern()" or index = nPattern and result = e.getImmediateGuard() and partialPredicateCall = "Guard()" @@ -3641,12 +2530,8 @@ private module Impl { private Element getImmediateChildOfConditionElement( ConditionElement e, int index, string partialPredicateCall ) { - exists( - int b, int bAstNode, int n, int nBoolean, int nPattern, int nInitializer, int nAvailability - | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nBoolean, int nPattern, int nInitializer, int nAvailability | + n = 0 and nBoolean = n + 1 and nPattern = nBoolean + 1 and nInitializer = nPattern + 1 and @@ -3654,8 +2539,6 @@ private module Impl { ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateBoolean() and partialPredicateCall = "Boolean()" or index = nBoolean and result = e.getImmediatePattern() and partialPredicateCall = "Pattern()" @@ -3671,32 +2554,15 @@ private module Impl { ) } - 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 getImmediateChildOfStmtCondition( StmtCondition e, int index, string partialPredicateCall ) { - exists(int b, int bAstNode, int n, int nElement | - b = 0 and - bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and - n = bAstNode and + exists(int n, int nElement | + n = 0 and nElement = n + 1 + max(int i | i = -1 or exists(e.getElement(i)) | i) and ( none() or - result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall) - or result = e.getElement(index - n) and partialPredicateCall = "Element(" + (index - n).toString() + ")" ) @@ -3704,17 +2570,13 @@ private module Impl { } private Element getImmediateChildOfBraceStmt(BraceStmt e, int index, string partialPredicateCall) { - exists(int b, int bStmt, int n, int nVariable, int nElement | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and + exists(int n, int nVariable, int nElement | + n = 0 and nVariable = n + 1 + max(int i | i = -1 or exists(e.getVariable(i)) | i) and nElement = nVariable + 1 + max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) and ( none() or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - or result = e.getVariable(index - n) and partialPredicateCall = "Variable(" + (index - n).toString() + ")" or @@ -3725,31 +2587,18 @@ private module Impl { } private Element getImmediateChildOfBreakStmt(BreakStmt 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) - ) - ) + none() } private Element getImmediateChildOfCaseStmt(CaseStmt e, int index, string partialPredicateCall) { - exists(int b, int bStmt, int n, int nLabel, int nVariable, int nBody | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and + exists(int n, int nLabel, int nVariable, int nBody | + n = 0 and nLabel = n + 1 + max(int i | i = -1 or exists(e.getLabel(i)) | i) and nVariable = nLabel + 1 + max(int i | i = -1 or exists(e.getVariable(i)) | i) and nBody = nVariable + 1 and ( none() or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - or result = e.getLabel(index - n) and partialPredicateCall = "Label(" + (index - n).toString() + ")" or @@ -3764,29 +2613,16 @@ private module Impl { private Element getImmediateChildOfContinueStmt( ContinueStmt 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) - ) - ) + none() } private Element getImmediateChildOfDeferStmt(DeferStmt e, int index, string partialPredicateCall) { - exists(int b, int bStmt, int n, int nBody | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and + exists(int n, int nBody | + n = 0 and nBody = n + 1 and ( none() or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - or index = n and result = e.getBody() and partialPredicateCall = "Body()" ) ) @@ -3795,138 +2631,76 @@ private module Impl { private Element getImmediateChildOfDiscardStmt( DiscardStmt e, int index, string partialPredicateCall ) { - exists(int b, int bStmt, int n, int nSubExpr | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } private Element getImmediateChildOfFailStmt(FailStmt 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) - ) - ) + none() } private Element getImmediateChildOfFallthroughStmt( FallthroughStmt 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 getImmediateChildOfLabeledStmt( - LabeledStmt 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) - ) - ) + none() } private Element getImmediateChildOfPoundAssertStmt( PoundAssertStmt 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) - ) - ) + none() } private Element getImmediateChildOfReturnStmt(ReturnStmt e, int index, string partialPredicateCall) { - exists(int b, int bStmt, int n, int nResult | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and + exists(int n, int nResult | + n = 0 and nResult = n + 1 and ( none() or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateResult() and partialPredicateCall = "Result()" ) ) } private Element getImmediateChildOfThenStmt(ThenStmt e, int index, string partialPredicateCall) { - exists(int b, int bStmt, int n, int nResult | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and + exists(int n, int nResult | + n = 0 and nResult = n + 1 and ( none() or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateResult() and partialPredicateCall = "Result()" ) ) } private Element getImmediateChildOfThrowStmt(ThrowStmt e, int index, string partialPredicateCall) { - exists(int b, int bStmt, int n, int nSubExpr | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and + exists(int n, int nSubExpr | + n = 0 and nSubExpr = n + 1 and ( none() or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateSubExpr() and partialPredicateCall = "SubExpr()" ) ) } private Element getImmediateChildOfYieldStmt(YieldStmt e, int index, string partialPredicateCall) { - exists(int b, int bStmt, int n, int nResult | - b = 0 and - bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and - n = bStmt and + exists(int n, int nResult | + n = 0 and nResult = n + 1 + max(int i | i = -1 or exists(e.getImmediateResult(i)) | i) and ( none() or - result = getImmediateChildOfStmt(e, index - b, partialPredicateCall) - or result = e.getImmediateResult(index - n) and partialPredicateCall = "Result(" + (index - n).toString() + ")" ) @@ -3936,18 +2710,13 @@ private module Impl { private Element getImmediateChildOfDoCatchStmt( DoCatchStmt e, int index, string partialPredicateCall ) { - exists(int b, int bLabeledStmt, int n, int nBody, int nCatch | - b = 0 and - bLabeledStmt = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) and - n = bLabeledStmt and + exists(int n, int nBody, int nCatch | + n = 0 and nBody = n + 1 and nCatch = nBody + 1 + max(int i | i = -1 or exists(e.getCatch(i)) | i) and ( none() or - result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) - or index = n and result = e.getBody() and partialPredicateCall = "Body()" or result = e.getCatch(index - nBody) and @@ -3957,17 +2726,12 @@ private module Impl { } private Element getImmediateChildOfDoStmt(DoStmt e, int index, string partialPredicateCall) { - exists(int b, int bLabeledStmt, int n, int nBody | - b = 0 and - bLabeledStmt = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) and - n = bLabeledStmt and + exists(int n, int nBody | + n = 0 and nBody = n + 1 and ( none() or - result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) - or index = n and result = e.getBody() and partialPredicateCall = "Body()" ) ) @@ -3977,13 +2741,9 @@ private module Impl { ForEachStmt e, int index, string partialPredicateCall ) { exists( - int b, int bLabeledStmt, int n, int nVariable, int nPattern, int nWhere, int nIteratorVar, - int nNextCall, int nBody + int n, int nVariable, int nPattern, int nWhere, int nIteratorVar, int nNextCall, int nBody | - b = 0 and - bLabeledStmt = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) and - n = bLabeledStmt and + n = 0 and nVariable = n + 1 + max(int i | i = -1 or exists(e.getVariable(i)) | i) and nPattern = nVariable + 1 and nWhere = nPattern + 1 and @@ -3993,8 +2753,6 @@ private module Impl { ( none() or - result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) - or result = e.getVariable(index - n) and partialPredicateCall = "Variable(" + (index - n).toString() + ")" or @@ -4015,40 +2773,16 @@ private module Impl { ) } - private Element getImmediateChildOfLabeledConditionalStmt( - LabeledConditionalStmt e, int index, string partialPredicateCall - ) { - exists(int b, int bLabeledStmt, int n, int nCondition | - b = 0 and - bLabeledStmt = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) and - n = bLabeledStmt and - nCondition = n + 1 and - ( - none() - or - result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) - or - index = n and result = e.getCondition() and partialPredicateCall = "Condition()" - ) - ) - } - private Element getImmediateChildOfRepeatWhileStmt( RepeatWhileStmt e, int index, string partialPredicateCall ) { - exists(int b, int bLabeledStmt, int n, int nCondition, int nBody | - b = 0 and - bLabeledStmt = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) and - n = bLabeledStmt and + exists(int n, int nCondition, int nBody | + n = 0 and nCondition = n + 1 and nBody = nCondition + 1 and ( none() or - result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateCondition() and partialPredicateCall = "Condition()" or index = nCondition and result = e.getBody() and partialPredicateCall = "Body()" @@ -4057,18 +2791,13 @@ private module Impl { } private Element getImmediateChildOfSwitchStmt(SwitchStmt e, int index, string partialPredicateCall) { - exists(int b, int bLabeledStmt, int n, int nExpr, int nCase | - b = 0 and - bLabeledStmt = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLabeledStmt(e, i, _)) | i) and - n = bLabeledStmt and + exists(int n, int nExpr, int nCase | + n = 0 and nExpr = n + 1 and nCase = nExpr + 1 + max(int i | i = -1 or exists(e.getCase(i)) | i) and ( none() or - result = getImmediateChildOfLabeledStmt(e, index - b, partialPredicateCall) - or index = n and result = e.getImmediateExpr() and partialPredicateCall = "Expr()" or result = e.getCase(index - nExpr) and @@ -4078,38 +2807,32 @@ private module Impl { } private Element getImmediateChildOfGuardStmt(GuardStmt e, int index, string partialPredicateCall) { - exists(int b, int bLabeledConditionalStmt, int n, int nBody | - b = 0 and - bLabeledConditionalStmt = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfLabeledConditionalStmt(e, i, _)) | i) and - n = bLabeledConditionalStmt and - nBody = n + 1 and - ( + exists(int n, int nCondition, int nBody | + n = 0 and + nCondition = n + 1 and + nBody = nCondition + 1 and + ( none() or - result = getImmediateChildOfLabeledConditionalStmt(e, index - b, partialPredicateCall) + index = n and result = e.getCondition() and partialPredicateCall = "Condition()" or - index = n and result = e.getBody() and partialPredicateCall = "Body()" + index = nCondition and result = e.getBody() and partialPredicateCall = "Body()" ) ) } private Element getImmediateChildOfIfStmt(IfStmt e, int index, string partialPredicateCall) { - exists(int b, int bLabeledConditionalStmt, int n, int nThen, int nElse | - b = 0 and - bLabeledConditionalStmt = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfLabeledConditionalStmt(e, i, _)) | i) and - n = bLabeledConditionalStmt and - nThen = n + 1 and + exists(int n, int nCondition, int nThen, int nElse | + n = 0 and + nCondition = n + 1 and + nThen = nCondition + 1 and nElse = nThen + 1 and ( none() or - result = getImmediateChildOfLabeledConditionalStmt(e, index - b, partialPredicateCall) + index = n and result = e.getCondition() and partialPredicateCall = "Condition()" or - index = n and result = e.getThen() and partialPredicateCall = "Then()" + index = nCondition and result = e.getThen() and partialPredicateCall = "Then()" or index = nThen and result = e.getElse() and partialPredicateCall = "Else()" ) @@ -4117,1140 +2840,332 @@ private module Impl { } private Element getImmediateChildOfWhileStmt(WhileStmt e, int index, string partialPredicateCall) { - exists(int b, int bLabeledConditionalStmt, int n, int nBody | - b = 0 and - bLabeledConditionalStmt = - b + 1 + - max(int i | i = -1 or exists(getImmediateChildOfLabeledConditionalStmt(e, i, _)) | i) and - n = bLabeledConditionalStmt and - nBody = n + 1 and + exists(int n, int nCondition, int nBody | + n = 0 and + nCondition = n + 1 and + nBody = nCondition + 1 and ( none() or - result = getImmediateChildOfLabeledConditionalStmt(e, index - b, partialPredicateCall) - or - index = n and result = e.getBody() and partialPredicateCall = "Body()" - ) - ) - } - - private Element getImmediateChildOfType(Type 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() + index = n and result = e.getCondition() and partialPredicateCall = "Condition()" or - result = getImmediateChildOfElement(e, index - b, partialPredicateCall) + index = nCondition and result = e.getBody() and partialPredicateCall = "Body()" ) ) } private Element getImmediateChildOfTypeRepr(TypeRepr 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 getImmediateChildOfAnyFunctionType( - AnyFunctionType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAnyGenericType( - AnyGenericType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAnyMetatypeType( - AnyMetatypeType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBuiltinType( - BuiltinType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfDependentMemberType( DependentMemberType e, int index, string partialPredicateCall ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfDynamicSelfType( DynamicSelfType e, int index, string partialPredicateCall ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfErrorType(ErrorType e, int index, string partialPredicateCall) { - exists(int b, int bType, int bErrorElement, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - bErrorElement = - bType + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bType, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfExistentialType( ExistentialType e, int index, string partialPredicateCall ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfInOutType(InOutType e, int index, string partialPredicateCall) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfIntegerType( IntegerType e, int index, string partialPredicateCall ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfLValueType(LValueType e, int index, string partialPredicateCall) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfModuleType(ModuleType e, int index, string partialPredicateCall) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfPackElementType( PackElementType e, int index, string partialPredicateCall ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfPackExpansionType( PackExpansionType e, int index, string partialPredicateCall ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfPackType(PackType e, int index, string partialPredicateCall) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfParameterizedProtocolType( ParameterizedProtocolType e, int index, string partialPredicateCall ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfProtocolCompositionType( ProtocolCompositionType e, int index, string partialPredicateCall ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfReferenceStorageType( - ReferenceStorageType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfSubstitutableType( - SubstitutableType e, int index, string partialPredicateCall - ) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfSugarType(SugarType e, int index, string partialPredicateCall) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfTupleType(TupleType e, int index, string partialPredicateCall) { - exists(int b, int bType, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - n = bType and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfUnresolvedType( UnresolvedType e, int index, string partialPredicateCall ) { - exists(int b, int bType, int bErrorElement, int n | - b = 0 and - bType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfType(e, i, _)) | i) and - bErrorElement = - bType + 1 + max(int i | i = -1 or exists(getImmediateChildOfErrorElement(e, i, _)) | i) and - n = bErrorElement and - ( - none() - or - result = getImmediateChildOfType(e, index - b, partialPredicateCall) - or - result = getImmediateChildOfErrorElement(e, index - bType, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfAnyBuiltinIntegerType( - AnyBuiltinIntegerType e, int index, string partialPredicateCall - ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfArchetypeType( - ArchetypeType e, int index, string partialPredicateCall - ) { - exists(int b, int bSubstitutableType, int n | - b = 0 and - bSubstitutableType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSubstitutableType(e, i, _)) | i) and - n = bSubstitutableType and - ( - none() - or - result = getImmediateChildOfSubstitutableType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfBuiltinBridgeObjectType( BuiltinBridgeObjectType e, int index, string partialPredicateCall ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfBuiltinDefaultActorStorageType( BuiltinDefaultActorStorageType e, int index, string partialPredicateCall ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfBuiltinExecutorType( BuiltinExecutorType e, int index, string partialPredicateCall ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfBuiltinFixedArrayType( BuiltinFixedArrayType e, int index, string partialPredicateCall ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfBuiltinFloatType( BuiltinFloatType e, int index, string partialPredicateCall ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfBuiltinJobType( BuiltinJobType e, int index, string partialPredicateCall ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfBuiltinNativeObjectType( BuiltinNativeObjectType e, int index, string partialPredicateCall ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfBuiltinRawPointerType( BuiltinRawPointerType e, int index, string partialPredicateCall ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfBuiltinRawUnsafeContinuationType( BuiltinRawUnsafeContinuationType e, int index, string partialPredicateCall ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfBuiltinUnsafeValueBufferType( BuiltinUnsafeValueBufferType e, int index, string partialPredicateCall ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfBuiltinVectorType( BuiltinVectorType e, int index, string partialPredicateCall ) { - exists(int b, int bBuiltinType, int n | - b = 0 and - bBuiltinType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBuiltinType(e, i, _)) | i) and - n = bBuiltinType and - ( - none() - or - result = getImmediateChildOfBuiltinType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfExistentialMetatypeType( ExistentialMetatypeType e, int index, string partialPredicateCall ) { - exists(int b, int bAnyMetatypeType, int n | - b = 0 and - bAnyMetatypeType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyMetatypeType(e, i, _)) | i) and - n = bAnyMetatypeType and - ( - none() - or - result = getImmediateChildOfAnyMetatypeType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfFunctionType( FunctionType e, int index, string partialPredicateCall ) { - exists(int b, int bAnyFunctionType, int n | - b = 0 and - bAnyFunctionType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyFunctionType(e, i, _)) | i) and - n = bAnyFunctionType and - ( - none() - or - result = getImmediateChildOfAnyFunctionType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfGenericFunctionType( GenericFunctionType e, int index, string partialPredicateCall ) { - exists(int b, int bAnyFunctionType, int n | - b = 0 and - bAnyFunctionType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyFunctionType(e, i, _)) | i) and - n = bAnyFunctionType and - ( - none() - or - result = getImmediateChildOfAnyFunctionType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfGenericTypeParamType( GenericTypeParamType e, int index, string partialPredicateCall ) { - exists(int b, int bSubstitutableType, int n | - b = 0 and - bSubstitutableType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSubstitutableType(e, i, _)) | i) and - n = bSubstitutableType and - ( - none() - or - result = getImmediateChildOfSubstitutableType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfMetatypeType( MetatypeType e, int index, string partialPredicateCall ) { - exists(int b, int bAnyMetatypeType, int n | - b = 0 and - bAnyMetatypeType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyMetatypeType(e, i, _)) | i) and - n = bAnyMetatypeType and - ( - none() - or - result = getImmediateChildOfAnyMetatypeType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfNominalOrBoundGenericNominalType( - NominalOrBoundGenericNominalType e, int index, string partialPredicateCall - ) { - exists(int b, int bAnyGenericType, int n | - b = 0 and - bAnyGenericType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyGenericType(e, i, _)) | i) and - n = bAnyGenericType and - ( - none() - or - result = getImmediateChildOfAnyGenericType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfParenType(ParenType e, int index, string partialPredicateCall) { - exists(int b, int bSugarType, int n | - b = 0 and - bSugarType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSugarType(e, i, _)) | i) and - n = bSugarType and - ( - none() - or - result = getImmediateChildOfSugarType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfSyntaxSugarType( - SyntaxSugarType e, int index, string partialPredicateCall - ) { - exists(int b, int bSugarType, int n | - b = 0 and - bSugarType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSugarType(e, i, _)) | i) and - n = bSugarType and - ( - none() - or - result = getImmediateChildOfSugarType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfTypeAliasType( TypeAliasType e, int index, string partialPredicateCall ) { - exists(int b, int bSugarType, int n | - b = 0 and - bSugarType = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSugarType(e, i, _)) | i) and - n = bSugarType and - ( - none() - or - result = getImmediateChildOfSugarType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfUnboundGenericType( UnboundGenericType e, int index, string partialPredicateCall ) { - exists(int b, int bAnyGenericType, int n | - b = 0 and - bAnyGenericType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyGenericType(e, i, _)) | i) and - n = bAnyGenericType and - ( - none() - or - result = getImmediateChildOfAnyGenericType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfUnmanagedStorageType( UnmanagedStorageType e, int index, string partialPredicateCall ) { - exists(int b, int bReferenceStorageType, int n | - b = 0 and - bReferenceStorageType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfReferenceStorageType(e, i, _)) | i) and - n = bReferenceStorageType and - ( - none() - or - result = getImmediateChildOfReferenceStorageType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfUnownedStorageType( UnownedStorageType e, int index, string partialPredicateCall ) { - exists(int b, int bReferenceStorageType, int n | - b = 0 and - bReferenceStorageType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfReferenceStorageType(e, i, _)) | i) and - n = bReferenceStorageType and - ( - none() - or - result = getImmediateChildOfReferenceStorageType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfWeakStorageType( WeakStorageType e, int index, string partialPredicateCall ) { - exists(int b, int bReferenceStorageType, int n | - b = 0 and - bReferenceStorageType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfReferenceStorageType(e, i, _)) | i) and - n = bReferenceStorageType and - ( - none() - or - result = getImmediateChildOfReferenceStorageType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfBoundGenericType( - BoundGenericType e, int index, string partialPredicateCall - ) { - exists(int b, int bNominalOrBoundGenericNominalType, int n | - b = 0 and - bNominalOrBoundGenericNominalType = - b + 1 + - max(int i | - i = -1 or exists(getImmediateChildOfNominalOrBoundGenericNominalType(e, i, _)) - | - i - ) and - n = bNominalOrBoundGenericNominalType and - ( - none() - or - result = - getImmediateChildOfNominalOrBoundGenericNominalType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfBuiltinIntegerLiteralType( BuiltinIntegerLiteralType e, int index, string partialPredicateCall ) { - exists(int b, int bAnyBuiltinIntegerType, int n | - b = 0 and - bAnyBuiltinIntegerType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyBuiltinIntegerType(e, i, _)) | i) and - n = bAnyBuiltinIntegerType and - ( - none() - or - result = getImmediateChildOfAnyBuiltinIntegerType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfBuiltinIntegerType( BuiltinIntegerType e, int index, string partialPredicateCall ) { - exists(int b, int bAnyBuiltinIntegerType, int n | - b = 0 and - bAnyBuiltinIntegerType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAnyBuiltinIntegerType(e, i, _)) | i) and - n = bAnyBuiltinIntegerType and - ( - none() - or - result = getImmediateChildOfAnyBuiltinIntegerType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfDictionaryType( DictionaryType e, int index, string partialPredicateCall ) { - exists(int b, int bSyntaxSugarType, int n | - b = 0 and - bSyntaxSugarType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSyntaxSugarType(e, i, _)) | i) and - n = bSyntaxSugarType and - ( - none() - or - result = getImmediateChildOfSyntaxSugarType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfLocalArchetypeType( - LocalArchetypeType e, int index, string partialPredicateCall - ) { - exists(int b, int bArchetypeType, int n | - b = 0 and - bArchetypeType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArchetypeType(e, i, _)) | i) and - n = bArchetypeType and - ( - none() - or - result = getImmediateChildOfArchetypeType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfNominalType( - NominalType e, int index, string partialPredicateCall - ) { - exists(int b, int bNominalOrBoundGenericNominalType, int n | - b = 0 and - bNominalOrBoundGenericNominalType = - b + 1 + - max(int i | - i = -1 or exists(getImmediateChildOfNominalOrBoundGenericNominalType(e, i, _)) - | - i - ) and - n = bNominalOrBoundGenericNominalType and - ( - none() - or - result = - getImmediateChildOfNominalOrBoundGenericNominalType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfOpaqueTypeArchetypeType( OpaqueTypeArchetypeType e, int index, string partialPredicateCall ) { - exists(int b, int bArchetypeType, int n | - b = 0 and - bArchetypeType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArchetypeType(e, i, _)) | i) and - n = bArchetypeType and - ( - none() - or - result = getImmediateChildOfArchetypeType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfPackArchetypeType( PackArchetypeType e, int index, string partialPredicateCall ) { - exists(int b, int bArchetypeType, int n | - b = 0 and - bArchetypeType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArchetypeType(e, i, _)) | i) and - n = bArchetypeType and - ( - none() - or - result = getImmediateChildOfArchetypeType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfPrimaryArchetypeType( PrimaryArchetypeType e, int index, string partialPredicateCall ) { - exists(int b, int bArchetypeType, int n | - b = 0 and - bArchetypeType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArchetypeType(e, i, _)) | i) and - n = bArchetypeType and - ( - none() - or - result = getImmediateChildOfArchetypeType(e, index - b, partialPredicateCall) - ) - ) - } - - private Element getImmediateChildOfUnarySyntaxSugarType( - UnarySyntaxSugarType e, int index, string partialPredicateCall - ) { - exists(int b, int bSyntaxSugarType, int n | - b = 0 and - bSyntaxSugarType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfSyntaxSugarType(e, i, _)) | i) and - n = bSyntaxSugarType and - ( - none() - or - result = getImmediateChildOfSyntaxSugarType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfArraySliceType( ArraySliceType e, int index, string partialPredicateCall ) { - exists(int b, int bUnarySyntaxSugarType, int n | - b = 0 and - bUnarySyntaxSugarType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfUnarySyntaxSugarType(e, i, _)) | i) and - n = bUnarySyntaxSugarType and - ( - none() - or - result = getImmediateChildOfUnarySyntaxSugarType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfBoundGenericClassType( BoundGenericClassType e, int index, string partialPredicateCall ) { - exists(int b, int bBoundGenericType, int n | - b = 0 and - bBoundGenericType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBoundGenericType(e, i, _)) | i) and - n = bBoundGenericType and - ( - none() - or - result = getImmediateChildOfBoundGenericType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfBoundGenericEnumType( BoundGenericEnumType e, int index, string partialPredicateCall ) { - exists(int b, int bBoundGenericType, int n | - b = 0 and - bBoundGenericType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBoundGenericType(e, i, _)) | i) and - n = bBoundGenericType and - ( - none() - or - result = getImmediateChildOfBoundGenericType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfBoundGenericStructType( BoundGenericStructType e, int index, string partialPredicateCall ) { - exists(int b, int bBoundGenericType, int n | - b = 0 and - bBoundGenericType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfBoundGenericType(e, i, _)) | i) and - n = bBoundGenericType and - ( - none() - or - result = getImmediateChildOfBoundGenericType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfClassType(ClassType e, int index, string partialPredicateCall) { - exists(int b, int bNominalType, int n | - b = 0 and - bNominalType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalType(e, i, _)) | i) and - n = bNominalType and - ( - none() - or - result = getImmediateChildOfNominalType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfElementArchetypeType( ElementArchetypeType e, int index, string partialPredicateCall ) { - exists(int b, int bLocalArchetypeType, int n | - b = 0 and - bLocalArchetypeType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocalArchetypeType(e, i, _)) | i) and - n = bLocalArchetypeType and - ( - none() - or - result = getImmediateChildOfLocalArchetypeType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfEnumType(EnumType e, int index, string partialPredicateCall) { - exists(int b, int bNominalType, int n | - b = 0 and - bNominalType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalType(e, i, _)) | i) and - n = bNominalType and - ( - none() - or - result = getImmediateChildOfNominalType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfOpenedArchetypeType( OpenedArchetypeType e, int index, string partialPredicateCall ) { - exists(int b, int bLocalArchetypeType, int n | - b = 0 and - bLocalArchetypeType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfLocalArchetypeType(e, i, _)) | i) and - n = bLocalArchetypeType and - ( - none() - or - result = getImmediateChildOfLocalArchetypeType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfOptionalType( OptionalType e, int index, string partialPredicateCall ) { - exists(int b, int bUnarySyntaxSugarType, int n | - b = 0 and - bUnarySyntaxSugarType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfUnarySyntaxSugarType(e, i, _)) | i) and - n = bUnarySyntaxSugarType and - ( - none() - or - result = getImmediateChildOfUnarySyntaxSugarType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfProtocolType( ProtocolType e, int index, string partialPredicateCall ) { - exists(int b, int bNominalType, int n | - b = 0 and - bNominalType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalType(e, i, _)) | i) and - n = bNominalType and - ( - none() - or - result = getImmediateChildOfNominalType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfStructType(StructType e, int index, string partialPredicateCall) { - exists(int b, int bNominalType, int n | - b = 0 and - bNominalType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfNominalType(e, i, _)) | i) and - n = bNominalType and - ( - none() - or - result = getImmediateChildOfNominalType(e, index - b, partialPredicateCall) - ) - ) + none() } private Element getImmediateChildOfVariadicSequenceType( VariadicSequenceType e, int index, string partialPredicateCall ) { - exists(int b, int bUnarySyntaxSugarType, int n | - b = 0 and - bUnarySyntaxSugarType = - b + 1 + max(int i | i = -1 or exists(getImmediateChildOfUnarySyntaxSugarType(e, i, _)) | i) and - n = bUnarySyntaxSugarType and - ( - none() - or - result = getImmediateChildOfUnarySyntaxSugarType(e, index - b, partialPredicateCall) - ) - ) + none() } cached diff --git a/swift/ql/test/extractor-tests/generated/decl/Accessor/Accessor.expected b/swift/ql/test/extractor-tests/generated/decl/Accessor/Accessor.expected index 15b05916e441..3e7285b4b7c2 100644 --- a/swift/ql/test/extractor-tests/generated/decl/Accessor/Accessor.expected +++ b/swift/ql/test/extractor-tests/generated/decl/Accessor/Accessor.expected @@ -1,36 +1,36 @@ -| accessors.swift:2:9:2:9 | _modify | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:2:9:2:9 | get | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:2:9:2:9 | set | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:3:9:3:9 | _modify | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:4:9:4:28 | get | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:5:9:5:42 | set | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:7:9:7:9 | _modify | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:7:9:7:9 | get | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:7:9:7:9 | set | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:8:9:8:29 | willSet | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | isGetter: | no | isSetter: | no | isWillSet: | yes | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:11:9:11:9 | _modify | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:11:9:11:9 | get | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:11:9:11:9 | set | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:12:9:12:19 | willSet | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | isGetter: | no | isSetter: | no | isWillSet: | yes | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:15:9:15:9 | _modify | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:15:9:15:9 | get | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:15:9:15:9 | set | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:16:9:16:28 | didSet | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | yes | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:19:9:19:9 | _modify | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:19:9:19:9 | get | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:19:9:19:9 | set | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:20:9:20:18 | didSet | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | yes | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:23:9:23:9 | _modify | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:23:9:23:9 | get | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:23:9:23:9 | set | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:24:9:24:19 | willSet | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | isGetter: | no | isSetter: | no | isWillSet: | yes | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:26:9:26:18 | didSet | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | yes | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:29:9:29:9 | get | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:29:9:29:9 | set | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:30:9:32:9 | _read | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> () | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | yes | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:33:9:35:9 | _modify | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:38:9:38:9 | _modify | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:38:9:38:9 | get | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:38:9:38:9 | set | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | -| accessors.swift:39:9:41:9 | unsafeAddress | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> UnsafePointer | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | yes | isUnsafeMutableAddress: | no | -| accessors.swift:42:9:44:9 | unsafeMutableAddress | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> UnsafeMutablePointer | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | yes | +| accessors.swift:2:9:2:9 | _modify | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:2:9:2:9 | get | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:2:9:2:9 | set | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:3:9:3:9 | _modify | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:4:9:4:28 | get | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:5:9:5:42 | set | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:7:9:7:9 | _modify | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:7:9:7:9 | get | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:7:9:7:9 | set | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:8:9:8:29 | willSet | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | yes | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:11:9:11:9 | _modify | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:11:9:11:9 | get | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:11:9:11:9 | set | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:12:9:12:19 | willSet | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | yes | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:15:9:15:9 | _modify | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:15:9:15:9 | get | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:15:9:15:9 | set | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:16:9:16:28 | didSet | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | yes | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:19:9:19:9 | _modify | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:19:9:19:9 | get | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:19:9:19:9 | set | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:20:9:20:18 | didSet | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | yes | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:23:9:23:9 | _modify | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:23:9:23:9 | get | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:23:9:23:9 | set | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:24:9:24:19 | willSet | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | yes | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:26:9:26:18 | didSet | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | yes | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:29:9:29:9 | get | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:29:9:29:9 | set | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:30:9:32:9 | _read | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | yes | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:33:9:35:9 | _modify | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:38:9:38:9 | _modify | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | yes | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:38:9:38:9 | get | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> Int | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | yes | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:38:9:38:9 | set | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> (Int) -> () | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | yes | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | no | +| accessors.swift:39:9:41:9 | unsafeAddress | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (Foo) -> () -> UnsafePointer | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | yes | isUnsafeMutableAddress: | no | +| accessors.swift:42:9:44:9 | unsafeMutableAddress | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | accessors | getNumberOfMembers: | 0 | getInterfaceType: | (inout Foo) -> () -> UnsafeMutablePointer | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | yes | diff --git a/swift/ql/test/extractor-tests/generated/decl/Accessor/Accessor.ql b/swift/ql/test/extractor-tests/generated/decl/Accessor/Accessor.ql index f4e231c7671d..fcaf8538dad7 100644 --- a/swift/ql/test/extractor-tests/generated/decl/Accessor/Accessor.ql +++ b/swift/ql/test/extractor-tests/generated/decl/Accessor/Accessor.ql @@ -3,23 +3,22 @@ import codeql.swift.elements import TestUtils from - Accessor x, string hasName, string hasSelfParam, int getNumberOfParams, string hasBody, - int getNumberOfCaptures, int getNumberOfGenericTypeParams, ModuleDecl getModule, - int getNumberOfMembers, Type getInterfaceType, string isGetter, string isSetter, string isWillSet, - string isDidSet, string isRead, string isModify, string isUnsafeAddress, - string isUnsafeMutableAddress + Accessor x, int getNumberOfGenericTypeParams, ModuleDecl getModule, int getNumberOfMembers, + Type getInterfaceType, string hasName, string hasSelfParam, int getNumberOfParams, string hasBody, + int getNumberOfCaptures, string isGetter, string isSetter, string isWillSet, string isDidSet, + string isRead, string isModify, string isUnsafeAddress, string isUnsafeMutableAddress where toBeTested(x) and not x.isUnknown() and + getNumberOfGenericTypeParams = x.getNumberOfGenericTypeParams() and + getModule = x.getModule() and + getNumberOfMembers = x.getNumberOfMembers() and + getInterfaceType = x.getInterfaceType() and (if x.hasName() then hasName = "yes" else hasName = "no") and (if x.hasSelfParam() then hasSelfParam = "yes" else hasSelfParam = "no") and getNumberOfParams = x.getNumberOfParams() and (if x.hasBody() then hasBody = "yes" else hasBody = "no") and getNumberOfCaptures = x.getNumberOfCaptures() and - getNumberOfGenericTypeParams = x.getNumberOfGenericTypeParams() and - getModule = x.getModule() and - getNumberOfMembers = x.getNumberOfMembers() and - getInterfaceType = x.getInterfaceType() and (if x.isGetter() then isGetter = "yes" else isGetter = "no") and (if x.isSetter() then isSetter = "yes" else isSetter = "no") and (if x.isWillSet() then isWillSet = "yes" else isWillSet = "no") and @@ -30,10 +29,9 @@ where if x.isUnsafeMutableAddress() then isUnsafeMutableAddress = "yes" else isUnsafeMutableAddress = "no" -select x, "hasName:", hasName, "hasSelfParam:", hasSelfParam, "getNumberOfParams:", - getNumberOfParams, "hasBody:", hasBody, "getNumberOfCaptures:", getNumberOfCaptures, - "getNumberOfGenericTypeParams:", getNumberOfGenericTypeParams, "getModule:", getModule, - "getNumberOfMembers:", getNumberOfMembers, "getInterfaceType:", getInterfaceType, "isGetter:", - isGetter, "isSetter:", isSetter, "isWillSet:", isWillSet, "isDidSet:", isDidSet, "isRead:", - isRead, "isModify:", isModify, "isUnsafeAddress:", isUnsafeAddress, "isUnsafeMutableAddress:", - isUnsafeMutableAddress +select x, "getNumberOfGenericTypeParams:", getNumberOfGenericTypeParams, "getModule:", getModule, + "getNumberOfMembers:", getNumberOfMembers, "getInterfaceType:", getInterfaceType, "hasName:", + hasName, "hasSelfParam:", hasSelfParam, "getNumberOfParams:", getNumberOfParams, "hasBody:", + hasBody, "getNumberOfCaptures:", getNumberOfCaptures, "isGetter:", isGetter, "isSetter:", + isSetter, "isWillSet:", isWillSet, "isDidSet:", isDidSet, "isRead:", isRead, "isModify:", + isModify, "isUnsafeAddress:", isUnsafeAddress, "isUnsafeMutableAddress:", isUnsafeMutableAddress diff --git a/swift/ql/test/extractor-tests/generated/decl/ExtensionDecl/ExtensionDecl.expected b/swift/ql/test/extractor-tests/generated/decl/ExtensionDecl/ExtensionDecl.expected index bd70109bed0c..8bf23cc28995 100644 --- a/swift/ql/test/extractor-tests/generated/decl/ExtensionDecl/ExtensionDecl.expected +++ b/swift/ql/test/extractor-tests/generated/decl/ExtensionDecl/ExtensionDecl.expected @@ -1,4 +1,4 @@ -| extensions.swift:5:1:9:1 | extension of S | getModule: | file://:0:0:0:0 | extensions | getNumberOfMembers: | 3 | getNumberOfGenericTypeParams: | 0 | getExtendedTypeDecl: | extensions.swift:1:1:1:11 | S | getNumberOfProtocols: | 0 | -| extensions.swift:11:1:15:1 | extension of C | getModule: | file://:0:0:0:0 | extensions | getNumberOfMembers: | 3 | getNumberOfGenericTypeParams: | 0 | getExtendedTypeDecl: | extensions.swift:3:1:3:10 | C | getNumberOfProtocols: | 0 | -| extensions.swift:21:1:23:1 | extension of S | getModule: | file://:0:0:0:0 | extensions | getNumberOfMembers: | 1 | getNumberOfGenericTypeParams: | 0 | getExtendedTypeDecl: | extensions.swift:1:1:1:11 | S | getNumberOfProtocols: | 1 | -| extensions.swift:27:1:29:1 | extension of C | getModule: | file://:0:0:0:0 | extensions | getNumberOfMembers: | 1 | getNumberOfGenericTypeParams: | 0 | getExtendedTypeDecl: | extensions.swift:3:1:3:10 | C | getNumberOfProtocols: | 2 | +| extensions.swift:5:1:9:1 | extension of S | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | extensions | getNumberOfMembers: | 3 | getExtendedTypeDecl: | extensions.swift:1:1:1:11 | S | getNumberOfProtocols: | 0 | +| extensions.swift:11:1:15:1 | extension of C | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | extensions | getNumberOfMembers: | 3 | getExtendedTypeDecl: | extensions.swift:3:1:3:10 | C | getNumberOfProtocols: | 0 | +| extensions.swift:21:1:23:1 | extension of S | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | extensions | getNumberOfMembers: | 1 | getExtendedTypeDecl: | extensions.swift:1:1:1:11 | S | getNumberOfProtocols: | 1 | +| extensions.swift:27:1:29:1 | extension of C | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | extensions | getNumberOfMembers: | 1 | getExtendedTypeDecl: | extensions.swift:3:1:3:10 | C | getNumberOfProtocols: | 2 | diff --git a/swift/ql/test/extractor-tests/generated/decl/ExtensionDecl/ExtensionDecl.ql b/swift/ql/test/extractor-tests/generated/decl/ExtensionDecl/ExtensionDecl.ql index 725a9082047b..052556b161e2 100644 --- a/swift/ql/test/extractor-tests/generated/decl/ExtensionDecl/ExtensionDecl.ql +++ b/swift/ql/test/extractor-tests/generated/decl/ExtensionDecl/ExtensionDecl.ql @@ -3,16 +3,16 @@ import codeql.swift.elements import TestUtils from - ExtensionDecl x, ModuleDecl getModule, int getNumberOfMembers, int getNumberOfGenericTypeParams, + ExtensionDecl x, int getNumberOfGenericTypeParams, ModuleDecl getModule, int getNumberOfMembers, NominalTypeDecl getExtendedTypeDecl, int getNumberOfProtocols where toBeTested(x) and not x.isUnknown() and + getNumberOfGenericTypeParams = x.getNumberOfGenericTypeParams() and getModule = x.getModule() and getNumberOfMembers = x.getNumberOfMembers() and - getNumberOfGenericTypeParams = x.getNumberOfGenericTypeParams() and getExtendedTypeDecl = x.getExtendedTypeDecl() and getNumberOfProtocols = x.getNumberOfProtocols() -select x, "getModule:", getModule, "getNumberOfMembers:", getNumberOfMembers, - "getNumberOfGenericTypeParams:", getNumberOfGenericTypeParams, "getExtendedTypeDecl:", - getExtendedTypeDecl, "getNumberOfProtocols:", getNumberOfProtocols +select x, "getNumberOfGenericTypeParams:", getNumberOfGenericTypeParams, "getModule:", getModule, + "getNumberOfMembers:", getNumberOfMembers, "getExtendedTypeDecl:", getExtendedTypeDecl, + "getNumberOfProtocols:", getNumberOfProtocols diff --git a/swift/ql/test/extractor-tests/generated/decl/NamedFunction/NamedFunction.expected b/swift/ql/test/extractor-tests/generated/decl/NamedFunction/NamedFunction.expected index 975da0933216..e844edf7c7e0 100644 --- a/swift/ql/test/extractor-tests/generated/decl/NamedFunction/NamedFunction.expected +++ b/swift/ql/test/extractor-tests/generated/decl/NamedFunction/NamedFunction.expected @@ -1,5 +1,5 @@ -| functions.swift:1:1:3:1 | foo() | hasName: | yes | hasSelfParam: | no | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | functions | getNumberOfMembers: | 0 | getInterfaceType: | () -> Int | -| functions.swift:5:1:7:1 | bar(_:d:) | hasName: | yes | hasSelfParam: | no | getNumberOfParams: | 2 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | functions | getNumberOfMembers: | 0 | getInterfaceType: | (Int, Double) -> Int | -| functions.swift:10:5:10:28 | noBody(x:) | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | no | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | functions | getNumberOfMembers: | 0 | getInterfaceType: | (Self) -> (Int) -> Int | -| functions.swift:13:1:15:1 | variadic(_:) | hasName: | yes | hasSelfParam: | no | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | functions | getNumberOfMembers: | 0 | getInterfaceType: | (Int...) -> () | -| functions.swift:17:1:19:1 | generic(x:y:) | hasName: | yes | hasSelfParam: | no | getNumberOfParams: | 2 | hasBody: | yes | getNumberOfCaptures: | 0 | getNumberOfGenericTypeParams: | 2 | getModule: | file://:0:0:0:0 | functions | getNumberOfMembers: | 0 | getInterfaceType: | (X, Y) -> () | +| functions.swift:1:1:3:1 | foo() | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | functions | getNumberOfMembers: | 0 | getInterfaceType: | () -> Int | hasName: | yes | hasSelfParam: | no | getNumberOfParams: | 0 | hasBody: | yes | getNumberOfCaptures: | 0 | +| functions.swift:5:1:7:1 | bar(_:d:) | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | functions | getNumberOfMembers: | 0 | getInterfaceType: | (Int, Double) -> Int | hasName: | yes | hasSelfParam: | no | getNumberOfParams: | 2 | hasBody: | yes | getNumberOfCaptures: | 0 | +| functions.swift:10:5:10:28 | noBody(x:) | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | functions | getNumberOfMembers: | 0 | getInterfaceType: | (Self) -> (Int) -> Int | hasName: | yes | hasSelfParam: | yes | getNumberOfParams: | 1 | hasBody: | no | getNumberOfCaptures: | 0 | +| functions.swift:13:1:15:1 | variadic(_:) | getNumberOfGenericTypeParams: | 0 | getModule: | file://:0:0:0:0 | functions | getNumberOfMembers: | 0 | getInterfaceType: | (Int...) -> () | hasName: | yes | hasSelfParam: | no | getNumberOfParams: | 1 | hasBody: | yes | getNumberOfCaptures: | 0 | +| functions.swift:17:1:19:1 | generic(x:y:) | getNumberOfGenericTypeParams: | 2 | getModule: | file://:0:0:0:0 | functions | getNumberOfMembers: | 0 | getInterfaceType: | (X, Y) -> () | hasName: | yes | hasSelfParam: | no | getNumberOfParams: | 2 | hasBody: | yes | getNumberOfCaptures: | 0 | diff --git a/swift/ql/test/extractor-tests/generated/decl/NamedFunction/NamedFunction.ql b/swift/ql/test/extractor-tests/generated/decl/NamedFunction/NamedFunction.ql index b040631d9b09..5ff75994c9a8 100644 --- a/swift/ql/test/extractor-tests/generated/decl/NamedFunction/NamedFunction.ql +++ b/swift/ql/test/extractor-tests/generated/decl/NamedFunction/NamedFunction.ql @@ -3,22 +3,22 @@ import codeql.swift.elements import TestUtils from - NamedFunction x, string hasName, string hasSelfParam, int getNumberOfParams, string hasBody, - int getNumberOfCaptures, int getNumberOfGenericTypeParams, ModuleDecl getModule, - int getNumberOfMembers, Type getInterfaceType + NamedFunction x, int getNumberOfGenericTypeParams, ModuleDecl getModule, int getNumberOfMembers, + Type getInterfaceType, string hasName, string hasSelfParam, int getNumberOfParams, string hasBody, + int getNumberOfCaptures where toBeTested(x) and not x.isUnknown() and + getNumberOfGenericTypeParams = x.getNumberOfGenericTypeParams() and + getModule = x.getModule() and + getNumberOfMembers = x.getNumberOfMembers() and + getInterfaceType = x.getInterfaceType() and (if x.hasName() then hasName = "yes" else hasName = "no") and (if x.hasSelfParam() then hasSelfParam = "yes" else hasSelfParam = "no") and getNumberOfParams = x.getNumberOfParams() and (if x.hasBody() then hasBody = "yes" else hasBody = "no") and - getNumberOfCaptures = x.getNumberOfCaptures() and - getNumberOfGenericTypeParams = x.getNumberOfGenericTypeParams() and - getModule = x.getModule() and - getNumberOfMembers = x.getNumberOfMembers() and - getInterfaceType = x.getInterfaceType() -select x, "hasName:", hasName, "hasSelfParam:", hasSelfParam, "getNumberOfParams:", - getNumberOfParams, "hasBody:", hasBody, "getNumberOfCaptures:", getNumberOfCaptures, - "getNumberOfGenericTypeParams:", getNumberOfGenericTypeParams, "getModule:", getModule, - "getNumberOfMembers:", getNumberOfMembers, "getInterfaceType:", getInterfaceType + getNumberOfCaptures = x.getNumberOfCaptures() +select x, "getNumberOfGenericTypeParams:", getNumberOfGenericTypeParams, "getModule:", getModule, + "getNumberOfMembers:", getNumberOfMembers, "getInterfaceType:", getInterfaceType, "hasName:", + hasName, "hasSelfParam:", hasSelfParam, "getNumberOfParams:", getNumberOfParams, "hasBody:", + hasBody, "getNumberOfCaptures:", getNumberOfCaptures