Swift: move getName to Callable (generated)

Now that getStaticTarget returns a Callable.
This commit is contained in:
Nora Dimitrijević
2022-12-13 17:08:08 -05:00
parent 535daf39b7
commit 6269e6b24d
9 changed files with 59 additions and 38 deletions

View File

@@ -363,7 +363,7 @@ ql/lib/codeql/swift/elements/type/WeakStorageType.qll 87a28616eea3600fb0156fffcd
ql/lib/codeql/swift/elements/type/WeakStorageTypeConstructor.qll d88b031ef44d6de14b3ddcff2eb47b53dbd11550c37250ff2edb42e5d21ec3e9 26d855c33492cf7a118e439f7baeed0e5425cfaf058b1dcc007eca7ed765c897
ql/lib/codeql/swift/elements.qll 56ea4825f91bb761355f366b0b57ea49cd3df513abf901b370445b0f9264845d 56ea4825f91bb761355f366b0b57ea49cd3df513abf901b370445b0f9264845d
ql/lib/codeql/swift/generated/AstNode.qll 02ca56d82801f942ae6265c6079d92ccafdf6b532f6bcebd98a04029ddf696e4 6216fda240e45bd4302fa0cf0f08f5f945418b144659264cdda84622b0420aa2
ql/lib/codeql/swift/generated/Callable.qll f67df00043a3d7100d1438a5bc9cda18390db89d05047c47650b85ac4eaf3cb5 aab5400c5e31d9175a60c62483609aa7b11bb1dbdb652cba59025d077996c322
ql/lib/codeql/swift/generated/Callable.qll cdadcd29460e9c956b494bde46671f673abd39c91cee4acc8b1cde55afb5e4d4 373904ff78518af88fc1578e830552c157ecdbba2f913aefce7e7b7656111a6e
ql/lib/codeql/swift/generated/Comment.qll f58b49f6e68c21f87c51e2ff84c8a64b09286d733e86f70d67d3a98fe6260bd6 975bbb599a2a7adc35179f6ae06d9cbc56ea8a03b972ef2ee87604834bc6deb1
ql/lib/codeql/swift/generated/DbFile.qll a49b2a2cb2788cb49c861ebcd458b8daead7b15adb19c3a9f4db3bf39a0051fc a49b2a2cb2788cb49c861ebcd458b8daead7b15adb19c3a9f4db3bf39a0051fc
ql/lib/codeql/swift/generated/DbLocation.qll b9baea963d9fa82068986512c0649d1050897654eee3df51dba17cf6b1170873 b9baea963d9fa82068986512c0649d1050897654eee3df51dba17cf6b1170873
@@ -373,15 +373,15 @@ ql/lib/codeql/swift/generated/ErrorElement.qll 4b032abe8ffb71376a29c63e470a52943
ql/lib/codeql/swift/generated/File.qll 61454459f5f1ae378bd4970ad1da4f39f3e696bac8a5eebdd162f131995c5316 3e6805f8858cd55dd0e0d0e5aeab923d6a55292dbf98b0029db1ae0208efe684
ql/lib/codeql/swift/generated/Locatable.qll bdc98b9fb7788f44a4bf7e487ee5bd329473409950a8e9f116d61995615ad849 0b36b4fe45e2aa195e4bb70c50ea95f32f141b8e01e5f23466c6427dd9ab88fb
ql/lib/codeql/swift/generated/Location.qll 851766e474cdfdfa67da42e0031fc42dd60196ff5edd39d82f08d3e32deb84c1 b29b2c37672f5acff15f1d3c5727d902f193e51122327b31bd27ec5f877bca3b
ql/lib/codeql/swift/generated/ParentChild.qll 37af8347ae69f840f37c13b532440a17b871d381130ac86b2c61667026712eea 5989b6d3ef54b5977185cc988e6cab4b796485d8cbe089c8714bcebfbdb11f3a
ql/lib/codeql/swift/generated/ParentChild.qll 0cf944fbfc0b7421b474cf3b4591802292008cb2017f72a42d3a58aacafae226 5989b6d3ef54b5977185cc988e6cab4b796485d8cbe089c8714bcebfbdb11f3a
ql/lib/codeql/swift/generated/PureSynthConstructors.qll 173c0dd59396a1de26fe870e3bc2766c46de689da2a4d8807cb62023bbce1a98 173c0dd59396a1de26fe870e3bc2766c46de689da2a4d8807cb62023bbce1a98
ql/lib/codeql/swift/generated/Raw.qll 6b8e3e3d86254d5689b17a08c41d23cda0d913b5d3b22b18b55aa00363ace6df 3736f05fc2c2eb6a9d9dd0d244061abe72161714cd435233106804472213e2b1
ql/lib/codeql/swift/generated/Raw.qll 6c68d4d8b51f42a19994476cdf8129bf55b6908dbbc643383506d002bbadb6ba f312416ea50d751501a666c9dc070521055caa5ecc72e460b16ac4fe827a4b6a
ql/lib/codeql/swift/generated/Synth.qll 6a9e6edcc43732b6cf947d88b9562a591a54c651aa8e4f94b8b6139ff3f84b63 a1f37bb361fed57104f8277c8f8b1962a0a54b1f80c2d676e71c40a91d3af529
ql/lib/codeql/swift/generated/SynthConstructors.qll 62360813f1419e111732e42e209535a40644997009890d09e4cc70f3918fbf86 62360813f1419e111732e42e209535a40644997009890d09e4cc70f3918fbf86
ql/lib/codeql/swift/generated/UnknownFile.qll 0fcf9beb8de79440bcdfff4bb6ab3dd139bd273e6c32754e05e6a632651e85f6 0fcf9beb8de79440bcdfff4bb6ab3dd139bd273e6c32754e05e6a632651e85f6
ql/lib/codeql/swift/generated/UnknownLocation.qll e50efefa02a0ec1ff635a00951b5924602fc8cab57e5756e4a039382c69d3882 e50efefa02a0ec1ff635a00951b5924602fc8cab57e5756e4a039382c69d3882
ql/lib/codeql/swift/generated/UnspecifiedElement.qll dbc6ca4018012977b26ca184a88044c55b0661e3998cd14d46295b62a8d69625 184c9a0ce18c2ac881943b0fb400613d1401ed1d5564f90716b6c310ba5afe71
ql/lib/codeql/swift/generated/decl/AbstractFunctionDecl.qll 8255b24dddda83e8a7dee9d69a4cf9883b5a7ae43676d7242b5aab5169f68982 407c7d63681fb03ad6cb4ea3c2b04be7ccb5ddbe655a8aec4219eb3799bc36e8
ql/lib/codeql/swift/generated/decl/AbstractFunctionDecl.qll 76408e1672fe4c18d00e6027171a88a994639034bd90052effb649d472b15478 22d507db18d4d3ed7fc4ecf6e423041249159c048f610ec6fe0866b1b6261c59
ql/lib/codeql/swift/generated/decl/AbstractStorageDecl.qll 882e95e6887741c0cdac4dcafb9efb5182f18484c6d29e84bab0a8f65c9e70a2 0c5c6739484ce3913cfbff68307a5c1cf63639e5ba9043f1f305197fc06b8de9
ql/lib/codeql/swift/generated/decl/AbstractTypeParamDecl.qll 1e268b00d0f2dbbd85aa70ac206c5e4a4612f06ba0091e5253483635f486ccf9 5479e13e99f68f1f347283535f8098964f7fd4a34326ff36ad5711b2de1ab0d0
ql/lib/codeql/swift/generated/decl/AccessorDecl.qll 443cb9888dbdbaee680bf24469ce097a8292806dc53f0b109d492db621fa00aa 0dbe38cbbd3f3cd880c1569d9d42165e7cf0358da0cc7cb63e89890310ad40a0
@@ -650,9 +650,10 @@ ql/lib/codeql/swift/generated/type/WeakStorageType.qll dda4397a49f537ec44117a86d
ql/test/extractor-tests/generated/Comment/MISSING_SOURCE.txt 7e714762ffb48c436102027d560fb5addc1f7dc6dd6936b06e0d3cca031d67fd 7e714762ffb48c436102027d560fb5addc1f7dc6dd6936b06e0d3cca031d67fd
ql/test/extractor-tests/generated/Diagnostics/Diagnostics.ql 6a4a9480cc929381e0337b181e5ac519a7abc6d597ebe24fb6701acf79ced86f 199c5bf8bd38e161d989e0e4db1ea1d3ddcb4d7cf571afd9112ce3ed8d9b8d2a
ql/test/extractor-tests/generated/File/File.ql ab0968ae31b749da2b66462bd04e4dfb30604dba405a84594b575abfc4fa4c35 bcc0ff648b28c5ecd567e196e700272883756bbcc65296bbb880a979e3162628
ql/test/extractor-tests/generated/decl/AccessorDecl/AccessorDecl.ql fcf430b5a4631a56f88ff8e05c97f312244d450745d65f9c312f9fd14ccc917f a6423ef93f4aae97dac13f700cbb5c79aeda4762e4524685ad03686468d2925c
ql/test/extractor-tests/generated/decl/AccessorDecl/AccessorDecl.ql 5bfde9efcae4418ec82ef8ef39ac42e25888b45d4745221650bb89e79d37cd6f ff78564a33a8f33506cc2cff8eee4b5a55264cfb9964cb1eea0919efec4fa808
ql/test/extractor-tests/generated/decl/AccessorDecl/AccessorDecl_getBody.ql 1d42eb1a5b832cfaf1949b61a01a6a11448a6d4369a44f2511bb31d1d7fc10a8 b326a6743121353f8a66410d3d9151ca969939abcbbe5c411872ca290da45123
ql/test/extractor-tests/generated/decl/AccessorDecl/AccessorDecl_getGenericTypeParam.ql 8648679e9403477c7f97b6df450a0fa623dc9aff0777021ee33f9cc96eef2611 59c384c35804bf205c3c63e8b956e6bc89d3ded7952911c40e7bf156acb56bf8
ql/test/extractor-tests/generated/decl/AccessorDecl/AccessorDecl_getName.ql a8f7b6cbb8ab43ed612cfbb36b48b5d6dd23b1dbe94a99d95fedf80e3c95f89f d70eb32403c4983c58448fe5c9e2d88bc873ab61e0e310c38356a9a144b42978
ql/test/extractor-tests/generated/decl/AccessorDecl/AccessorDecl_getParam.ql 7c61c15d75f681c5f5817bdc1e0c1e2594afdc43a5a8889bd385b6cd007d6509 7f6111069c3f289fb3bd21933893757a0adbf8be8f21bf5f8960b6fb26840219
ql/test/extractor-tests/generated/decl/AccessorDecl/AccessorDecl_getSelfParam.ql 0d773ccd4c84a5280f03341cccff8363479b668541d269311215db866a1cfd53 743d584a8d5d85aa11e96ca44151f1239c750bf8a429d60269129696411a0294
ql/test/extractor-tests/generated/decl/AssociatedTypeDecl/AssociatedTypeDecl.ql 74cf30be2fa4f825f0167bde4489b09683858f762bb335db04fe1cc474dafec6 0911e8a9130622da23f3b2747830c7c8e1659f0c062594bd34f82e335b08448e
@@ -661,9 +662,10 @@ ql/test/extractor-tests/generated/decl/ClassDecl/ClassDecl.ql b65b8bb8def2a79501
ql/test/extractor-tests/generated/decl/ClassDecl/ClassDecl_getBaseType.ql 5f4fddbb3fb3d003f1485dc4c5a56f7d0d26dfc1d691540085654c4c66e70e69 0b5a5b757ca92e664ef136d26ac682aa5a0e071494d9f09d85f66cd13807e81d
ql/test/extractor-tests/generated/decl/ClassDecl/ClassDecl_getGenericTypeParam.ql ca0b73a4f31eea47def7a1de017de36b5fdaec96ae98edb03ff00611bfcac572 f9badd62887a30113484496532b3ff9b67ff5047eb5a311aa2ec2e4d91321e0e
ql/test/extractor-tests/generated/decl/ClassDecl/ClassDecl_getMember.ql f73881b14bb4eaf83dacf60b9e46d440227f90566e2dfb8908a55567626ccdda f78a7261f7ccfe01ca55f7279bd5a1a302fc65ba36b13e779426d173c7465b84
ql/test/extractor-tests/generated/decl/ConcreteFuncDecl/ConcreteFuncDecl.ql 27df755f467c5176cf8f26d3b41ebd321834048ce8120a384746c3deeb73cdc3 d4b8363876172e5a152a5126457443dc9fe9ec83c3f0a9bd86eae54473ac8bd9
ql/test/extractor-tests/generated/decl/ConcreteFuncDecl/ConcreteFuncDecl.ql ecc7c4fa21110e6661d4b6b25b1675bd6d8d9129465afff2f66df62513a4b210 207fbb75dabf125f2f79133fc8055e9200390dc7ec0a1abb9cbba5a8522d154f
ql/test/extractor-tests/generated/decl/ConcreteFuncDecl/ConcreteFuncDecl_getBody.ql 3c742b9c8d8d8c23d1bef03f559e1b91f0d3848084ba5819f118c323dd1920a2 340d4e4a6312ffaf4c47bbc753828c1e478d84a2d399c66220288c081c8357ca
ql/test/extractor-tests/generated/decl/ConcreteFuncDecl/ConcreteFuncDecl_getGenericTypeParam.ql b5e64bf02a5991a1549794af0aaab9ae654c88b5d52a3e04b7ac525b3a64af5e 034a7d0bf7500afa952a28d184d1d073e71c3dcec3bc26fcefaed70aef9de3ce
ql/test/extractor-tests/generated/decl/ConcreteFuncDecl/ConcreteFuncDecl_getName.ql d80c7dfdde294264b6763a7129e666efd98111dbf203a9739c24942659d7f832 396e44281e4f4af2188a4f7d246872b7058132b12f508b88dc60d5bdd14e2092
ql/test/extractor-tests/generated/decl/ConcreteFuncDecl/ConcreteFuncDecl_getParam.ql 392bc906a24a432b0dd65a18248cab53874e1ea018b44fdf07d8acb55939c85d cf272febc8355d7171308c0b35f65ae0469106c022093f87ffd25d5951eef4a3
ql/test/extractor-tests/generated/decl/ConcreteFuncDecl/ConcreteFuncDecl_getSelfParam.ql c8a593149db6785d9bc7017a3fcee305832ab434955b4c36ac2842e214f0acac b70a7c18085961d2c907631d69811071deb391c45c94ef7165bf7ce700dabaf9
ql/test/extractor-tests/generated/decl/ConcreteVarDecl/ConcreteVarDecl.ql 5b38d0a84f99a7472a222fe612aa8a04f1ce0f7b804fd95eb75bfb83be5314c0 1a78d482860647c40b85e1119b849268f7d38c41b626d63f6cfa90fa933e9c1a

View File

@@ -7,6 +7,16 @@ import codeql.swift.elements.decl.ParamDecl
module Generated {
class Callable extends Synth::TCallable, Element {
/**
* Gets the name of this Callable, if it exists.
*/
string getName() { result = Synth::convertCallableToRaw(this).(Raw::Callable).getName() }
/**
* Holds if `getName()` exists.
*/
final predicate hasName() { exists(getName()) }
/**
* Gets the self parameter of this callable, if it exists.
*

View File

@@ -6,6 +6,8 @@ module Raw {
}
class Callable extends @callable, Element {
string getName() { callable_names(this, result) }
ParamDecl getSelfParam() { callable_self_params(this, result) }
ParamDecl getParam(int index) { callable_params(this, index, result) }
@@ -154,7 +156,6 @@ module Raw {
}
class AbstractFunctionDecl extends @abstract_function_decl, GenericContext, ValueDecl, Callable {
string getName() { abstract_function_decls(this, result) }
}
class AbstractStorageDecl extends @abstract_storage_decl, ValueDecl {

View File

@@ -7,12 +7,5 @@ import codeql.swift.elements.decl.ValueDecl
module Generated {
class AbstractFunctionDecl extends Synth::TAbstractFunctionDecl, GenericContext, ValueDecl,
Callable {
/**
* Gets the name of this function.
*/
string getName() {
result = Synth::convertAbstractFunctionDeclToRaw(this).(Raw::AbstractFunctionDecl).getName()
}
}
Callable { }
}

View File

@@ -31,6 +31,12 @@ element_is_unknown(
| @abstract_function_decl
;
#keyset[id]
callable_names(
int id: @callable ref,
string name: string ref
);
#keyset[id]
callable_self_params(
int id: @callable ref,
@@ -315,12 +321,6 @@ value_decls( //dir=decl
| @func_decl
;
#keyset[id]
abstract_function_decls( //dir=decl
int id: @abstract_function_decl ref,
string name: string ref
);
@abstract_storage_decl =
@subscript_decl
| @var_decl

View File

@@ -3,20 +3,20 @@ import codeql.swift.elements
import TestUtils
from
AccessorDecl x, string hasSelfParam, int getNumberOfParams, string hasBody,
int getNumberOfGenericTypeParams, ModuleDecl getModule, Type getInterfaceType, string getName,
string isGetter, string isSetter, string isWillSet, string isDidSet, string isRead,
string isModify, string isUnsafeAddress, string isUnsafeMutableAddress
AccessorDecl x, string hasName, string hasSelfParam, int getNumberOfParams, string hasBody,
int getNumberOfGenericTypeParams, ModuleDecl getModule, Type getInterfaceType, string isGetter,
string isSetter, string isWillSet, string isDidSet, string isRead, string isModify,
string isUnsafeAddress, string isUnsafeMutableAddress
where
toBeTested(x) and
not x.isUnknown() and
(if x.hasName() then hasName = "yes" else hasName = "no") and
(if x.hasSelfParam() then hasSelfParam = "yes" else hasSelfParam = "no") and
getNumberOfParams = x.getNumberOfParams() and
(if x.hasBody() then hasBody = "yes" else hasBody = "no") and
getNumberOfGenericTypeParams = x.getNumberOfGenericTypeParams() and
getModule = x.getModule() and
getInterfaceType = x.getInterfaceType() and
getName = x.getName() and
(if x.isGetter() then isGetter = "yes" else isGetter = "no") and
(if x.isSetter() then isSetter = "yes" else isSetter = "no") and
(if x.isWillSet() then isWillSet = "yes" else isWillSet = "no") and
@@ -27,8 +27,9 @@ where
if x.isUnsafeMutableAddress()
then isUnsafeMutableAddress = "yes"
else isUnsafeMutableAddress = "no"
select x, "hasSelfParam:", hasSelfParam, "getNumberOfParams:", getNumberOfParams, "hasBody:",
hasBody, "getNumberOfGenericTypeParams:", getNumberOfGenericTypeParams, "getModule:", getModule,
"getInterfaceType:", getInterfaceType, "getName:", getName, "isGetter:", isGetter, "isSetter:",
isSetter, "isWillSet:", isWillSet, "isDidSet:", isDidSet, "isRead:", isRead, "isModify:",
isModify, "isUnsafeAddress:", isUnsafeAddress, "isUnsafeMutableAddress:", isUnsafeMutableAddress
select x, "hasName:", hasName, "hasSelfParam:", hasSelfParam, "getNumberOfParams:",
getNumberOfParams, "hasBody:", hasBody, "getNumberOfGenericTypeParams:",
getNumberOfGenericTypeParams, "getModule:", getModule, "getInterfaceType:", getInterfaceType,
"isGetter:", isGetter, "isSetter:", isSetter, "isWillSet:", isWillSet, "isDidSet:", isDidSet,
"isRead:", isRead, "isModify:", isModify, "isUnsafeAddress:", isUnsafeAddress,
"isUnsafeMutableAddress:", isUnsafeMutableAddress

View File

@@ -0,0 +1,7 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from AccessorDecl x
where toBeTested(x) and not x.isUnknown()
select x, x.getName()

View File

@@ -3,18 +3,18 @@ import codeql.swift.elements
import TestUtils
from
ConcreteFuncDecl x, string hasSelfParam, int getNumberOfParams, string hasBody,
int getNumberOfGenericTypeParams, ModuleDecl getModule, Type getInterfaceType, string getName
ConcreteFuncDecl x, string hasName, string hasSelfParam, int getNumberOfParams, string hasBody,
int getNumberOfGenericTypeParams, ModuleDecl getModule, Type getInterfaceType
where
toBeTested(x) and
not x.isUnknown() and
(if x.hasName() then hasName = "yes" else hasName = "no") and
(if x.hasSelfParam() then hasSelfParam = "yes" else hasSelfParam = "no") and
getNumberOfParams = x.getNumberOfParams() and
(if x.hasBody() then hasBody = "yes" else hasBody = "no") and
getNumberOfGenericTypeParams = x.getNumberOfGenericTypeParams() and
getModule = x.getModule() and
getInterfaceType = x.getInterfaceType() and
getName = x.getName()
select x, "hasSelfParam:", hasSelfParam, "getNumberOfParams:", getNumberOfParams, "hasBody:",
hasBody, "getNumberOfGenericTypeParams:", getNumberOfGenericTypeParams, "getModule:", getModule,
"getInterfaceType:", getInterfaceType, "getName:", getName
getInterfaceType = x.getInterfaceType()
select x, "hasName:", hasName, "hasSelfParam:", hasSelfParam, "getNumberOfParams:",
getNumberOfParams, "hasBody:", hasBody, "getNumberOfGenericTypeParams:",
getNumberOfGenericTypeParams, "getModule:", getModule, "getInterfaceType:", getInterfaceType

View File

@@ -0,0 +1,7 @@
// generated by codegen/codegen.py
import codeql.swift.elements
import TestUtils
from ConcreteFuncDecl x
where toBeTested(x) and not x.isUnknown()
select x, x.getName()