Codegen: pass ql_internal to Stub

This commit is contained in:
Paolo Tranquilli
2023-11-08 09:54:21 +01:00
parent 10afa4381a
commit b7543f5dc7
8 changed files with 35 additions and 7 deletions

View File

@@ -102,7 +102,8 @@ def _get_doc(cls: schema.Class, prop: schema.Property, plural=None):
return f"{prop_name} of this {class_name}"
def get_ql_property(cls: schema.Class, prop: schema.Property, lookup: typing.Dict[str, schema.Class], prev_child: str = "") -> ql.Property:
def get_ql_property(cls: schema.Class, prop: schema.Property, lookup: typing.Dict[str, schema.Class],
prev_child: str = "") -> ql.Property:
args = dict(
type=prop.type if not prop.is_predicate else "predicate",
qltest_skip="qltest_skip" in prop.pragmas,
@@ -310,7 +311,8 @@ def _get_stub(cls: schema.Class, base_import: str, generated_import_prefix: str)
]
else:
accessors = []
return ql.Stub(name=cls.name, base_import=base_import, import_prefix=generated_import_prefix, synth_accessors=accessors)
return ql.Stub(name=cls.name, base_import=base_import, import_prefix=generated_import_prefix,
synth_accessors=accessors, ql_internal="ql_internal" in cls.pragmas)
def generate(opts, renderer):
@@ -426,7 +428,7 @@ def generate(opts, renderer):
for stub_file, data in stubs.items():
renderer.render(data, stub_file)
renderer.render(ql.Synth.Types(root.name, generated_import_prefix,
final_synth_types, non_final_synth_types), out / "Synth.qll")
final_synth_types, non_final_synth_types), out / "Synth.qll")
renderer.render(ql.ImportList(constructor_imports), out / "SynthConstructors.qll")
renderer.render(ql.ImportList(synth_constructor_imports), out / "PureSynthConstructors.qll")
if opts.ql_format:

View File

@@ -166,6 +166,7 @@ class Stub:
base_import: str
import_prefix: str
synth_accessors: List[SynthUnderlyingAccessor] = field(default_factory=list)
ql_internal: bool = False
@property
def has_synth_accessors(self) -> bool:

View File

@@ -153,6 +153,15 @@ def test_one_empty_class(generate_classes):
}
def test_one_empty_internal_class(generate_classes):
assert generate_classes([
schema.Class("A", pragmas=["ql_internal"])
]) == {
"A.qll": (a_ql_stub(name="A", ql_internal=True),
a_ql_class(name="A", final=True, ql_internal=True)),
}
def test_hierarchy(generate_classes):
assert generate_classes([
schema.Class("D", bases=["B", "C"]),

View File

@@ -14,7 +14,7 @@ lib/codeql/swift/elements/UnspecifiedElementConstructor.qll f7e232dae7362d0c3f9f
lib/codeql/swift/elements/decl/AbstractStorageDecl.qll d79e4d19ac9534173d3322c82fdfda3a140f296a9fbf658e23641245ddfd7a72 1d383912eee998c68366a63709c9665bee257560d4b0c997e97f79877c6546da
lib/codeql/swift/elements/decl/AbstractTypeParamDecl.qll 8d08a5c00663ad9f1703e564aca3efa9ad4d54f8f2758befbf36d70eec708110 e1048fb35d25d742d5293caffabadef1f7421f1316a5274a6121a9c5d94a6388
lib/codeql/swift/elements/decl/AccessorConstructor.qll b6c0923d01f1b2b7f5b97a1885dfe62277d728f3b57fe036b2aeb89063fc2b65 2f2f0d9397e5e34d6167c4e605e214d25059f9e911117323683561c17da539fb
lib/codeql/swift/elements/decl/AccessorOrNamedFunction.qll f1a186fa81d28e2f8cc5dee45940e1523e6e1a5414f1fef44a6f513d8e0d3616 a1fa9c11ad757ceb36d85ea742909e82959b2c28f9d5ada738572fa58497b13f
lib/codeql/swift/elements/decl/AccessorOrNamedFunction.qll 76ae8f9e7fddb361d1ac8c113efbabf2a1276785e6c6cb5a5d7a4a5b0a281237 586715edecf97a624e658b7a0bf60cec1d02563a601253d7660289eadab403e2
lib/codeql/swift/elements/decl/AssociatedTypeDecl.qll 2f78f9cafe49f10146e416a87b7d73b85a7067ee49bca0d8ca45bcf0cc972523 a14dfe50933b38bf11a539f2e02b734c005f1f1538f6554763ee7d5ed50eac0f
lib/codeql/swift/elements/decl/AssociatedTypeDeclConstructor.qll f51555f5561f937cb9356aae938ec09c43712dd474045a5df177073fbd230a83 27608714c1fb37e37b821e94399fa710237a7da2876e268ad0b4419b8ccab6d6
lib/codeql/swift/elements/decl/CapturedDeclConstructor.qll 39e8ecb4d7cda881389cacb0294bc129fd3cd2c6832619a23895ac3afccca57d 1a392f4637240a89a37e0f62d4f520e3633444b0be06c4c5e50fa07a857932b0
@@ -113,7 +113,7 @@ lib/codeql/swift/elements/expr/DifferentiableFunctionExtractOriginalExprConstruc
lib/codeql/swift/elements/expr/DiscardAssignmentExprConstructor.qll da5f5b96affe451df707015cb304ae61df0ccffe989e765d59c336a194c28516 43b411c22d407338ad7151e6d949d2f85f8ff88e5bc923f8ff713f842803e26e
lib/codeql/swift/elements/expr/DotSelfExprConstructor.qll 01fe3c9b34580e5b5b4a17d6ea841685800d7197af9a9c81cbbc9dec5e1c6157 96a44bea60877e7ae7cfe878733d30e20a59dac15f2dcf02c174d2e7dd9159e8
lib/codeql/swift/elements/expr/DotSyntaxBaseIgnoredExprConstructor.qll 154b2d59b8926f0a66f55280a54e9eb61dbf5d8537b1a148e48234379cd1aa35 f2cbb8f9a8dcae1fde553dcc3370be5580657196dfa742aed3ee01bd3a78eba8
lib/codeql/swift/elements/expr/DotSyntaxCallExpr.qll 10f47dc6ac0335af6fb9dd363a3ba852fedcadf99d7d785f4826e73aea9a0a92 5c4db2fd0756ca8e08c46c3510910528977acc2dbeb67ef9ed7f718635de4062
lib/codeql/swift/elements/expr/DotSyntaxCallExpr.qll 35512b6343c4d86f107efeabb2f8e26999d0306aa38aeaa58f237519e286a0d0 c5568903843ee1db76d9bb18c54b9e5431654bb092a101321a6e12cb9b257af1
lib/codeql/swift/elements/expr/DynamicLookupExpr.qll 118784c752b01e8fb898d81e729bef7d877f37b64ca6461c02fa766e52ad368e d109e043931fbf6b5a1b383a47b3ce06a25048ab95030ad0c26678ba4b1314a7
lib/codeql/swift/elements/expr/DynamicMemberRefExprConstructor.qll fabe4fa78d5390d8926b83db0a81b448ff609acac694364d37bcabeecb1f3216 aa86cadeea1cd0d6ddeea7207fd87e2db960fa7327ce7be964df40727a5daa85
lib/codeql/swift/elements/expr/DynamicSubscriptExprConstructor.qll b488d0f3b250b2acaf2434abc29e19735cf87f8f803697d4c3c69f34824ad721 27774dd280e37f3c5d9451ed14e01183b5e84099f1f30afad942c3dd26c438c3
@@ -139,7 +139,7 @@ lib/codeql/swift/elements/expr/IfExprConstructor.qll 19db7b1ada1eadc9222b9197b01
lib/codeql/swift/elements/expr/InOutExprConstructor.qll 22f59945ffa2b32107801b7830f5558e795ddeb3b7b84ad841647989e2326c16 907cde9a2ae22a8cde9de6ec1ad2f1a56cf8455ecbc8562c6375b1695679aa4b
lib/codeql/swift/elements/expr/InOutToPointerExpr.qll 93bb97e98ca26d2e5edbc188f84664c6325bb75951eb04e1df9058a6e9869c1c cc3e07b789d8196bb8bef8d85d1957168a4d5599c4e9481c284d61b9e4ebdef4
lib/codeql/swift/elements/expr/InOutToPointerExprConstructor.qll a1d4a719225259ccc6870d71b1b00d9e7cc5dc5291e6c3134b26e0bf50dc8ca1 61ad8913d43af36843027c52598f0ed5a406523f67234be1a5c31f4702a67376
lib/codeql/swift/elements/expr/InitializerRefCallExpr.qll c5137f1092014a8eaebf4edf1f68e9ae3175096e3e5e97614b81773bbfb665ef 0cccfda7189e232c9a73bbd307b2597f1064a309043593e210ca3defb8294372
lib/codeql/swift/elements/expr/InitializerRefCallExpr.qll b2881e1dc5823da63728def4f4bb45f7069bfcb9a7e858b477ba226d49acf8fd a44073e9daadf9b347958b1bc4997e9a0bdbe342753aa6dfe9790a1ab51b5e7c
lib/codeql/swift/elements/expr/InjectIntoOptionalExpr.qll f45fb9e782e868c164df21043b89cefcd7f55d85f017ba2408b1b696e214e621 71c37dd964fe71d55af9540b7b79fabcdb94d35de31005db1ec024157dfd3697
lib/codeql/swift/elements/expr/InjectIntoOptionalExprConstructor.qll f700c46060dcc34182dda95692dcc8ae1240e113a3b2bdcfb02c7fdb5be07191 8ff9ff6ed10e91d920f3c93b1316c4567b545b8d2289d607233b4f35318a2a32
lib/codeql/swift/elements/expr/IntegerLiteralExprConstructor.qll a5129ec2adf907228d6830e8ca6577596dbbf6711c358767b99d1f28e5eb70c2 e30346f405e64f68d433aef284300ecbfb5a885e65dbb8b08977cf1e396dd3dc
@@ -190,7 +190,7 @@ lib/codeql/swift/elements/expr/ProtocolMetatypeToObjectExpr.qll a146a7d2616dc651
lib/codeql/swift/elements/expr/ProtocolMetatypeToObjectExprConstructor.qll 6fee3ca39b925d11da5582702d147a8bbc1230d4b22a26788873f7ad3630fa4e 1ab7aea377213cd48fecec44268a05c3b74290f50fc9d74a2fc2be4078bfa070
lib/codeql/swift/elements/expr/RebindSelfInInitializerExprConstructor.qll 3c0d02373ae393dd95654685d4d1bc26d9071cabbdaa15009c80f04bffcead9a 61a625ebf97a2b8b7c2c7cae77b65258910ffcddb1be6c93fee347a8ccaa0951
lib/codeql/swift/elements/expr/RegexLiteralExprConstructor.qll eed0c4e96369f9db89984b2a29e6ce06df7be953964857cb9cd57c59119b0860 d085bfb23b381acfd21b6d9004cd729f5b489d9bc992801ec744e84a7898e68c
lib/codeql/swift/elements/expr/SelfApplyExpr.qll 7ed10a14a67a5f7d392cadcedf954375fe6ef1d59d50744fc185e1bca78b1997 da1d1370c0c8706c63abf9de487168e66c84dced60c702046882bfa9af15c222
lib/codeql/swift/elements/expr/SelfApplyExpr.qll 1d72bbcb20eb829e3f830b64d700cf417f4de911a5bb7f5dc68c63a2606e7688 3b23644f2ec280dd39dab9010cc6a691fe91a520d8462661dd4501d27743c891
lib/codeql/swift/elements/expr/SequenceExpr.qll 7a354f84ba4d935e18884d14ce9029b5cabbf15d679a553608f4bef57d052b32 71deff01f9c3a7e07006f2d331526dfd99de384a181e0885b157263e70c91c0e
lib/codeql/swift/elements/expr/SequenceExprConstructor.qll bf2712ab013e292f51a8a9b7ec3a84e3681f3aecb11ae2f639d542c0ea1267c2 4a93b3b5b7c163915bb47b8e51d3b1df1023b122ed36b5a31fbf1940b8017cff
lib/codeql/swift/elements/expr/StringLiteralExprConstructor.qll f2b4e492711fb1de6f8534012730047b2b26a6f6ab018447ab482d5824c05c10 516fb10926e7a6f616e45fe27b865c0fb06a258db084b1ee65d8a86c5f815b77

View File

@@ -1,8 +1,12 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
/**
* This module provides a hand-modifiable wrapper around the generated class `AccessorOrNamedFunction`.
* INTERNAL: Do not use.
*/
private import codeql.swift.generated.decl.AccessorOrNamedFunction
/**
* INTERNAL: Do not use.
*/
class AccessorOrNamedFunction extends Generated::AccessorOrNamedFunction { }

View File

@@ -1,8 +1,12 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
/**
* This module provides a hand-modifiable wrapper around the generated class `DotSyntaxCallExpr`.
* INTERNAL: Do not use.
*/
private import codeql.swift.generated.expr.DotSyntaxCallExpr
/**
* INTERNAL: Do not use.
*/
class DotSyntaxCallExpr extends Generated::DotSyntaxCallExpr { }

View File

@@ -1,8 +1,12 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
/**
* This module provides a hand-modifiable wrapper around the generated class `InitializerRefCallExpr`.
* INTERNAL: Do not use.
*/
private import codeql.swift.generated.expr.InitializerRefCallExpr
/**
* INTERNAL: Do not use.
*/
class InitializerRefCallExpr extends Generated::InitializerRefCallExpr { }

View File

@@ -1,8 +1,12 @@
// generated by codegen/codegen.py, remove this comment if you wish to edit this file
/**
* This module provides a hand-modifiable wrapper around the generated class `SelfApplyExpr`.
* INTERNAL: Do not use.
*/
private import codeql.swift.generated.expr.SelfApplyExpr
/**
* INTERNAL: Do not use.
*/
class SelfApplyExpr extends Generated::SelfApplyExpr { }