Swift: make hideability spread upward in the hierarchy

This commit is contained in:
Paolo Tranquilli 2023-05-23 12:17:03 +02:00
Родитель b19194bd06
Коммит b4edc92079
29 изменённых файлов: 174 добавлений и 213 удалений

Просмотреть файл

@ -166,7 +166,6 @@ def get_ql_class(cls: schema.Class, lookup: typing.Dict[str, schema.Class]) -> q
ipa=bool(cls.ipa),
doc=cls.doc,
hideable=cls.hideable,
hideable_root=cls.hideable_root,
**pragmas,
)

Просмотреть файл

@ -114,7 +114,6 @@ class Class:
ql_internal: bool = False
ipa: bool = False
doc: List[str] = field(default_factory=list)
hideable_root: bool = False
hideable: bool = False
def __post_init__(self):

Просмотреть файл

@ -91,7 +91,6 @@ class Class:
"""^^^ filled with `True` for non-final classes with only synthesized final descendants """
doc: List[str] = field(default_factory=list)
default_doc_name: Optional[str] = None
hideable_root: bool = False
hideable: bool = False
@property

Просмотреть файл

@ -39,7 +39,6 @@ def _get_class(cls: type) -> schema.Class:
group=getattr(cls, "_group", ""),
hideable=getattr(cls, "_hideable", False),
# in the following we don't use `getattr` to avoid inheriting
hideable_root=cls.__dict__.get("_hideable", False),
pragmas=cls.__dict__.get("_pragmas", []),
ipa=cls.__dict__.get("_ipa", None),
properties=[
@ -96,6 +95,18 @@ def _fill_ipa_information(classes: typing.Dict[str, schema.Class]):
cls.ipa = True
def _fill_hideable_information(classes: typing.Dict[str, schema.Class]):
""" Update the class map propagating the `hideable` attribute upwards in the hierarchy """
todo = [cls for cls in classes.values() if cls.hideable]
while todo:
cls = todo.pop()
for base in cls.bases:
supercls = classes[base]
if not supercls.hideable:
supercls.hideable = True
todo.append(supercls)
def load(m: types.ModuleType) -> schema.Schema:
includes = set()
classes = {}
@ -124,6 +135,7 @@ def load(m: types.ModuleType) -> schema.Schema:
cls.is_null_class = True
_fill_ipa_information(classes)
_fill_hideable_information(classes)
return schema.Schema(includes=includes, classes=_toposort_classes_by_group(classes), null=null)

Просмотреть файл

@ -37,8 +37,7 @@ module Generated {
* Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs.
*/
final string getPrimaryQlClasses() { result = concat(this.getAPrimaryQlClass(), ",") }
{{/root}}
{{#hideable_root}}
/**
* Gets the most immediate element that should substitute this element in the explicit AST, if any.
* Classes can override this to indicate this node should be in the "hidden" AST, mostly reserved
@ -55,7 +54,7 @@ module Generated {
or
result = this.getResolveStep().resolve()
}
{{/hideable_root}}
{{/root}}
{{#final}}
override string getAPrimaryQlClass() { result = "{{name}}" }
{{/final}}

Просмотреть файл

@ -64,10 +64,6 @@ none()
{{/final}}
{{/classes}}
}
Element resolve(Element e) {
{{#classes}}{{#hideable_root}}if e instanceof {{name}} then result = e.({{name}}).resolve() else {{/hideable_root}}{{/classes}}result = e
}
}
/**
@ -75,21 +71,21 @@ Element resolve(Element e) {
* if `e` has conversions, `getImmediateParent(e)` will give the innermost conversion in the hidden AST.
*/
Element getImmediateParent(Element e) {
// `unique` is used here to tell the optimizer that there is in fact only one result
// this is tested by the `library-tests/parent/no_double_parents.ql` test
result = unique(Element x | e = Impl::getImmediateChild(x, _, _) | x)
// `unique` is used here to tell the optimizer that there is in fact only one result
// this is tested by the `library-tests/parent/no_double_parents.ql` test
result = unique(Element x | e = Impl::getImmediateChild(x, _, _) | x)
}
/**
* Gets the immediate child indexed at `index`. Indexes are not guaranteed to be contiguous, but are guaranteed to be distinct. `accessor` is bound the member predicate call resulting in the given child.
*/
Element getImmediateChildAndAccessor(Element e, int index, string accessor) {
exists(string partialAccessor | result = Impl::getImmediateChild(e, index, partialAccessor) and accessor = "get" + partialAccessor)
exists(string partialAccessor | result = Impl::getImmediateChild(e, index, partialAccessor) and accessor = "get" + partialAccessor)
}
/**
* Gets the child indexed at `index`. Indexes are not guaranteed to be contiguous, but are guaranteed to be distinct. `accessor` is bound the member predicate call resulting in the given child.
*/
Element getChildAndAccessor(Element e, int index, string accessor) {
exists(string partialAccessor | result = Impl::resolve(Impl::getImmediateChild(e, index, partialAccessor)) and accessor = "get" + partialAccessor)
exists(string partialAccessor | result = Impl::getImmediateChild(e, index, partialAccessor).resolve() and accessor = "get" + partialAccessor)
}

Просмотреть файл

@ -880,14 +880,6 @@ def test_hideable_class(generate_classes):
}
def test_hideable_root_class(generate_classes):
assert generate_classes([
schema.Class("MyObject", hideable_root=True),
]) == {
"MyObject.qll": (a_ql_stub(name="MyObject"), a_ql_class(name="MyObject", final=True, hideable_root=True)),
}
def test_hideable_property(generate_classes):
assert generate_classes([
schema.Class("MyObject", hideable=True),

Просмотреть файл

@ -698,11 +698,22 @@ def test_hideable():
class A(Root):
pass
class B(A):
class IndirectlyHideable(Root):
pass
assert data.classes["A"] == schema.Class("A", bases=["Root"], derived={"B"}, hideable_root=True, hideable=True)
assert data.classes["B"] == schema.Class("B", bases=["A"], hideable=True)
class B(A, IndirectlyHideable):
pass
class NonHideable(Root):
pass
assert data.classes == {
"Root": schema.Class("Root", derived={"A", "IndirectlyHideable", "NonHideable"}, hideable=True),
"A": schema.Class("A", bases=["Root"], derived={"B"}, hideable=True),
"IndirectlyHideable": schema.Class("IndirectlyHideable", bases=["Root"], derived={"B"}, hideable=True),
"B": schema.Class("B", bases=["A", "IndirectlyHideable"], hideable=True),
"NonHideable": schema.Class("NonHideable", bases=["Root"], hideable=False),
}
if __name__ == '__main__':

23
swift/ql/.generated.list сгенерированный
Просмотреть файл

@ -365,7 +365,7 @@ lib/codeql/swift/elements/type/VariadicSequenceType.qll 325e4c4481e9ac07acdc6aeb
lib/codeql/swift/elements/type/VariadicSequenceTypeConstructor.qll 0d1d2328a3b5e503a883e7e6d7efd0ca5e7f2633abead9e4c94a9f98ed3cb223 69bff81c1b9413949eacb9298d2efb718ea808e68364569a1090c9878c4af856
lib/codeql/swift/elements/type/WeakStorageType.qll 7c07739cfc1459f068f24fef74838428128054adf611504d22532e4a156073e7 9c968414d7cc8d672f3754bced5d4f83f43a6d7872d0d263d79ff60483e1f996
lib/codeql/swift/elements/type/WeakStorageTypeConstructor.qll d88b031ef44d6de14b3ddcff2eb47b53dbd11550c37250ff2edb42e5d21ec3e9 26d855c33492cf7a118e439f7baeed0e5425cfaf058b1dcc007eca7ed765c897
lib/codeql/swift/elements.qll cba02ae777269061af0713f6b003c97679434ddc8b2e871fc00c5d17c5265d2a cba02ae777269061af0713f6b003c97679434ddc8b2e871fc00c5d17c5265d2a
lib/codeql/swift/elements.qll 3df0060edd2b2030f4e4d7d5518afe0073d798474d9b1d6185d833bec63ca8bd 3df0060edd2b2030f4e4d7d5518afe0073d798474d9b1d6185d833bec63ca8bd
lib/codeql/swift/generated/AstNode.qll 02ca56d82801f942ae6265c6079d92ccafdf6b532f6bcebd98a04029ddf696e4 6216fda240e45bd4302fa0cf0f08f5f945418b144659264cdda84622b0420aa2
lib/codeql/swift/generated/AvailabilityInfo.qll 1e38e7f52ccbcecd4dd088eae15c482d87911682dabb426332cc0e207fc6bf2f 7c6640530cdbece90d4172e8d6cfd119656860da08bb61ed4ef3a6757723994f
lib/codeql/swift/generated/AvailabilitySpec.qll fb1255f91bb5e41ad4e9c675a2efbc50d0fb366ea2de68ab7eebd177b0795309 144e0c2e7d6c62ecee43325f7f26dcf437881edf0b75cc1bc898c6c4b61fdeaf
@ -374,23 +374,22 @@ lib/codeql/swift/generated/Comment.qll f58b49f6e68c21f87c51e2ff84c8a64b09286d733
lib/codeql/swift/generated/DbFile.qll a49b2a2cb2788cb49c861ebcd458b8daead7b15adb19c3a9f4db3bf39a0051fc a49b2a2cb2788cb49c861ebcd458b8daead7b15adb19c3a9f4db3bf39a0051fc
lib/codeql/swift/generated/DbLocation.qll b9baea963d9fa82068986512c0649d1050897654eee3df51dba17cf6b1170873 b9baea963d9fa82068986512c0649d1050897654eee3df51dba17cf6b1170873
lib/codeql/swift/generated/Diagnostics.qll d2ee2db55e932dcaee95fcc1164a51ffbe1a78d86ee0f50aabb299b458462afe 566d554d579cadde26dc4d1d6b1750ca800511201b737b629f15b6f873af3733
lib/codeql/swift/generated/Element.qll 1c6a757f3c1218b02a98f075b2cfb5bd0cc31dff31bd1d04acdf4d4f040dee45 a3221cd9250706e6313a82450466326e5a1e6ffa5ae0b308e943d0979d03919e
lib/codeql/swift/generated/Element.qll 81a01c1965cf8154596c753b20536ef8630b30567d8c077660ab2d11143f060b 74f5c76db5ec82a9c1675ec0282acd44f1a86ef447d1961c47aea3eed50f79cb
lib/codeql/swift/generated/ErrorElement.qll 4b032abe8ffb71376a29c63e470a52943ace2527bf7b433c97a8bf716f9ad102 4f2b1be162a5c275e3264dbc51bf98bce8846d251be8490a0d4b16cbc85f630f
lib/codeql/swift/generated/File.qll f88c485883dd9b2b4a366080e098372912e03fb3177e5cae58aa4449c2b03399 0333c49e3a11c48e6146a7f492ee31ac022d80150fc3f8bfafc3c8f94d66ff76
lib/codeql/swift/generated/HideableElement.qll 0eb3bb2fd9fb2b5ba444f4cd1aa4f91c87926618dcfa0051b048cf9d63f9602e 0eb3bb2fd9fb2b5ba444f4cd1aa4f91c87926618dcfa0051b048cf9d63f9602e
lib/codeql/swift/generated/KeyPathComponent.qll c79c7bc04fc1426992ab472eedc1a20a7aa496ff3f43305400022f1a02ba44f4 a9935b68b511329d157bcd7a7d27aa4803d2163306db8b41808a2b736f80f4d8
lib/codeql/swift/generated/Locatable.qll be20967d48a34cdba126fe298606e0adc11697831f097acba9c52a0b7ce9983e 8aa01bc376614abbc3209e25785c72f86c9b4e94bb5f471a4a0677fedaec4f61
lib/codeql/swift/generated/Location.qll c5793987e77812059a28254dadee29bfe9b38153c0399fbb1bf6a2f5c237fdab 6e6d8802b021e36bbaad81845657769dd48a798ea33080ada05e9818a20b38f7
lib/codeql/swift/generated/OtherAvailabilitySpec.qll 0e26a203b26ff0581b7396b0c6d1606feec5cc32477f676585cdec4911af91c5 0e26a203b26ff0581b7396b0c6d1606feec5cc32477f676585cdec4911af91c5
lib/codeql/swift/generated/ParentChild.qll ffec94e3ee076ff73dd7b4e6561c8d8c1f9a198547085baa40a1e5e28adc5827 a28adf13137431f55ce218ade6848bf5b853d3f27315765e9e6c45032c02ddd3
lib/codeql/swift/generated/ParentChild.qll 7d2d0628965c38d59877fed220b39bd3b02d3652990caf7eeabe966b73534c7d a5a9df21d0a6a00aed6ebb60f13fea3456bf97ca84a140ebca52610eb7c8ff8b
lib/codeql/swift/generated/PlatformVersionAvailabilitySpec.qll f82d9ca416fe8bd59b5531b65b1c74c9f317b3297a6101544a11339a1cffce38 7f5c6d3309e66c134107afe55bae76dfc9a72cb7cdd6d4c3706b6b34cee09fa0
lib/codeql/swift/generated/PureSynthConstructors.qll 173c0dd59396a1de26fe870e3bc2766c46de689da2a4d8807cb62023bbce1a98 173c0dd59396a1de26fe870e3bc2766c46de689da2a4d8807cb62023bbce1a98
lib/codeql/swift/generated/Raw.qll 56e12381886fe9eb6aef74968cb542e179116ad6722640a21bda37f1d9d26e77 ae93d0caebecf3ce593c95887b44cd1686b5c7e989d5cce4bb39d97312c3cb68
lib/codeql/swift/generated/Synth.qll 14dbc93375bcde4d792c1ec6157ee9c825119dcc9de31bcfeea56b3636f32d27 e84970ed295aa0af59135ee09b9cddbd6a26dcbce3baaf0e2a958b0552aac6d1
lib/codeql/swift/generated/Raw.qll 8d4880e5ee1fdd120adeb7bf0dfa1399e7b1a53b2cc7598aed8e15cbf996d1c0 da0d446347d29f5cd05281c17c24e87610f31c32adb7e05ab8f3a26bed55bd90
lib/codeql/swift/generated/Synth.qll 551fdf7e4b53f9ee1314d1bb42c2638cf82f45bfa1f40a635dfa7b6072e4418c 9ab178464700a19951fc5285acacda4913addee81515d8e072b3d7055935a814
lib/codeql/swift/generated/SynthConstructors.qll 2f801bd8b0db829b0253cd459ed3253c1fdfc55dce68ebc53e7fec138ef0aca4 2f801bd8b0db829b0253cd459ed3253c1fdfc55dce68ebc53e7fec138ef0aca4
lib/codeql/swift/generated/UnknownFile.qll 0fcf9beb8de79440bcdfff4bb6ab3dd139bd273e6c32754e05e6a632651e85f6 0fcf9beb8de79440bcdfff4bb6ab3dd139bd273e6c32754e05e6a632651e85f6
lib/codeql/swift/generated/UnknownLocation.qll e50efefa02a0ec1ff635a00951b5924602fc8cab57e5756e4a039382c69d3882 e50efefa02a0ec1ff635a00951b5924602fc8cab57e5756e4a039382c69d3882
lib/codeql/swift/generated/UnspecifiedElement.qll 2b66070944ad36316476b6bf8a811131ca6d4232591353b2b23e881b547463cc c9bff46bcb6f6d106eb57ab8bb04584d9a0b2513abdc1be6e98c0bd227c5f1e0
lib/codeql/swift/generated/UnspecifiedElement.qll ad04c197266069baf505e529e62751ab3056b4bac5db378fe1f79bbdfa29e066 a5058c7e3e0ba7d52710161e349a71f3e963d4abe07ca581ad663395fc50e972
lib/codeql/swift/generated/decl/AbstractStorageDecl.qll 4e827d05b3b98c043f925a3bd9c00622da3dc6e3d3406f5a18b2c3a684e3774f 47e5767a6f9a87f848cccce651d8c40af8aa3e0e727fc147cbf4d5a2a3e483d9
lib/codeql/swift/generated/decl/AbstractTypeParamDecl.qll 1e268b00d0f2dbbd85aa70ac206c5e4a4612f06ba0091e5253483635f486ccf9 5479e13e99f68f1f347283535f8098964f7fd4a34326ff36ad5711b2de1ab0d0
lib/codeql/swift/generated/decl/Accessor.qll c93cdf7dbb87e6c9b09b5fcf469b952041f753914a892addeb24bb46eaa51d29 1e8104da2da146d3e4d8f5f96b87872e63162e53b46f9c7038c75db51a676599
@ -409,7 +408,7 @@ lib/codeql/swift/generated/decl/Function.qll 92d1fbceb9e96afd00a1dfbfd15cec0063b
lib/codeql/swift/generated/decl/GenericContext.qll 9f7e17d11bf898429a921ba7726b07aab382c97f8326bd186f2bded3d090852c 14d558b6e498d49b850f862d85091a11954dad13f16c60f700cf2c66fa37c473
lib/codeql/swift/generated/decl/GenericTypeDecl.qll 71f5c9c6078567dda0a3ac17e2d2d590454776b2459267e31fed975724f84aec 669c5dbd8fad8daf007598e719ac0b2dbcb4f9fad698bffb6f1d0bcd2cee9102
lib/codeql/swift/generated/decl/GenericTypeParamDecl.qll bc41a9d854e65b1e0da86350870a8fe050eb1dc031cd17ded11c15b5ad8ad183 bc41a9d854e65b1e0da86350870a8fe050eb1dc031cd17ded11c15b5ad8ad183
lib/codeql/swift/generated/decl/IfConfigDecl.qll 085e2c70d3e158b7f3d3d3ade94593f1331d681d07da8a968c537830a67a62fe 19bb842314e8edb6a8dce4d78ec8043a527f13569da8be4ad03ba876a09998a5
lib/codeql/swift/generated/decl/IfConfigDecl.qll f1decc68b28dfb43ec70070156d19d6ef0943d8cf375ea639adf13da19398586 75fe6359304693a002987d57865d52b9fca84023752432c98e2f0dbc2830da7e
lib/codeql/swift/generated/decl/ImportDecl.qll 542405d7a75659d048d1ff8894a0cc0d357802c2936407ec39b7e4f69d2dd864 41ee9a9f1fc8068db587ac786145cf50f74f74161555ca94b502a57cca23288a
lib/codeql/swift/generated/decl/InfixOperatorDecl.qll 3da133c325380fbc10448b731d5826959056ca861d3a0661e7c37694e5ccb208 bb81c8e1597a1fb7e791e3c4c4ed28a73c442591bff2b12d13a7a327a7b6db08
lib/codeql/swift/generated/decl/Initializer.qll a72005f0abebd31b7b91f496ddae8dff49a027ba01b5a827e9b8870ecf34de17 a72005f0abebd31b7b91f496ddae8dff49a027ba01b5a827e9b8870ecf34de17
@ -484,7 +483,7 @@ lib/codeql/swift/generated/expr/ErrorExpr.qll 8e354eed5655e7261d939f3831eb6fa296
lib/codeql/swift/generated/expr/ExistentialMetatypeToObjectExpr.qll eb0d42aac3f6331011a0e26cf5581c5e0a1b5523d2da94672abdebe70000d65b efe2bc0424e551454acc919abe4dac7fd246b84f1ae0e5d2e31a49cbcf84ce40
lib/codeql/swift/generated/expr/ExplicitCastExpr.qll 162f94461d41cf10a81567e13d5141d7aca417cc92d4ef55de97c7909681882e c8e7d1f569265a9bc2ae6a82e33783ec3ac077c3ae6e582edcb49a4eb816f7b5
lib/codeql/swift/generated/expr/ExplicitClosureExpr.qll c5291fb91e04a99133d1b4caf25f8bd6e7f2e7b9d5d99558143899f4dc9a7861 c5291fb91e04a99133d1b4caf25f8bd6e7f2e7b9d5d99558143899f4dc9a7861
lib/codeql/swift/generated/expr/Expr.qll 91b45df8d77ece59147e330b1a93515ad791e1da84128a079be2160ee5f87796 4a57263c533d9d5a9e1cacc997d09434fe7ebbabff9ac1a49602b618b828839b
lib/codeql/swift/generated/expr/Expr.qll b09ddd296693ad78a2b0e7dc17d2b746357ae88645b046a026861eafeba616cb 498c628f904fbf48be10f32b146168b71f8f7d9f829614e422020701ccc0f8e4
lib/codeql/swift/generated/expr/FloatLiteralExpr.qll ae851773886b3d33ab5535572a4d6f771d4b11d6c93e802f01348edb2d80c454 35f103436fc2d1b2cec67b5fbae07b28c054c9687d57cbd3245c38c55d8bde0b
lib/codeql/swift/generated/expr/ForceTryExpr.qll 062997b5e9a9e993de703856ae6af60fe1950951cf77cdab11b972fb0a5a4ed3 062997b5e9a9e993de703856ae6af60fe1950951cf77cdab11b972fb0a5a4ed3
lib/codeql/swift/generated/expr/ForceValueExpr.qll cd7ee5fa4a6f7094c7fbb9c5831f60d5ce18b123fe7beea3dcb26ca78e387118 7cdef6e9b501f9e9cb0d48828e68b349b25e4e5f312e5bcee91868ae8b196e7d
@ -565,10 +564,10 @@ lib/codeql/swift/generated/pattern/IsPattern.qll c809159dff26b86d44f560742d66e75
lib/codeql/swift/generated/pattern/NamedPattern.qll 5d25e51eb83e86363b95a6531ffb164e5a6070b4a577f3900140edbef0e83c71 9e88b2b2b90a547b402d4782e8d494bc555d4200763c094dd985fe3b7ebc1ec8
lib/codeql/swift/generated/pattern/OptionalSomePattern.qll 5b9c7032584619d4921d1a1324e3ce4bd7207f0d4daa703e1e059f983bf1b132 e6d44514cd123a7ad27f657a2b83d46277a961a849139380ece886430a862920
lib/codeql/swift/generated/pattern/ParenPattern.qll 337cb03dcb7384f7ef13e35d843b3498c0ae391374f5e870d1e52c2d1baacd95 cba288ee99726f5bbf15cf61971e000a835cf6e8b7507dcf6f6c6dea91ec287a
lib/codeql/swift/generated/pattern/Pattern.qll abdb00ae9ee55061de85fa77ecff6f3df9ddf395f45a38dde94983ac423d861a 67ffece7bd83150bb0981b2fda86468c2df7c4d2015526b90ca40c71eec6b542
lib/codeql/swift/generated/pattern/Pattern.qll 0e96528a8dd87185f4fb23ba33ea418932762127e99739d7e56e5c8988e024d1 ba1e010c9f7f891048fb8c4ff8ea5a6c664c09e43d74b860d559f6459f82554a
lib/codeql/swift/generated/pattern/TuplePattern.qll b3a138b0942f7e3eecb52ad2f095584a6cd5f555e9487c6eaad6a5527ae99f0c d6ff67ecc7395571acef4b82da514cb737c72d97ea557d89da534469feda340c
lib/codeql/swift/generated/pattern/TypedPattern.qll 6a9fd2815755eddc6918d6be8221c7afb90e4fba4fcb8eb54ff42754269bb481 f198c3b09553a5f5f3d97f8088ef82c00552b9635560750c56d801b09dbd9e26
lib/codeql/swift/generated/stmt/BraceStmt.qll 72557bdbde907042a936b55039e6032afd5eb92b21a6bb3d669437f3141a7e76 a2fb52f3d77444880edcafec6d107f27cf8c528c21241b1222823136fd4cfbb9
lib/codeql/swift/generated/stmt/BraceStmt.qll eea1a33767c14a3b96aea6bbe10f17c3ecd1d8ac263de07e475e23b46d85a20d a5ee6c19a38e968c245886c28c82513f39ca90a80a9ea11d0e3139a35f682046
lib/codeql/swift/generated/stmt/BreakStmt.qll 879cf66911cc7f53e7e8f4ae8244681018fb17d6501b269fb7cf9d8481f0b539 c78fc1b0e3e76321fc1653aa8b0aabaaacf082e01a003b78f693b106cc05faa0
lib/codeql/swift/generated/stmt/CaseLabelItem.qll 9536d2909a274c3a969eec25f8e5966adfaa9b0d6451ea6319d9f7bb2fd6fe07 02e25f036db50e9a6e9a7ceab6002dd605b73afb55fa1dee6f22e7af33a40913
lib/codeql/swift/generated/stmt/CaseStmt.qll c180478c6161439bc76bd39edfab343faba7450900ffedcadd3ccea12dc3a08c b537eb517db76113cfbc91c59e6bdfbf16ff83d639dfe6fd6892171f71a97090
@ -647,7 +646,7 @@ lib/codeql/swift/generated/type/SubstitutableType.qll 9e74ec2d281cd3dedbc5791d66
lib/codeql/swift/generated/type/SugarType.qll 4ea82201ae20e769c0c3e6e158bae86493e1b16bbd3ef6495e2a3760baa1fc6b 6c78df86db6f9c70398484819a9b9ecc8ee337b0a4ac2d84e17294951a6fd788
lib/codeql/swift/generated/type/SyntaxSugarType.qll 253e036452e0ba8ae3bb60d6ed22f4efb8436f4ef19f158f1114a6f9a14df42c 743fe4dede40ca173b19d5757d14e0f606fe36f51119445503e8eea7cf6df3b0
lib/codeql/swift/generated/type/TupleType.qll af224031c3bea6dfca6138903cca940a4f00ba6494ad7b591b9f017d69ee9a6c f59ad1bb4994196ec49836ae169e550a70dbb25a359ff889ed6456882fe2d9a0
lib/codeql/swift/generated/type/Type.qll ada3973ed840643fa9f015d721d1f3c58994cda46b169e875b77473281d9122f 6a43dc43be0ac6f315b58ca4dc9b015769281eb5011220f28b5e9b6ed9436207
lib/codeql/swift/generated/type/Type.qll c08acc943c9b52662a465d77fcd39d12f869c42b24a3755225b3bddbb1cf72f5 6d82c5bddded75fd5598bb559ecfa07360ad802d5e9541af2c334dc9d0159335
lib/codeql/swift/generated/type/TypeAliasType.qll 7c1397c4a145d3265e8d1b4dac4ae6a58a2c4026145cfb2d8d28c01309b0ea26 0e3c3a2c166285f4ac1b417b8cc74a5095c8a8e1a102d7b5ca2829a06b61de23
lib/codeql/swift/generated/type/TypeRepr.qll 25a412f029bf2d4b283ea07f0f0ff5713b1b4f369f8cb06991328fdee030e14a 2a39717f2e023c96015b797b59812b0e0bef1ea2780ee83869b68da549abbf2f
lib/codeql/swift/generated/type/UnarySyntaxSugarType.qll 6f3822691d04531cc1dd6a78fb184f3e18d42ee324123dc4338fdd368fbd0bd6 d489aac77955de0d71fd5c271fddccd40050db4ef8ce8d817320ca9554057c3a

1
swift/ql/.gitattributes сгенерированный поставляемый
Просмотреть файл

@ -379,7 +379,6 @@
/lib/codeql/swift/generated/Element.qll linguist-generated
/lib/codeql/swift/generated/ErrorElement.qll linguist-generated
/lib/codeql/swift/generated/File.qll linguist-generated
/lib/codeql/swift/generated/HideableElement.qll linguist-generated
/lib/codeql/swift/generated/KeyPathComponent.qll linguist-generated
/lib/codeql/swift/generated/Locatable.qll linguist-generated
/lib/codeql/swift/generated/Location.qll linguist-generated

Просмотреть файл

@ -98,7 +98,7 @@ private predicate isBooleanConstant(ControlFlowElement n, boolean value) {
// Boolean constants hidden inside conversions are also
// constants that resolve to the same value.
exists(ControlFlowElement parent |
parent.asAstNode() = n.asAstNode().(HideableElement).getResolveStep() and
parent.asAstNode() = n.asAstNode().getResolveStep() and
isBooleanConstant(parent, value)
)
}
@ -122,9 +122,9 @@ private predicate inBooleanContext(ControlFlowElement n) {
private predicate astInBooleanContext(AstNode n) {
n = any(ConditionElement condElem).getBoolean().getFullyUnresolved()
or
n = any(ConditionElement condElem).getAvailability()
n = any(ConditionElement condElem).getAvailability().getFullyUnresolved()
or
n = any(StmtCondition stmtCond)
n = any(StmtCondition stmtCond).getFullyUnresolved()
or
exists(RepeatWhileStmt repeat | n = repeat.getCondition().getFullyConverted())
or

Просмотреть файл

@ -264,7 +264,7 @@ module Stmts {
or
child.asAstNode() = ast.getAnElement().getBoolean().getFullyConverted()
or
child.asAstNode() = ast.getAnElement().getAvailability()
child.asAstNode() = ast.getAnElement().getAvailability().getFullyUnresolved()
}
predicate firstElement(int i, ControlFlowElement first) {
@ -278,7 +278,7 @@ module Stmts {
astFirst(ast.getElement(i).getBoolean().getFullyConverted(), first)
or
// ... or an availability check.
astFirst(ast.getElement(i).getAvailability(), first)
astFirst(ast.getElement(i).getAvailability().getFullyUnresolved(), first)
)
}
@ -296,7 +296,7 @@ module Stmts {
astLast(ast.getElement(i).getBoolean().getFullyConverted(), pred, c)
or
// ... or the availability check ...
astLast(ast.getElement(i).getAvailability(), pred, c)
astLast(ast.getElement(i).getAvailability().getFullyUnresolved(), pred, c)
) and
// We evaluate the next element
c instanceof NormalCompletion and
@ -313,7 +313,7 @@ module Stmts {
not c.(MatchingCompletion).isMatch()
or
// Stop if an availability check failed
astLast(ast.getAnElement().getAvailability(), last, c) and
astLast(ast.getAnElement().getAvailability().getFullyUnresolved(), last, c) and
c instanceof FalseCompletion
or
// Stop if we successfully evaluated all the conditionals
@ -322,7 +322,7 @@ module Stmts {
or
astLast(ast.getLastElement().getPattern().getFullyUnresolved(), last, c)
or
astLast(ast.getLastElement().getAvailability(), last, c)
astLast(ast.getLastElement().getAvailability().getFullyUnresolved(), last, c)
) and
c instanceof NormalCompletion
}
@ -342,14 +342,14 @@ module Stmts {
override IfStmt ast;
final override predicate propagatesAbnormal(ControlFlowElement child) {
child.asAstNode() = ast.getCondition() or
child.asAstNode() = ast.getCondition().getFullyUnresolved() or
child.asAstNode() = ast.getThen() or
child.asAstNode() = ast.getElse()
}
final override predicate last(ControlFlowElement last, Completion c) {
// Condition exits with a false completion and there is no `else` branch
astLast(ast.getCondition(), last, c) and
astLast(ast.getCondition().getFullyUnresolved(), last, c) and
c instanceof FalseOrNonMatchCompletion and
not exists(ast.getElse())
or
@ -360,10 +360,10 @@ module Stmts {
final override predicate succ(ControlFlowElement pred, ControlFlowElement succ, Completion c) {
// Pre-order: flow from statement itself to first element of condition
pred.asAstNode() = ast and
astFirst(ast.getCondition(), succ) and
astFirst(ast.getCondition().getFullyUnresolved(), succ) and
c instanceof SimpleCompletion
or
astLast(ast.getCondition(), pred, c) and
astLast(ast.getCondition().getFullyUnresolved(), pred, c) and
(
// Flow from last element of condition to first element of then branch
c instanceof TrueOrMatchCompletion and
@ -380,7 +380,7 @@ module Stmts {
override GuardStmt ast;
final override predicate propagatesAbnormal(ControlFlowElement child) {
child.asAstNode() = ast.getCondition() or
child.asAstNode() = ast.getCondition().getFullyUnresolved() or
child.asAstNode() = ast.getBody()
}
@ -390,18 +390,18 @@ module Stmts {
c instanceof NormalCompletion
or
// Exit when a condition is true
astLast(ast.getCondition(), last, c) and
astLast(ast.getCondition().getFullyUnresolved(), last, c) and
c instanceof TrueOrMatchCompletion
}
final override predicate succ(ControlFlowElement pred, ControlFlowElement succ, Completion c) {
// Pre-order: flow from statement itself to first element of condition
pred.asAstNode() = ast and
astFirst(ast.getCondition(), succ) and
astFirst(ast.getCondition().getFullyUnresolved(), succ) and
c instanceof SimpleCompletion
or
// Flow to the body when the condition is false
astLast(ast.getCondition(), pred, c) and
astLast(ast.getCondition().getFullyUnresolved(), pred, c) and
c instanceof FalseOrNonMatchCompletion and
astFirst(ast.getBody(), succ)
}
@ -458,7 +458,9 @@ module Stmts {
private class WhileTree extends LoopTree {
override WhileStmt ast;
final override ControlFlowElement getCondition() { result.asAstNode() = ast.getCondition() }
final override ControlFlowElement getCondition() {
result.asAstNode() = ast.getCondition().getFullyUnresolved()
}
final override ControlFlowElement getBody() { result.asAstNode() = ast.getBody() }
@ -672,7 +674,7 @@ module Stmts {
final override predicate last(ControlFlowElement last, Completion c) {
// Case pattern exits with a non-match
astLast(ast.getLastLabel(), last, c) and
astLast(ast.getLastLabel().getFullyUnresolved(), last, c) and
not c.(MatchingCompletion).isMatch()
or
// Case body exits with any completion
@ -682,18 +684,18 @@ module Stmts {
override predicate succ(ControlFlowElement pred, ControlFlowElement succ, Completion c) {
// Pre-order: Flow from the case statement itself to the first label
pred.asAstNode() = ast and
astFirst(ast.getFirstLabel(), succ) and
astFirst(ast.getFirstLabel().getFullyUnresolved(), succ) and
c instanceof SimpleCompletion
or
// Left-to-right evaluation of labels until we find a match
exists(int i |
astLast(ast.getLabel(i), pred, c) and
astFirst(ast.getLabel(i + 1), succ) and
astLast(ast.getLabel(i).getFullyUnresolved(), pred, c) and
astFirst(ast.getLabel(i + 1).getFullyUnresolved(), succ) and
c.(MatchingCompletion).isNonMatch()
)
or
// Flow from last element of pattern to first element of body
astLast(ast.getALabel(), pred, c) and
astLast(ast.getALabel().getFullyUnresolved(), pred, c) and
astFirst(ast.getBody(), succ) and
c.(MatchingCompletion).isMatch()
}
@ -1162,7 +1164,7 @@ module Exprs {
override CaptureListExpr ast;
final override ControlFlowElement getChildElement(int i) {
result.asAstNode() = ast.getBindingDecl(i)
result.asAstNode() = ast.getBindingDecl(i).getFullyUnresolved()
or
i = ast.getNumberOfBindingDecls() and
result.asAstNode() = ast.getClosureBody().getFullyConverted()
@ -1794,7 +1796,9 @@ module AvailabilityInfo {
private class AvailabilityInfoTree extends AstStandardPostOrderTree {
override AvailabilityInfo ast;
final override ControlFlowElement getChildElement(int i) { result.asAstNode() = ast.getSpec(i) }
final override ControlFlowElement getChildElement(int i) {
result.asAstNode() = ast.getSpec(i).getFullyUnresolved()
}
}
private class AvailabilitySpecTree extends AstLeafTree {

1
swift/ql/lib/codeql/swift/elements.qll сгенерированный
Просмотреть файл

@ -10,7 +10,6 @@ import codeql.swift.elements.Diagnostics
import codeql.swift.elements.Element
import codeql.swift.elements.ErrorElement
import codeql.swift.elements.File
import codeql.swift.elements.HideableElement
import codeql.swift.elements.KeyPathComponent
import codeql.swift.elements.Locatable
import codeql.swift.elements.Location

Просмотреть файл

@ -1,7 +1,18 @@
private import codeql.swift.generated.Element
class Element extends Generated::Element {
private predicate resolvesFrom(Element e) { e.getResolveStep() = this }
override string toString() { result = this.getPrimaryQlClasses() }
Element getFullyUnresolved() {
not this.resolvesFrom(_) and result = this
or
exists(Element e |
this.resolvesFrom(e) and
result = e.getFullyUnresolved()
)
}
}
class UnknownElement extends Element {

Просмотреть файл

@ -1,14 +0,0 @@
private import codeql.swift.generated.HideableElement
class HideableElement extends Generated::HideableElement {
private predicate resolvesFrom(HideableElement e) { e.getResolveStep() = this }
HideableElement getFullyUnresolved() {
not this.resolvesFrom(_) and result = this
or
exists(HideableElement e |
this.resolvesFrom(e) and
result = e.getFullyUnresolved()
)
}
}

17
swift/ql/lib/codeql/swift/generated/Element.qll сгенерированный
Просмотреть файл

@ -24,6 +24,23 @@ module Generated {
*/
final string getPrimaryQlClasses() { result = concat(this.getAPrimaryQlClass(), ",") }
/**
* Gets the most immediate element that should substitute this element in the explicit AST, if any.
* Classes can override this to indicate this node should be in the "hidden" AST, mostly reserved
* for conversions and syntactic sugar nodes like parentheses.
*/
Element getResolveStep() { none() } // overridden by subclasses
/**
* Gets the element that should substitute this element in the explicit AST, applying `getResolveStep`
* transitively.
*/
final Element resolve() {
not exists(this.getResolveStep()) and result = this
or
result = this.getResolveStep().resolve()
}
/**
* Holds if this element is unknown.
*/

Просмотреть файл

@ -1,25 +0,0 @@
// generated by codegen/codegen.py
private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.Element
module Generated {
class HideableElement extends Synth::THideableElement, Element {
/**
* Gets the most immediate element that should substitute this element in the explicit AST, if any.
* Classes can override this to indicate this node should be in the "hidden" AST, mostly reserved
* for conversions and syntactic sugar nodes like parentheses.
*/
HideableElement getResolveStep() { none() } // overridden by subclasses
/**
* Gets the element that should substitute this element in the explicit AST, applying `getResolveStep`
* transitively.
*/
final HideableElement resolve() {
not exists(this.getResolveStep()) and result = this
or
result = this.getResolveStep().resolve()
}
}
}

52
swift/ql/lib/codeql/swift/generated/ParentChild.qll сгенерированный
Просмотреть файл

@ -50,21 +50,6 @@ private module Impl {
)
}
private Element getImmediateChildOfHideableElement(
HideableElement 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
@ -1043,19 +1028,14 @@ private module Impl {
}
private Element getImmediateChildOfExpr(Expr e, int index, string partialPredicateCall) {
exists(int b, int bAstNode, int bHideableElement, int n |
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
bHideableElement =
bAstNode + 1 +
max(int i | i = -1 or exists(getImmediateChildOfHideableElement(e, i, _)) | i) and
n = bHideableElement and
n = bAstNode and
(
none()
or
result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall)
or
result = getImmediateChildOfHideableElement(e, index - bAstNode, partialPredicateCall)
)
)
}
@ -3179,19 +3159,14 @@ private module Impl {
}
private Element getImmediateChildOfPattern(Pattern e, int index, string partialPredicateCall) {
exists(int b, int bAstNode, int bHideableElement, int n |
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
bHideableElement =
bAstNode + 1 +
max(int i | i = -1 or exists(getImmediateChildOfHideableElement(e, i, _)) | i) and
n = bHideableElement and
n = bAstNode and
(
none()
or
result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall)
or
result = getImmediateChildOfHideableElement(e, index - bAstNode, partialPredicateCall)
)
)
}
@ -3481,13 +3456,13 @@ private module Impl {
b = 0 and
bStmt = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfStmt(e, i, _)) | i) and
n = bStmt and
nElement = n + 1 + max(int i | i = -1 or exists(e.getElement(i)) | i) and
nElement = n + 1 + max(int i | i = -1 or exists(e.getImmediateElement(i)) | i) and
(
none()
or
result = getImmediateChildOfStmt(e, index - b, partialPredicateCall)
or
result = e.getElement(index - n) and
result = e.getImmediateElement(index - n) and
partialPredicateCall = "Element(" + (index - n).toString() + ")"
)
)
@ -3854,15 +3829,14 @@ private module Impl {
}
private Element getImmediateChildOfType(Type e, int index, string partialPredicateCall) {
exists(int b, int bHideableElement, int n |
exists(int b, int bElement, int n |
b = 0 and
bHideableElement =
b + 1 + max(int i | i = -1 or exists(getImmediateChildOfHideableElement(e, i, _)) | i) and
n = bHideableElement and
bElement = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfElement(e, i, _)) | i) and
n = bElement and
(
none()
or
result = getImmediateChildOfHideableElement(e, index - b, partialPredicateCall)
result = getImmediateChildOfElement(e, index - b, partialPredicateCall)
)
)
}
@ -5319,10 +5293,6 @@ private module Impl {
or
result = getImmediateChildOfVariadicSequenceType(e, index, partialAccessor)
}
Element resolve(Element e) {
if e instanceof HideableElement then result = e.(HideableElement).resolve() else result = e
}
}
/**
@ -5350,7 +5320,7 @@ Element getImmediateChildAndAccessor(Element e, int index, string accessor) {
*/
Element getChildAndAccessor(Element e, int index, string accessor) {
exists(string partialAccessor |
result = Impl::resolve(Impl::getImmediateChild(e, index, partialAccessor)) and
result = Impl::getImmediateChild(e, index, partialAccessor).resolve() and
accessor = "get" + partialAccessor
)
}

11
swift/ql/lib/codeql/swift/generated/Raw.qll сгенерированный
Просмотреть файл

@ -62,11 +62,6 @@ module Raw {
predicate isSuccessfullyExtracted() { file_is_successfully_extracted(this) }
}
/**
* INTERNAL: Do not use.
*/
class HideableElement extends @hideable_element, Element { }
/**
* INTERNAL: Do not use.
*/
@ -991,7 +986,7 @@ module Raw {
* INTERNAL: Do not use.
* The base class for all expressions in Swift.
*/
class Expr extends @expr, AstNode, HideableElement {
class Expr extends @expr, AstNode {
/**
* Gets the type of this expression, if it exists.
*/
@ -2358,7 +2353,7 @@ module Raw {
/**
* INTERNAL: Do not use.
*/
class Pattern extends @pattern, AstNode, HideableElement { }
class Pattern extends @pattern, AstNode { }
/**
* INTERNAL: Do not use.
@ -2874,7 +2869,7 @@ module Raw {
/**
* INTERNAL: Do not use.
*/
class Type extends @type, HideableElement {
class Type extends @type, Element {
/**
* Gets the name of this type.
*/

39
swift/ql/lib/codeql/swift/generated/Synth.qll сгенерированный
Просмотреть файл

@ -1043,11 +1043,6 @@ module Synth {
*/
class TFile = TDbFile or TUnknownFile;
/**
* INTERNAL: Do not use.
*/
class THideableElement = TExpr or TPattern or TType;
/**
* INTERNAL: Do not use.
*/
@ -3228,11 +3223,11 @@ module Synth {
or
result = convertGenericContextFromRaw(e)
or
result = convertHideableElementFromRaw(e)
or
result = convertLocatableFromRaw(e)
or
result = convertLocationFromRaw(e)
or
result = convertTypeFromRaw(e)
}
/**
@ -3277,19 +3272,6 @@ module Synth {
result = convertUnknownFileFromRaw(e)
}
/**
* INTERNAL: Do not use.
* Converts a raw DB element to a synthesized `THideableElement`, if possible.
*/
cached
THideableElement convertHideableElementFromRaw(Raw::Element e) {
result = convertExprFromRaw(e)
or
result = convertPatternFromRaw(e)
or
result = convertTypeFromRaw(e)
}
/**
* INTERNAL: Do not use.
* Converts a raw DB element to a synthesized `TLocatable`, if possible.
@ -6046,11 +6028,11 @@ module Synth {
or
result = convertGenericContextToRaw(e)
or
result = convertHideableElementToRaw(e)
or
result = convertLocatableToRaw(e)
or
result = convertLocationToRaw(e)
or
result = convertTypeToRaw(e)
}
/**
@ -6095,19 +6077,6 @@ module Synth {
result = convertUnknownFileToRaw(e)
}
/**
* INTERNAL: Do not use.
* Converts a synthesized `THideableElement` to a raw DB element, if possible.
*/
cached
Raw::Element convertHideableElementToRaw(THideableElement e) {
result = convertExprToRaw(e)
or
result = convertPatternToRaw(e)
or
result = convertTypeToRaw(e)
}
/**
* INTERNAL: Do not use.
* Converts a synthesized `TLocatable` to a raw DB element, if possible.

Просмотреть файл

@ -10,14 +10,27 @@ module Generated {
/**
* Gets the parent of this unspecified element, if it exists.
*
* This includes nodes from the "hidden" AST. It can be overridden in subclasses to change the
* behavior of both the `Immediate` and non-`Immediate` versions.
*/
Element getParent() {
Element getImmediateParent() {
result =
Synth::convertElementFromRaw(Synth::convertUnspecifiedElementToRaw(this)
.(Raw::UnspecifiedElement)
.getParent())
}
/**
* Gets the parent of this unspecified element, if it exists.
*/
final Element getParent() {
exists(Element immediate |
immediate = this.getImmediateParent() and
result = immediate.resolve()
)
}
/**
* Holds if `getParent()` exists.
*/

Просмотреть файл

@ -10,14 +10,27 @@ module Generated {
/**
* Gets the `index`th active element of this if config declaration (0-based).
*
* This includes nodes from the "hidden" AST. It can be overridden in subclasses to change the
* behavior of both the `Immediate` and non-`Immediate` versions.
*/
AstNode getActiveElement(int index) {
AstNode getImmediateActiveElement(int index) {
result =
Synth::convertAstNodeFromRaw(Synth::convertIfConfigDeclToRaw(this)
.(Raw::IfConfigDecl)
.getActiveElement(index))
}
/**
* Gets the `index`th active element of this if config declaration (0-based).
*/
final AstNode getActiveElement(int index) {
exists(AstNode immediate |
immediate = this.getImmediateActiveElement(index) and
result = immediate.resolve()
)
}
/**
* Gets any of the active elements of this if config declaration.
*/

3
swift/ql/lib/codeql/swift/generated/expr/Expr.qll сгенерированный
Просмотреть файл

@ -2,14 +2,13 @@
private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.AstNode
import codeql.swift.elements.HideableElement
import codeql.swift.elements.type.Type
module Generated {
/**
* The base class for all expressions in Swift.
*/
class Expr extends Synth::TExpr, AstNode, HideableElement {
class Expr extends Synth::TExpr, AstNode {
/**
* Gets the type of this expression, if it exists.
*

Просмотреть файл

@ -2,8 +2,7 @@
private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.AstNode
import codeql.swift.elements.HideableElement
module Generated {
class Pattern extends Synth::TPattern, AstNode, HideableElement { }
class Pattern extends Synth::TPattern, AstNode { }
}

15
swift/ql/lib/codeql/swift/generated/stmt/BraceStmt.qll сгенерированный
Просмотреть файл

@ -10,14 +10,27 @@ module Generated {
/**
* Gets the `index`th element of this brace statement (0-based).
*
* This includes nodes from the "hidden" AST. It can be overridden in subclasses to change the
* behavior of both the `Immediate` and non-`Immediate` versions.
*/
AstNode getElement(int index) {
AstNode getImmediateElement(int index) {
result =
Synth::convertAstNodeFromRaw(Synth::convertBraceStmtToRaw(this)
.(Raw::BraceStmt)
.getElement(index))
}
/**
* Gets the `index`th element of this brace statement (0-based).
*/
final AstNode getElement(int index) {
exists(AstNode immediate |
immediate = this.getImmediateElement(index) and
result = immediate.resolve()
)
}
/**
* Gets any of the elements of this brace statement.
*/

4
swift/ql/lib/codeql/swift/generated/type/Type.qll сгенерированный
Просмотреть файл

@ -1,10 +1,10 @@
// generated by codegen/codegen.py
private import codeql.swift.generated.Synth
private import codeql.swift.generated.Raw
import codeql.swift.elements.HideableElement
import codeql.swift.elements.Element
module Generated {
class Type extends Synth::TType, HideableElement {
class Type extends Synth::TType, Element {
/**
* Gets the name of this type.
*/

Просмотреть файл

@ -66,7 +66,7 @@ private string prettyPrint(Locatable e) {
result = "[" + concat(e.getPrimaryQlClasses(), ", ") + "] " + e
}
private class Unresolved extends HideableElement, Locatable {
private class Unresolved extends Locatable {
Unresolved() { this != this.resolve() }
}
@ -89,7 +89,7 @@ class PrintLocatable extends PrintAstNode, TLocatable {
// use even indexes for normal children, leaving odd slots for conversions if any
child = TLocatable(c) and index = 2 * i and label = accessor
or
child = TLocatable(c.(HideableElement).getFullyUnresolved().(Unresolved)) and
child = TLocatable(c.getFullyUnresolved().(Unresolved)) and
index = 2 * i + 1 and
(
if c instanceof Expr

8
swift/ql/lib/swift.dbscheme сгенерированный
Просмотреть файл

@ -15,9 +15,9 @@ sourceLocationPrefix(
@callable
| @file
| @generic_context
| @hideable_element
| @locatable
| @location
| @type
;
#keyset[id]
@ -77,12 +77,6 @@ file_is_successfully_extracted(
int id: @file ref
);
@hideable_element =
@expr
| @pattern
| @type
;
@locatable =
@argument
| @ast_node

Просмотреть файл

@ -72,12 +72,9 @@ class UnknownLocation(Location):
class AstNode(Locatable):
pass
@ql.hideable
class HideableElement(Element):
pass
@group("type")
class Type(HideableElement):
@ql.hideable
class Type(Element):
name: string
canonical_type: "Type"
@ -87,12 +84,14 @@ class Decl(AstNode):
members: list["Decl"] | child
@group("expr")
class Expr(AstNode, HideableElement):
@ql.hideable
class Expr(AstNode):
"""The base class for all expressions in Swift."""
type: optional[Type]
@group("pattern")
class Pattern(AstNode, HideableElement):
@ql.hideable
class Pattern(AstNode):
pass
@group("stmt")