Merge pull request #19866 from github/redsun82/codegen-new-parent-child

Codegen: improve implementation of generated parent/child relationship
This commit is contained in:
Paolo Tranquilli
2025-06-30 14:52:24 +02:00
committed by GitHub
18 changed files with 2063 additions and 5193 deletions

View File

@@ -30,6 +30,7 @@ import subprocess
import typing
import itertools
import os
import dataclasses
import inflection
@@ -113,117 +114,197 @@ 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
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_property(
cls: schema.Class,
prop: schema.Property,
lookup: typing.Dict[str, schema.ClassBase],
prev_child: str = "",
) -> ql.Property:
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]
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"
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,
)
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)
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_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_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,
)
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 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 _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 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,69 +411,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,
)
def _partition_iter(x, pred):
x1, x2 = itertools.tee(x)
return filter(pred, x1), itertools.filterfalse(pred, x2)
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:
@@ -478,8 +496,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
}
@@ -529,7 +549,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")
@@ -600,7 +620,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
@@ -619,9 +639,7 @@ def generate(opts, renderer):
renderer.render(
ql.ClassTester(
class_name=c.name,
properties=list(
_get_all_properties_to_be_tested(c, data.classes)
),
properties=list(resolver.get_all_properties_to_be_tested(c)),
elements_module=elements_module,
# in case of collapsed hierarchies we want to see the actual QL class in results
show_ql_class="qltest_collapse_hierarchy" in c.pragmas,

View File

@@ -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):

View File

@@ -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 @@ class Property:
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 @@ class Property:
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 @@ class Class:
@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:

View File

@@ -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<base> is constructed to be strictly greater than the indexes required for children coming from <base> }}
{{! n is the base offset for direct children, equal to the last base offset from above }}
{{! n<child> is constructed to be strictly greater than the indexes for <child> 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<child> 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<child> is constructed to be strictly greater than the indexes for <child> children }}
exists(int n{{#all_children}}, int n{{property.singular}}{{/all_children}} |
n = 0
{{#all_children}}
{{#property}}
{{! n<child> 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) {

View File

@@ -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

View File

@@ -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.Child(
expected_properties[3],
prev="Child1",
),
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.Child(
expected_properties[5],
prev="Child",
),
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.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,
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,
),

View File

@@ -577,7 +577,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
@@ -707,7 +707,7 @@ test/extractor-tests/generated/FormatArgsExpr/FormatArgsArg.ql 5abcb565dcd2822e2
test/extractor-tests/generated/FormatArgsExpr/FormatArgsExpr.ql 243c2f9d830f1eae915749e81ac78d3c140280385b0002d10fcc4d2feaf14711 72b90a99a8b1c16baf1e254e1e3463c3ce5409624a2a90829122717d4e5a2b74
test/extractor-tests/generated/FormatArgsExpr/FormatArgument.ql 0a345eb48dba8e535d12a00e88008e71b3ce692fbf8f9686c8885e158635dffe eab1f230fd572474a3f304f97d05bbf4a004c52773aaf2d34f999192244c0b80
test/extractor-tests/generated/FormatArgsExpr/FormatTemplateVariableAccess.ql 24108cdc54feb77c24bb7894744e36e374f0c03d46d6e6c3fcb2012b1ad117f6 05a6b6f51029ee1a15039aa9d738bb1fd7145148f1aad790198fba832572c719
test/extractor-tests/generated/Function/Function.ql 3fccfb248ffe18fb1df1c12feba1c07f1a41edac58c9d77087971a8f94a013d7 1500438db913c101747911fd570a2f2197e4282f0156d1acd9a0026aec3cceb8
test/extractor-tests/generated/Function/Function.ql 3a30225887bd7d6fbcd6dda1c946683a2b0e289f45bc8a8fe832abe662024d4e 225475fa02be09a1b0c0fcd56a003b026b3ac938f591a47e8fbead4873b2b202
test/extractor-tests/generated/GenericArgList/GenericArgList.ql 9bd6873e56a381a693fed0f595d60d973d0073ba7afa303750d5c6a0b887a811 0b373079f65aa91cacabfc9729c91215082a915197eb657b66bcdb3b6d5e7e53
test/extractor-tests/generated/GenericParamList/GenericParamList.ql 206f270690f5c142777d43cf87b65d6dda5ec9f3953c17ee943fe3d0e7b7761c 38a6e0bbca916778f85b106609df6d5929baed006d55811ec0d71c75fe137e92
test/extractor-tests/generated/IdentPat/IdentPat.ql 23006eddf0ca1188e11ba5ee25ad62a83157b83e0b99119bf924c7f74fd8e70d 6e572f48f607f0ced309113304019ccc0a828f6ddd71e818369504dcf832a0b5

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +1,6 @@
instances
| gen_function.rs:3:1:4:38 | fn foo | isAsync: | no | isConst: | no | isDefault: | no | isGen: | no | isUnsafe: | no | hasImplementation: | yes |
| gen_function.rs:7:5:7:13 | fn bar | isAsync: | no | isConst: | no | isDefault: | no | isGen: | no | isUnsafe: | no | hasImplementation: | no |
getParamList
| gen_function.rs:3:1:4:38 | fn foo | gen_function.rs:4:7:4:14 | ParamList |
| gen_function.rs:7:5:7:13 | fn bar | gen_function.rs:7:11:7:12 | ParamList |
getAttr
getParam
| gen_function.rs:3:1:4:38 | fn foo | 0 | gen_function.rs:4:8:4:13 | ...: u32 |
getExtendedCanonicalPath
| gen_function.rs:3:1:4:38 | fn foo | crate::gen_function::foo |
| gen_function.rs:7:5:7:13 | fn bar | crate::gen_function::Trait::bar |
@@ -14,6 +8,12 @@ getCrateOrigin
| gen_function.rs:3:1:4:38 | fn foo | repo::test |
| gen_function.rs:7:5:7:13 | fn bar | repo::test |
getAttributeMacroExpansion
getParamList
| gen_function.rs:3:1:4:38 | fn foo | gen_function.rs:4:7:4:14 | ParamList |
| gen_function.rs:7:5:7:13 | fn bar | gen_function.rs:7:11:7:12 | ParamList |
getAttr
getParam
| gen_function.rs:3:1:4:38 | fn foo | 0 | gen_function.rs:4:8:4:13 | ...: u32 |
getAbi
getBody
| gen_function.rs:3:1:4:38 | fn foo | gen_function.rs:4:23:4:38 | { ... } |

View File

@@ -23,18 +23,6 @@ query predicate instances(
if x.hasImplementation() then hasImplementation = "yes" else hasImplementation = "no"
}
query predicate getParamList(Function x, ParamList getParamList) {
toBeTested(x) and not x.isUnknown() and getParamList = x.getParamList()
}
query predicate getAttr(Function x, int index, Attr getAttr) {
toBeTested(x) and not x.isUnknown() and getAttr = x.getAttr(index)
}
query predicate getParam(Function x, int index, Param getParam) {
toBeTested(x) and not x.isUnknown() and getParam = x.getParam(index)
}
query predicate getExtendedCanonicalPath(Function x, string getExtendedCanonicalPath) {
toBeTested(x) and not x.isUnknown() and getExtendedCanonicalPath = x.getExtendedCanonicalPath()
}
@@ -49,6 +37,18 @@ query predicate getAttributeMacroExpansion(Function x, MacroItems getAttributeMa
getAttributeMacroExpansion = x.getAttributeMacroExpansion()
}
query predicate getParamList(Function x, ParamList getParamList) {
toBeTested(x) and not x.isUnknown() and getParamList = x.getParamList()
}
query predicate getAttr(Function x, int index, Attr getAttr) {
toBeTested(x) and not x.isUnknown() and getAttr = x.getAttr(index)
}
query predicate getParam(Function x, int index, Param getParam) {
toBeTested(x) and not x.isUnknown() and getParam = x.getParam(index)
}
query predicate getAbi(Function x, Abi getAbi) {
toBeTested(x) and not x.isUnknown() and getAbi = x.getAbi()
}

View File

@@ -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
@@ -1039,7 +1039,7 @@ test/extractor-tests/generated/File/File.ql a1385ef2080e04e8757f61b8e1d0129df9f9
test/extractor-tests/generated/KeyPathComponent/KeyPathComponent.ql 3fa617f8ed1b308d0c56f429ee8abe6d33ef60bf57d87f6dc89fdc8fe969a102 c2fa3153077dbe9e0fc608524dc03c82ff4ed460364d341ee6a817b0d75291c3
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 74d288273f26d2551ed661f0c729ae561c76c21976c3f539d4ba135d92d3aba5 e237e6ca8db21afea6c96558aae873ede63feaa81b0e6038234ab7856a0d95d4
test/extractor-tests/generated/decl/Accessor/Accessor.ql 7e50dd3c4119162bbfa3e2461300d876c60321d4b6473ddd35e0cb992108570e eb81ed8db92bff46974079e0f1100cf94bd639191a36db45ee9e65467abb6e38
test/extractor-tests/generated/decl/AssociatedTypeDecl/AssociatedTypeDecl.ql 55a78a6b96a17532178a39bd39aa4df23295f98019bb00de041ba15dfd4f84d9 51dbcd86203d5d031d748f77943a81c2c50de4ff559af20a4a1a682a19978d4f
test/extractor-tests/generated/decl/CapturedDecl/CapturedDecl.ql fd62be6c38d39f371c20e8c2f233e37a9da5aa234588920634f5db67e8beb3bd d51d35d4fd6a21cd596e064e0221d0c86e36312412a9bd4e64f431c123f3019a
test/extractor-tests/generated/decl/ClassDecl/ClassDecl.ql d5fa7f68307e2e3e7ad060a125bda148e4a28f6acbef08a1a975bbf9ba947641 46d1e4f801414f1c869601dc706e41393e5fcd399e51da593c1e58737f6ff427
@@ -1048,7 +1048,7 @@ test/extractor-tests/generated/decl/Deinitializer/MISSING_SOURCE.txt 35fb32ea539
test/extractor-tests/generated/decl/EnumDecl/EnumCaseDecl.ql 7436bb7dfaa471f5a21ea2e3faba97d61bf53f930720999abdcc6745a65f0a1a 0241b2bb07c17136f6099185f65ea1266cd912296dfe481dce30eb9e3d1dd23f
test/extractor-tests/generated/decl/EnumDecl/EnumDecl.ql 47f20279f49388a4850df4f5ee61634e30beed58567eff891688c09942862ec2 8e11af1ceb07cab9738ffb25ac877ced712d1883a6514de5e8895cd1809a7bd8
test/extractor-tests/generated/decl/EnumDecl/EnumElementDecl.ql 16caf5b014dea42a36b23eee6932c0818d94b1416e151ce46ba06a1fd2fb73ba cac704575b50613c8f8f297ce37c6d09ef943c94df4289643a4496103ac8388e
test/extractor-tests/generated/decl/ExtensionDecl/ExtensionDecl.ql 7293da617df8d12dae74a8c7a97230d6b34b64d0afc8629988eac09dde8bcbc6 56f1e7edf6424f14ade4b99b6e1e93fbdf678e300367c07200230b640bf8d358
test/extractor-tests/generated/decl/ExtensionDecl/ExtensionDecl.ql 04529ad447b7b0c529a54b0e0d009183c00cb1dcd7eb16378a7c4c7bc86bca4d 86379270a15fa014dc127607b720bb4d39b24b70d1c0f72ef8563c4144423ced
test/extractor-tests/generated/decl/GenericTypeParamDecl/MISSING_SOURCE.txt 35fb32ea5393152eb7a875b20b4e3e4b8c7a997a8959c32417140d57a16a052d 35fb32ea5393152eb7a875b20b4e3e4b8c7a997a8959c32417140d57a16a052d
test/extractor-tests/generated/decl/IfConfigDecl/IfConfigDecl.ql b33916c742a97ea687a46aa337738666a4cf4854b394e3296582be0e8f0b7fb3 d1b4caf8bf04af0f11685f6381e52ca62dffbb6a50256be78dd686bf0a53df1d
test/extractor-tests/generated/decl/ImportDecl/ImportDecl.ql d5d5475363155fad37fd3f60a8eb22c324b8af52a91c065ee5fffe0f855a3b03 ac642144ecd2c5fbdfe628a88394646e5047d0db284d83b6a449654545456286
@@ -1057,7 +1057,7 @@ test/extractor-tests/generated/decl/Initializer/MISSING_SOURCE.txt 35fb32ea53931
test/extractor-tests/generated/decl/MacroDecl/MacroDecl.ql 61f092d4ed5972283b3eb0eeec81c8f299496dc548a98dca56a1aadaf8248d1d b9cd637cb0f6f34d8d0a4473f2c212a0534d49891d55593758bb03f8d225f32a
test/extractor-tests/generated/decl/MacroDecl/MacroRole.ql 7ab0dc211663c1b09a54ccbee7d6be94ffa45f420b383d2e2f22b7ccfb8d7a48 92296b89fccf6aebe877e67796885bedd809ebb470f23f48f98b27c2922c4ba2
test/extractor-tests/generated/decl/ModuleDecl/ModuleDecl.ql 63a41a3b393b29d19752379fe29f26fe649dad2927836e24832e07c503d092a6 927fa4056a5d7c65803f7baa1216e6bef9b3b6a223c4a2bb50f2a6a31580db6a
test/extractor-tests/generated/decl/NamedFunction/NamedFunction.ql f3d080cc8ed9c0f1753f20a21d700e0f95549510d8246971dc52a6ddcf2ee385 95cf0a0789df14593348b40ccfbce27b728eff368ffebb8137efc59065cd543d
test/extractor-tests/generated/decl/NamedFunction/NamedFunction.ql c6be4c1314ffed2a8a91af2e08ea14ce721195ec993d18ebd4d7b90f4a60dac3 767fc36b64291ab7ecccd63bf74856983830267c992d1347236da314fca73d57
test/extractor-tests/generated/decl/OpaqueTypeDecl/OpaqueTypeDecl.ql 85b041e1f791b40ff3d3c58c79e017cebf9ef535ea3d576984b7c093f25aa95b 9fcf314b02ac95fbd2c0e5fc95dc48c16522c74def57f5647dd5ad7e80f7c2c1
test/extractor-tests/generated/decl/ParamDecl/ParamDecl.ql cc9d89731f7a5ecc2267923268e2d8046aa3f0eb9556c6a12e53b541347f45a4 6d06279172ff2c04be0f39293a2e9a9de5e41ff1efffd41a67d5a921e1afe9ea
test/extractor-tests/generated/decl/PatternBindingDecl/MISSING_SOURCE.txt 35fb32ea5393152eb7a875b20b4e3e4b8c7a997a8959c32417140d57a16a052d 35fb32ea5393152eb7a875b20b4e3e4b8c7a997a8959c32417140d57a16a052d

File diff suppressed because it is too large Load Diff

View File

@@ -35,6 +35,8 @@ instances
| accessors.swift:38:9:38:9 | set | getModule: | file://:0:0:0:0 | accessors | 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 | getModule: | file://:0:0:0:0 | accessors | getInterfaceType: | (Foo) -> () -> UnsafePointer<Int> | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | yes | isUnsafeMutableAddress: | no |
| accessors.swift:42:9:44:9 | unsafeMutableAddress | getModule: | file://:0:0:0:0 | accessors | getInterfaceType: | (inout Foo) -> () -> UnsafeMutablePointer<Int> | isGetter: | no | isSetter: | no | isWillSet: | no | isDidSet: | no | isRead: | no | isModify: | no | isUnsafeAddress: | no | isUnsafeMutableAddress: | yes |
getGenericTypeParam
getMember
getName
| accessors.swift:2:9:2:9 | _modify | (unnamed function decl) |
| accessors.swift:2:9:2:9 | get | (unnamed function decl) |
@@ -161,5 +163,3 @@ getBody
| accessors.swift:39:9:41:9 | unsafeAddress | accessors.swift:39:23:41:9 | { ... } |
| accessors.swift:42:9:44:9 | unsafeMutableAddress | accessors.swift:42:30:44:9 | { ... } |
getCapture
getGenericTypeParam
getMember

View File

@@ -36,6 +36,14 @@ query predicate instances(
else isUnsafeMutableAddress = "no"
}
query predicate getGenericTypeParam(Accessor x, int index, GenericTypeParamDecl getGenericTypeParam) {
toBeTested(x) and not x.isUnknown() and getGenericTypeParam = x.getGenericTypeParam(index)
}
query predicate getMember(Accessor x, int index, Decl getMember) {
toBeTested(x) and not x.isUnknown() and getMember = x.getMember(index)
}
query predicate getName(Accessor x, string getName) {
toBeTested(x) and not x.isUnknown() and getName = x.getName()
}
@@ -55,11 +63,3 @@ query predicate getBody(Accessor x, BraceStmt getBody) {
query predicate getCapture(Accessor x, int index, CapturedDecl getCapture) {
toBeTested(x) and not x.isUnknown() and getCapture = x.getCapture(index)
}
query predicate getGenericTypeParam(Accessor x, int index, GenericTypeParamDecl getGenericTypeParam) {
toBeTested(x) and not x.isUnknown() and getGenericTypeParam = x.getGenericTypeParam(index)
}
query predicate getMember(Accessor x, int index, Decl getMember) {
toBeTested(x) and not x.isUnknown() and getMember = x.getMember(index)
}

View File

@@ -3,6 +3,7 @@ instances
| extensions.swift:11:1:15:1 | extension of C | getModule: | file://:0:0:0:0 | extensions | getExtendedTypeDecl: | extensions.swift:3:1:3:10 | C |
| extensions.swift:21:1:23:1 | extension of S | getModule: | file://:0:0:0:0 | extensions | getExtendedTypeDecl: | extensions.swift:1:1:1:11 | S |
| extensions.swift:27:1:29:1 | extension of C | getModule: | file://:0:0:0:0 | extensions | getExtendedTypeDecl: | extensions.swift:3:1:3:10 | C |
getGenericTypeParam
getMember
| extensions.swift:5:1:9:1 | extension of S | 0 | extensions.swift:6:5:6:37 | var ... = ... |
| extensions.swift:5:1:9:1 | extension of S | 1 | extensions.swift:6:9:6:9 | x |
@@ -12,7 +13,6 @@ getMember
| extensions.swift:11:1:15:1 | extension of C | 2 | extensions.swift:14:5:14:17 | bar() |
| extensions.swift:21:1:23:1 | extension of S | 0 | extensions.swift:22:5:22:17 | baz() |
| extensions.swift:27:1:29:1 | extension of C | 0 | extensions.swift:28:5:28:17 | baz() |
getGenericTypeParam
getProtocol
| extensions.swift:21:1:23:1 | extension of S | 0 | extensions.swift:17:1:19:1 | P1 |
| extensions.swift:27:1:29:1 | extension of C | 0 | extensions.swift:17:1:19:1 | P1 |

View File

@@ -14,16 +14,16 @@ query predicate instances(
getExtendedTypeDecl = x.getExtendedTypeDecl()
}
query predicate getMember(ExtensionDecl x, int index, Decl getMember) {
toBeTested(x) and not x.isUnknown() and getMember = x.getMember(index)
}
query predicate getGenericTypeParam(
ExtensionDecl x, int index, GenericTypeParamDecl getGenericTypeParam
) {
toBeTested(x) and not x.isUnknown() and getGenericTypeParam = x.getGenericTypeParam(index)
}
query predicate getMember(ExtensionDecl x, int index, Decl getMember) {
toBeTested(x) and not x.isUnknown() and getMember = x.getMember(index)
}
query predicate getProtocol(ExtensionDecl x, int index, ProtocolDecl getProtocol) {
toBeTested(x) and not x.isUnknown() and getProtocol = x.getProtocol(index)
}

View File

@@ -4,6 +4,10 @@ instances
| functions.swift:10:5:10:28 | noBody(x:) | getModule: | file://:0:0:0:0 | functions | getInterfaceType: | <Self where Self : Beep> (Self) -> (Int) -> Int |
| functions.swift:13:1:15:1 | variadic(_:) | getModule: | file://:0:0:0:0 | functions | getInterfaceType: | (Int...) -> () |
| functions.swift:17:1:19:1 | generic(x:y:) | getModule: | file://:0:0:0:0 | functions | getInterfaceType: | <X, Y> (X, Y) -> () |
getGenericTypeParam
| functions.swift:17:1:19:1 | generic(x:y:) | 0 | functions.swift:17:14:17:14 | X |
| functions.swift:17:1:19:1 | generic(x:y:) | 1 | functions.swift:17:17:17:17 | Y |
getMember
getName
| functions.swift:1:1:3:1 | foo() | foo() |
| functions.swift:5:1:7:1 | bar(_:d:) | bar(_:d:) |
@@ -25,7 +29,3 @@ getBody
| functions.swift:13:1:15:1 | variadic(_:) | functions.swift:13:31:15:1 | { ... } |
| functions.swift:17:1:19:1 | generic(x:y:) | functions.swift:17:32:19:1 | { ... } |
getCapture
getGenericTypeParam
| functions.swift:17:1:19:1 | generic(x:y:) | 0 | functions.swift:17:14:17:14 | X |
| functions.swift:17:1:19:1 | generic(x:y:) | 1 | functions.swift:17:17:17:17 | Y |
getMember

View File

@@ -14,6 +14,16 @@ query predicate instances(
getInterfaceType = x.getInterfaceType()
}
query predicate getGenericTypeParam(
NamedFunction x, int index, GenericTypeParamDecl getGenericTypeParam
) {
toBeTested(x) and not x.isUnknown() and getGenericTypeParam = x.getGenericTypeParam(index)
}
query predicate getMember(NamedFunction x, int index, Decl getMember) {
toBeTested(x) and not x.isUnknown() and getMember = x.getMember(index)
}
query predicate getName(NamedFunction x, string getName) {
toBeTested(x) and not x.isUnknown() and getName = x.getName()
}
@@ -33,13 +43,3 @@ query predicate getBody(NamedFunction x, BraceStmt getBody) {
query predicate getCapture(NamedFunction x, int index, CapturedDecl getCapture) {
toBeTested(x) and not x.isUnknown() and getCapture = x.getCapture(index)
}
query predicate getGenericTypeParam(
NamedFunction x, int index, GenericTypeParamDecl getGenericTypeParam
) {
toBeTested(x) and not x.isUnknown() and getGenericTypeParam = x.getGenericTypeParam(index)
}
query predicate getMember(NamedFunction x, int index, Decl getMember) {
toBeTested(x) and not x.isUnknown() and getMember = x.getMember(index)
}