Rust: Run codegen

This commit is contained in:
Tom Hvitved
2024-10-11 12:00:49 +02:00
parent b284a2a7c0
commit 8cc349e85f
18 changed files with 304 additions and 201 deletions

View File

@@ -1,2 +1,2 @@
mod.rs 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7
top.rs 170c3892b5cbb8be28ae420a92ebab3b96b354c3b7ea2ba96edec64e639e8455 170c3892b5cbb8be28ae420a92ebab3b96b354c3b7ea2ba96edec64e639e8455
top.rs 7c68cdb6a44e3f1ac27601f006a8c583ef1e5f198fd9c30a6710ffade2612d80 7c68cdb6a44e3f1ac27601f006a8c583ef1e5f198fd9c30a6710ffade2612d80

View File

@@ -390,6 +390,42 @@ impl From<trap::Label<Attr>> for trap::Label<Locatable> {
}
}
#[derive(Debug)]
pub struct Callable {
_unused: ()
}
impl trap::TrapClass for Callable {
fn class_name() -> &'static str { "Callable" }
}
impl From<trap::Label<Callable>> for trap::Label<AstNode> {
fn from(value: trap::Label<Callable>) -> Self {
// SAFETY: this is safe because in the dbscheme Callable is a subclass of AstNode
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Callable>> for trap::Label<Element> {
fn from(value: trap::Label<Callable>) -> Self {
// SAFETY: this is safe because in the dbscheme Callable is a subclass of Element
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Callable>> for trap::Label<Locatable> {
fn from(value: trap::Label<Callable>) -> Self {
// SAFETY: this is safe because in the dbscheme Callable is a subclass of Locatable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
#[derive(Debug)]
pub struct ClosureBinder {
pub id: trap::TrapId<ClosureBinder>,
@@ -3769,6 +3805,7 @@ impl From<trap::Label<CastExpr>> for trap::Label<Locatable> {
#[derive(Debug)]
pub struct ClosureExpr {
pub id: trap::TrapId<ClosureExpr>,
pub param_list: Option<trap::Label<ParamList>>,
pub attrs: Vec<trap::Label<Attr>>,
pub body: Option<trap::Label<Expr>>,
pub closure_binder: Option<trap::Label<ClosureBinder>>,
@@ -3777,7 +3814,6 @@ pub struct ClosureExpr {
pub is_gen: bool,
pub is_move: bool,
pub is_static: bool,
pub param_list: Option<trap::Label<ParamList>>,
pub ret_type: Option<trap::Label<RetType>>,
}
@@ -3788,8 +3824,11 @@ impl trap::TrapEntry for ClosureExpr {
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("closure_exprs", vec![id.into()]);
if let Some(v) = self.param_list {
out.add_tuple("callable_param_lists", vec![id.into(), v.into()]);
}
for (i, v) in self.attrs.into_iter().enumerate() {
out.add_tuple("closure_expr_attrs", vec![id.into(), i.into(), v.into()]);
out.add_tuple("callable_attrs", vec![id.into(), i.into(), v.into()]);
}
if let Some(v) = self.body {
out.add_tuple("closure_expr_bodies", vec![id.into(), v.into()]);
@@ -3812,9 +3851,6 @@ impl trap::TrapEntry for ClosureExpr {
if self.is_static {
out.add_tuple("closure_expr_is_static", vec![id.into()]);
}
if let Some(v) = self.param_list {
out.add_tuple("closure_expr_param_lists", vec![id.into(), v.into()]);
}
if let Some(v) = self.ret_type {
out.add_tuple("closure_expr_ret_types", vec![id.into(), v.into()]);
}
@@ -3834,6 +3870,15 @@ impl From<trap::Label<ClosureExpr>> for trap::Label<AstNode> {
}
}
impl From<trap::Label<ClosureExpr>> for trap::Label<Callable> {
fn from(value: trap::Label<ClosureExpr>) -> Self {
// SAFETY: this is safe because in the dbscheme ClosureExpr is a subclass of Callable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<ClosureExpr>> for trap::Label<Element> {
fn from(value: trap::Label<ClosureExpr>) -> Self {
// SAFETY: this is safe because in the dbscheme ClosureExpr is a subclass of Element
@@ -8400,8 +8445,9 @@ impl From<trap::Label<ExternCrate>> for trap::Label<Stmt> {
#[derive(Debug)]
pub struct Function {
pub id: trap::TrapId<Function>,
pub abi: Option<trap::Label<Abi>>,
pub param_list: Option<trap::Label<ParamList>>,
pub attrs: Vec<trap::Label<Attr>>,
pub abi: Option<trap::Label<Abi>>,
pub body: Option<trap::Label<BlockExpr>>,
pub generic_param_list: Option<trap::Label<GenericParamList>>,
pub is_async: bool,
@@ -8410,7 +8456,6 @@ pub struct Function {
pub is_gen: bool,
pub is_unsafe: bool,
pub name: Option<trap::Label<Name>>,
pub param_list: Option<trap::Label<ParamList>>,
pub ret_type: Option<trap::Label<RetType>>,
pub visibility: Option<trap::Label<Visibility>>,
pub where_clause: Option<trap::Label<WhereClause>>,
@@ -8423,11 +8468,14 @@ impl trap::TrapEntry for Function {
fn emit(self, id: trap::Label<Self>, out: &mut trap::Writer) {
out.add_tuple("functions", vec![id.into()]);
if let Some(v) = self.abi {
out.add_tuple("function_abis", vec![id.into(), v.into()]);
if let Some(v) = self.param_list {
out.add_tuple("callable_param_lists", vec![id.into(), v.into()]);
}
for (i, v) in self.attrs.into_iter().enumerate() {
out.add_tuple("function_attrs", vec![id.into(), i.into(), v.into()]);
out.add_tuple("callable_attrs", vec![id.into(), i.into(), v.into()]);
}
if let Some(v) = self.abi {
out.add_tuple("function_abis", vec![id.into(), v.into()]);
}
if let Some(v) = self.body {
out.add_tuple("function_bodies", vec![id.into(), v.into()]);
@@ -8453,9 +8501,6 @@ impl trap::TrapEntry for Function {
if let Some(v) = self.name {
out.add_tuple("function_names", vec![id.into(), v.into()]);
}
if let Some(v) = self.param_list {
out.add_tuple("function_param_lists", vec![id.into(), v.into()]);
}
if let Some(v) = self.ret_type {
out.add_tuple("function_ret_types", vec![id.into(), v.into()]);
}
@@ -8490,6 +8535,15 @@ impl From<trap::Label<Function>> for trap::Label<AstNode> {
}
}
impl From<trap::Label<Function>> for trap::Label<Callable> {
fn from(value: trap::Label<Function>) -> Self {
// SAFETY: this is safe because in the dbscheme Function is a subclass of Callable
unsafe {
Self::from_untyped(value.as_untyped())
}
}
}
impl From<trap::Label<Function>> for trap::Label<Element> {
fn from(value: trap::Label<Function>) -> Self {
// SAFETY: this is safe because in the dbscheme Function is a subclass of Element

View File

@@ -16,9 +16,10 @@ lib/codeql/rust/elements/BoxPat.qll 1b2c3fff171aa6aa238c9460b122f26c79e04577cea6
lib/codeql/rust/elements/BreakExpr.qll 7ca3807a20e9a9a988d1fd7abebf240325ed422fcb45c719ba46272f031f94db dffb7379d3f3ba220acfbd05eb7bb6cfd9cfda211e9c8b1f5240ca5fa61be3fc
lib/codeql/rust/elements/CallExpr.qll f336500ca7a611b164d48b90e80edb0c0d3816792b0ececce659ac1ff1ffeb3e f99a9c55466418ef53860c44d9f2d6161af4b492178ddd9e5870dff742b70ae5
lib/codeql/rust/elements/CallExprBase.qll 2846202b5208b541977500286951d96487bf555838c6c16cdd006a71e383745a c789d412bf099c624329379e0c7d94fa0d23ae2edea7a25a2ea0f3c0042ccf62
lib/codeql/rust/elements/Callable.qll e1ed21a7e6bd2426f6ccd0e46cee506d8ebf90a6fdc4dca0979157da439853aa 02f6c09710116ce82157aec9a5ec706983c38e4d85cc631327baf8d409b018c6
lib/codeql/rust/elements/CastExpr.qll ba281bde130f43c486c4ad889539b77fba9e41afdf7980e50b6a8696a1ec7527 61257003d395896ec60729d0bc01da36697615bb725d07141255fbb5c44e50a0
lib/codeql/rust/elements/ClosureBinder.qll 977df800f97cc9b03fffb5e5e1fc6acd08a2938e04cb6ad91108784a15b0d510 f6fad4127226fe1dff2f16416d8a7fde5d8ab4a88f30e443ac5e5ff618de3e05
lib/codeql/rust/elements/ClosureExpr.qll 8f06357ae134e42c073eef994c83c04b8cf294fe33b286dbd75c0e705ce29d05 9d9e282d965fed723965376801d4afa49444d1d9be9b093d02e276729a2cf7ad
lib/codeql/rust/elements/ClosureExpr.qll 192f67bb98d455f7de9eb871fc8f7353dfd991b857ed9fe65d01ef8610ece852 af99426b33dcf19ca4b97817dd94dd102cb0884c30bf7d947e9e6762e1c152ee
lib/codeql/rust/elements/Comment.qll fedad50575125e9a64a8a8776a8c1dbf1e76df990f01849d9f0955f9d74cb2a6 8eb1afad1e1007a4f0090fdac65d81726b23eda6517d067fd0185f70f17635ab
lib/codeql/rust/elements/Const.qll 2843a870e2abdf5b63fbea13f8a9ec4981b74369adec2ed3ce00a7d6f5a6fee3 c0bdb467cce63dcd3c65b21ef0836d8bf4e6c8d7d70049df8581fd35fdd03083
lib/codeql/rust/elements/ConstArg.qll f37b34417503bbd2f3ce09b3211d8fa71f6a954970c2738c73be6c55f204e58e 15ef5e189b67cfdfe4d16909e0b411ac8fdd4ef187c328bdede03a1a5e416b54
@@ -41,7 +42,7 @@ lib/codeql/rust/elements/ForExpr.qll 312804d53dd9236a2f2a15c9d6ec348b46e139a54eb
lib/codeql/rust/elements/ForType.qll 0036bed8749358c356d78c4a0eef40d73e2796284293cde5604ae70ddd6d0470 4edcaf8f7c67d42ebe3ebb1be6a7643758717d4fe88f5f648b6a1c5ff4ee4de7
lib/codeql/rust/elements/FormatArgsArg.qll 5bc9b4cd1bac7131165836e93838c45452a08ea6011741cbddace3cbf9c69440 f825140e98dc9800d5c045402186793c7b21511448e2f6bf6402d1e06305219c
lib/codeql/rust/elements/FormatArgsExpr.qll f2ffad5a1105b29a8437c8ed6cf918cfcf4d65ac164bbf1be0585c3b673ca749 3ba20dc312a0a994bb43b37b2db72cbd4e06061b97918fa0e84ce355070ffbeb
lib/codeql/rust/elements/Function.qll 736c53408f8674c88c352cd1f08f7c77e51551c68ef802f2e1c1aaf3d44fa8e9 6b52dbea081a5e799f1a2cedd57be5485bc8e018ded7249a1852343053d849a6
lib/codeql/rust/elements/Function.qll 2c76c2c7036891996b1f0ebde16c414edf37ebb44ff9c3483088dc6218733e07 d84d017d98aa240bf3bee6502a030aa8cfb7ed95425ffa9853e73b41485e1f4a
lib/codeql/rust/elements/GenericArg.qll 5f11ce0e3c5f08de84db61f56ba1b984652455ba6b95a8b8a5b5a235913d4072 756b6a73d66fde45bdcc65ce2362a5b1391af2927e6d54b6550b3ecd5fd11e75
lib/codeql/rust/elements/GenericArgList.qll dcf274db517b0e8f19e4545d77f86cdd4066ff2805e68c808d0bb5750b49f569 1055a82929e850264e501b367ef4d314a3e6bb8943ec95f4284d157fb4d0092f
lib/codeql/rust/elements/GenericParam.qll b58448b808d6dfa05db9574f54c22ce51f0b1d78784263c75a95d6bfc787067d 4afbab71fe717d7d7d3e2f60ea8c3d97bcb29b17b4efb79eabfe8f070edcb9bb
@@ -187,6 +188,7 @@ lib/codeql/rust/elements/internal/BreakExprConstructor.qll 356be043c28e0b34fdf92
lib/codeql/rust/elements/internal/CallExprBaseImpl.qll d2749cc1a9d7ee8bf7f34b6c3e0238a576a68e439a8c10a503c164ff45ffcbeb ffc7b0a8841945fe6736b0e1aed7d9ed69185db03dee2b16da121325b39397c7
lib/codeql/rust/elements/internal/CallExprConstructor.qll 742b38e862e2cf82fd1ecc4d4fc5b4782a9c7c07f031452b2bae7aa59d5aa13a cad6e0a8be21d91b20ac2ec16cab9c30eae810b452c0f1992ed87d5c7f4144dc
lib/codeql/rust/elements/internal/CallExprImpl.qll 7e48610680ba6f2876a1a005ab0743496dd2364b9c44aca441bd33e11317e2d7 bb12c3c28156b40796fe3ba112760f87bb5abb323aab3c5b7bb3e0facaef8d35
lib/codeql/rust/elements/internal/CallableImpl.qll 917a7d298583e15246428f32fba4cde6fc57a1790262731be27a96baddd8cf5e c5c0848024e0fe3fbb775e7750cf1a2c2dfa454a5aef0df55fec3d0a6fe99190
lib/codeql/rust/elements/internal/CastExprConstructor.qll f3d6e10c4731f38a384675aeab3fba47d17b9e15648293787092bb3247ed808d d738a7751dbadb70aa1dcffcf8af7fa61d4cf8029798369a7e8620013afff4ed
lib/codeql/rust/elements/internal/CastExprImpl.qll 3c57b75f01efc70013ba3f05bd79fe2747fe1d1de47b84ff73b06ad38b4f1093 da813adc3390d23ec0643e37226a58e8afdb78e889380ad265d7531a344b841c
lib/codeql/rust/elements/internal/ClosureBinderConstructor.qll 6e376ab9d40308e95bcdaf1cc892472c92099d477720192cd382d2c4e0d9c8a1 60a0efe50203ad5bb97bdfc06d602182edcc48ac9670f2d27a9675bd9fd8e19f
@@ -463,9 +465,10 @@ lib/codeql/rust/elements/internal/generated/BoxPat.qll ec946a3e671ab7417e04b0207
lib/codeql/rust/elements/internal/generated/BreakExpr.qll 0f428a8b2f4209b134c2ffc3e1c93c30bc6b0e9c9172f140cefa88c1f77d8690 957b39f38ff6befe9061f55bc0b403c2f1c366dd0cf63b874bae6f8216576d76
lib/codeql/rust/elements/internal/generated/CallExpr.qll 23ee64e3bf643cd5e6ff705181d2bb31e1aeaffecb5bdce73836172dbf15f12f 34b280139b1f8f70d78e1432392f03c971be392e8cb68d014eb325d0c101bddd
lib/codeql/rust/elements/internal/generated/CallExprBase.qll cce796e36847249f416629bacf3ea146313084de3374587412e66c10d2917b83 c219aa2174321c161a4a742ca0605521687ca9a5ca32db453a5c62db6f7784cc
lib/codeql/rust/elements/internal/generated/Callable.qll b0502b5263b7bcd18e740f284f992c0e600e37d68556e3e0ba54a2ac42b94934 bda3e1eea11cacf5a9b932cd72efc2de6105103e8c575880fcd0cd89daadf068
lib/codeql/rust/elements/internal/generated/CastExpr.qll d6fbf02e9e202254666082a9116634d0eb933177866ac4c0a57b5e9c4bb4b383 477f67773492e3b82695461d56327c9db05a7d1a67e8d192406265f2ce369670
lib/codeql/rust/elements/internal/generated/ClosureBinder.qll 94c0dcdd4cd87d115659d496c88a98354bc7d4ddc0fa27028003bf7688b99987 d59d713b426dbbdb775df9092d176eea031dac1f14e468810f2fc8591399cd19
lib/codeql/rust/elements/internal/generated/ClosureExpr.qll a10596deeb7b9799f0c0d9e9dfe43f5ff58ba03a9a444d581a240a99ca06a949 e94c2f6cd0190d108d0b91340227d45fb6b8c8c2c6a0476358fe75ea7f7a7760
lib/codeql/rust/elements/internal/generated/ClosureExpr.qll 70bb3d961e4dc62ad2c9b80d8cbe1e1d5792eafa00a2b0730c06cf6e8a164105 acb3c5200877fda8dffc65b4aa1d4deeb806e035aefecf4da7f0ce03e0b3a477
lib/codeql/rust/elements/internal/generated/Comment.qll cd1ef861e3803618f9f78a4ac00516d50ecfecdca1c1d14304dc5327cbe07a3b 8b67345aeb15beb5895212228761ea3496297846c93fd2127b417406ae87c201
lib/codeql/rust/elements/internal/generated/Const.qll 40464df9d8baacbc85bd137c7d1661684c957c407b2363ea60d90946be93de4c a3316beae55f570a5ca4b1172ef8267d7acb1104cc7a5e9efc58d9fc8224500f
lib/codeql/rust/elements/internal/generated/ConstArg.qll e2451cac6ee464f5b64883d60d534996fcff061a520517ac792116238a11e185 1dd6d4b073b0970448a52bbe2468cd160dfe108971dbf9ae9305900bd22ef146
@@ -488,7 +491,7 @@ lib/codeql/rust/elements/internal/generated/ForExpr.qll 541b62b48911d4999f9ed64a
lib/codeql/rust/elements/internal/generated/ForType.qll 3d43d044a1189281f09c55caafb6c8020a836f49e2866077086101925a573cf2 646b59bfd1b428aaf7211f574c49f79cb4c6a79ca151aa0663b2b31480298721
lib/codeql/rust/elements/internal/generated/FormatArgsArg.qll e07a1ae310f590003f1b88fada7dcf4847c99adb9d4c838d1c88e66e1da85c5f 0ef7342451fe2cb06e765fb4b33bb8c4a9b927f5edbc8feb5c6ba3655697f447
lib/codeql/rust/elements/internal/generated/FormatArgsExpr.qll 40d6daa7d2bafb33798a21d79774dc802cfbd7a31618ac3bd0149399ea2bf893 d1172e2151791228559004792e125fc4625f6a26ffad25f29efb0ad263bf8795
lib/codeql/rust/elements/internal/generated/Function.qll c8826307fcb18daf8c59552a5c629a0e59e83e7f676b4a30408a042ecc216a46 ae27a8a709c187ffd6fa7e25e7850555d1be6633d6ee304457a4481135402dcb
lib/codeql/rust/elements/internal/generated/Function.qll f285ee0c771f897eba6db34a7e98f3cfb7db91b0df252ff4b37fc9d779de0bfb 07401e832565ff376acda219514c2e2bbe4ae5058c76a73b40ca6ca66f1626c7
lib/codeql/rust/elements/internal/generated/GenericArg.qll 464da0ba1c5ddcd1be68617167f177773d99b5ac4775ec8ea24d503e789a9099 6faa1033d59baf7c210ac4837a55781cfc054b7acbad8027faf4630dbfa6e101
lib/codeql/rust/elements/internal/generated/GenericArgList.qll b8cd936bba6f28344e28c98acf38acb8ef43af6ecf8367d79ed487e5b9da17cb 8b14331261e49d004807285b02fca190aafd62bfb9378b05c7d9c1e95525fe7b
lib/codeql/rust/elements/internal/generated/GenericParam.qll a0285123f974f287154b706bf6688b86edf72a4adcec57346c654d962435651b b42c3915e9564b5b5c5282229bf882aa3309de26a77721b2255d6f4235c0cc38
@@ -536,7 +539,7 @@ lib/codeql/rust/elements/internal/generated/ParamList.qll c808c9d84dd7800573832b
lib/codeql/rust/elements/internal/generated/ParenExpr.qll bc0731505bfe88516205ec360582a4222d2681d11342c93e15258590ddee82f2 d4bd6e0c80cf1d63746c88d4bcb3a01d4c75732e5da09e3ebd9437ced227fb60
lib/codeql/rust/elements/internal/generated/ParenPat.qll ce24b8f8ecbf0f204af200317405724063887257460c80cf250c39b2fdf37185 e7c87d37e1a0ca7ea03840017e1aa9ddb7f927f1f3b6396c0305b46aeee33db6
lib/codeql/rust/elements/internal/generated/ParenType.qll 9cc954d73f8330dcac7b475f97748b63af5c8766dee9d2f2872c0a7e4c903537 c07534c8a9c683c4a9b11d490095647e420de0a0bfc23273eaf6f31b00244273
lib/codeql/rust/elements/internal/generated/ParentChild.qll 9c600678b3616c3c263fa317753a9ca8ad4ed7efd0e5195dd7eade054c513692 8000db77bab203447063283adb8d0835731c802bc17ef4ffb39cbdb855cef993
lib/codeql/rust/elements/internal/generated/ParentChild.qll 4af9df75abf8215aa746c9063368911ee94f84b91d71ccf8e6f3acdab02adc03 08855e899a703d5ed63d63db7749ab353367166987ac56ae10875d93975f934a
lib/codeql/rust/elements/internal/generated/Pat.qll 3605ac062be2f294ee73336e9669027b8b655f4ad55660e1eab35266275154ee 7f9400db2884d336dd1d21df2a8093759c2a110be9bf6482ce8e80ae0fd74ed4
lib/codeql/rust/elements/internal/generated/Path.qll 299abce24762a5ab023f3cf1ab9718b83047e171aed42a8092e7a155914b1657 db1a23d18640c548f08c9f94823838b5e019ac85877c7b15df2d1493d1846572
lib/codeql/rust/elements/internal/generated/PathExpr.qll 17cdb0a7393258a207450f08e37178fc9d35d167f064ba6015be94246f3dc933 a75fdd280aff6d87e083a92030e041c2eb52b57cf7151d4a6989fcd31d6a64bf
@@ -548,7 +551,7 @@ lib/codeql/rust/elements/internal/generated/PtrType.qll 40099c5a4041314b66932dfd
lib/codeql/rust/elements/internal/generated/PureSynthConstructors.qll dc03515d678ba052c2ff2dd9f0883e0bce54cac740ba9a15e5173f292c1b6971 dc03515d678ba052c2ff2dd9f0883e0bce54cac740ba9a15e5173f292c1b6971
lib/codeql/rust/elements/internal/generated/RangeExpr.qll 23cca03bf43535f33b22a38894f70d669787be4e4f5b8fe5c8f7b964d30e9027 18624cef6c6b679eeace2a98737e472432e0ead354cca02192b4d45330f047c9
lib/codeql/rust/elements/internal/generated/RangePat.qll efd93730de217cf50dcba5875595263a5eadf9f7e4e1272401342a094d158614 229b251b3d118932e31e78ac4dfb75f48b766f240f20d436062785606d44467b
lib/codeql/rust/elements/internal/generated/Raw.qll 632497608201b6c7bafcb093c0a1e115cec75a648b06e831c2116d88fd29a435 7c8736dfdd22fdbfce8ee8858144da538c4327e8ca880bd92a6e7feaa1199d7d
lib/codeql/rust/elements/internal/generated/Raw.qll ff4874c063c0338443293c807108ecdb878ff2a6a97932c2bafe1c5d2a5486ed 4db42119a06518aeb33bfe9156d884e046afff540c98f07fa81c22bb11c063ad
lib/codeql/rust/elements/internal/generated/RecordExpr.qll eb6cb662e463f9260efae1a6ce874fa781172063b916ef1963f861e9942d308d 1a21cbccc8f3799ff13281e822818ebfb21d81591720a427cac3625512cb9d40
lib/codeql/rust/elements/internal/generated/RecordExprField.qll 7e9f8663d3b74ebbc9603b10c9912f082febba6bd73d344b100bbd3edf837802 fbe6b578e7fd5d5a6f21bbb8c388957ab7210a6a249ec71510a50fb35b319ea1
lib/codeql/rust/elements/internal/generated/RecordExprFieldList.qll 179a97211fe7aa6265085d4d54115cdbc0e1cd7c9b2135591e8f36d6432f13d3 dd44bbbc1e83a1ed3a587afb729d7debf7aeb7b63245de181726af13090e50c0
@@ -573,7 +576,7 @@ lib/codeql/rust/elements/internal/generated/Static.qll 5fbd6879858cf356d4bdaa6da
lib/codeql/rust/elements/internal/generated/Stmt.qll 8473ff532dd5cc9d7decaddcd174b94d610f6ca0aec8e473cc051dad9f3db917 6ef7d2b5237c2dbdcacbf7d8b39109d4dc100229f2b28b5c9e3e4fbf673ba72b
lib/codeql/rust/elements/internal/generated/StmtList.qll a667193e32341e17400867c6e359878c4e645ef9f5f4d97676afc0283a33a026 a320ed678ee359302e2fc1b70a9476705cd616fcfa44a499d32f0c7715627f73
lib/codeql/rust/elements/internal/generated/Struct.qll 4d57f0db12dc7ad3e31e750a24172ef1505406b4dab16386af0674bd18bf8f4b 1a73c83df926b996f629316f74c61ea775be04532ab61b56af904223354f033e
lib/codeql/rust/elements/internal/generated/Synth.qll a87bb2f82978d4baf9234627d2c7769f2395ab6d164b12b72011f96a95096ce4 0342246219252dd29608e07398f4036d99d9b88d9b2e8e9873a93e9bb6d9535c
lib/codeql/rust/elements/internal/generated/Synth.qll 277fd5258498732937682a2b6982405b6cb515f4631a6e0dc6f1a2545ffa54cb 0d3db7534cf9c1c73fc5863b9048f8bca4fe69615e9cdba8f521c36f02155878
lib/codeql/rust/elements/internal/generated/SynthConstructors.qll 518b68ccf6d0791bc0c141486261108bb1723e37743fc7f8e4167a1d61660531 518b68ccf6d0791bc0c141486261108bb1723e37743fc7f8e4167a1d61660531
lib/codeql/rust/elements/internal/generated/Token.qll 77a91a25ca5669703cf3a4353b591cef4d72caa6b0b9db07bb9e005d69c848d1 2fdffc4882ed3a6ca9ac6d1fb5f1ac5a471ca703e2ffdc642885fa558d6e373b
lib/codeql/rust/elements/internal/generated/TokenTree.qll 8577c2b097c1be2f0f7daa5acfcf146f78674a424d99563e08a84dd3e6d91b46 d2f30764e84dbfc0a6a5d3d8a5f935cd432413688cb32da9c94e420fbc10665c
@@ -608,7 +611,7 @@ lib/codeql/rust/elements/internal/generated/WhileExpr.qll fec8a9211b82a80601bf73
lib/codeql/rust/elements/internal/generated/WildcardPat.qll d74b70b57a0a66bfae017a329352a5b27a6b9e73dd5521d627f680e810c6c59e 4b913b548ba27ff3c82fcd32cf996ff329cb57d176d3bebd0fcef394486ea499
lib/codeql/rust/elements/internal/generated/YeetExpr.qll cac328200872a35337b4bcb15c851afb4743f82c080f9738d295571eb01d7392 94af734eea08129b587fed849b643e7572800e8330c0b57d727d41abda47930b
lib/codeql/rust/elements/internal/generated/YieldExpr.qll 37e5f0c1e373a22bbc53d8b7f2c0e1f476e5be5080b8437c5e964f4e83fad79a 4a9a68643401637bf48e5c2b2f74a6bf0ddcb4ff76f6bffb61d436b685621e85
lib/codeql/rust/elements.qll 78908ca1e1988b47323eb47fa58bcceeb984022fa40f89fb0af4f7219d2dd77b 78908ca1e1988b47323eb47fa58bcceeb984022fa40f89fb0af4f7219d2dd77b
lib/codeql/rust/elements.qll 0e469834ccc4b5db3d35d9521d98e3c8b1911f8c5cd70d35d4cd52cb81c73722 0e469834ccc4b5db3d35d9521d98e3c8b1911f8c5cd70d35d4cd52cb81c73722
test/extractor-tests/generated/Abi/Abi.ql 7f6e7dc4af86eca3ebdc79b10373988cd0871bd78b51997d3cffd969105e5fdd 2f936b6ca005c6157c755121584410c03e4a3949c23bee302fbe05ee10ce118f
test/extractor-tests/generated/Abi/Abi_getAbiString.ql a496762fcec5a0887b87023bbf93e9b650f02e20113e25c44d6e4281ae8f5335 14109c7ce11ba25e3cd6e7f1b3fcb4cb00622f2a4eac91bfe43145c5f366bc52
test/extractor-tests/generated/ArgList/ArgList.ql e412927756e72165d0e7c5c9bd3fca89d08197bbf760db8fb7683c64bb2229bc 043dba8506946fbb87753e22c387987d7eded6ddb963aa067f9e60ef9024d684
@@ -667,7 +670,7 @@ test/extractor-tests/generated/CastExpr/CastExpr_getExpr.ql c37186b8f3e3dab8ae28
test/extractor-tests/generated/CastExpr/CastExpr_getTy.ql ad5d6e260e1495ba360bd2ade3b60f09705a86a08d618acf8c4aff342c8ee200 c02c1dc65ba9160bc28827e40473915de5403bdc91c16d9d8b6778aa97314a1b
test/extractor-tests/generated/ClosureBinder/ClosureBinder.ql 42516df87ac28c814d65f6739b2ede6eaa41c505d64756a3b8c7e0ca79895230 8b840f92ec033a4ef5edbe52bed909d8be0fffddf6d3e4bfaf9a8bc174fa2f2c
test/extractor-tests/generated/ClosureBinder/ClosureBinder_getGenericParamList.ql 71010c43a78a7abe8e63c94353f4b7eb97aca011755d200e7087467c1e3b7a68 2c834328f783ec5032544a692f7e23975bac0228b52b9f8fde46ef46a5f22a5f
test/extractor-tests/generated/ClosureExpr/ClosureExpr.ql 430d566d8176d7b98d6cde6c35f9420249236eddb084f9c7cbb091cc683ff063 6b8127425cad540a1e407ff7b387f3924253da980f46e5a678aeb2870ba6ec7b
test/extractor-tests/generated/ClosureExpr/ClosureExpr.ql f25f9b32e5c0cd61e4b75053a5af4640a08b115ea5a4310ab95df450f6dfe1c4 9b731218857fa16776e29bce084c2ec1526b24e15f46d4f24047917d77d4646a
test/extractor-tests/generated/ClosureExpr/ClosureExpr_getAttr.ql f7f803afa4e2a5976c911fdf8a91ec607c2f998e22531b9c69a63d85579e34c3 1296acd0fb97e1484aa3f1d5ba09d18088001186f3ba5821eb3218a931ca0d54
test/extractor-tests/generated/ClosureExpr/ClosureExpr_getBody.ql 22a973a61274e87620e38338b29beef395818b95a88e2261fff197f7a78a8f76 bd28ed426e4d07823044db869aa8022dc81e8599d156e3e0e7cd49be914a1f36
test/extractor-tests/generated/ClosureExpr/ClosureExpr_getClosureBinder.ql cbfcf89b8efb5cb9b7bfbea26b5a78b3d4c7994cbf03d5ca60b61ee1b5cb4be5 621431277732ef79c585cb0b7199c49b14c597ee6b594a70d9e6966a09d40a9f
@@ -739,7 +742,7 @@ test/extractor-tests/generated/FormatArgsExpr/FormatArgsExpr.ql 0cd439f61569ecf0
test/extractor-tests/generated/FormatArgsExpr/FormatArgsExpr_getArg.ql 8f692486be1546b914b17abdff4a989dfbaa889bfa1fc44597f4357806c1a1dd da9fd237e31e9c8dd0ef0c3c968157815b87d3e8dcdfd74674c988ce2ab6d270
test/extractor-tests/generated/FormatArgsExpr/FormatArgsExpr_getAttr.ql 1f9bf1344f942e65c3a3591b6ae04d3f5a2a1a65459bce0d976698de7d8a5958 02acb861d8ab4d32cf144c589881a888c3da5e2ade27e8c85fec3ae45219bb3b
test/extractor-tests/generated/FormatArgsExpr/FormatArgsExpr_getTemplate.ql c912ac37275cbe7b3b29607bed1a3190c80779436422c14a475113e1bfd91a54 ef90f67a9b952a38ce557b1afbf0b5ce8551e83ddfaad8309a0c9523e40b5ea7
test/extractor-tests/generated/Function/Function.ql 28776a499f21ab36c9dfcb905861cf0bf0a2c51f24d6d9401ca45f67d9f982b0 1ded959dfd9c216975572c4577c6a2d4c56a2d3d4a2dd5b0f3f90adff98d86aa
test/extractor-tests/generated/Function/Function.ql 1287fabd4677a151248331c76c3e389af7cd9f41b943b50dfc42217c6a8dfef0 8187ed07e77aa0cf68da885159a965d14b4888252210b217e6752581ff986e8d
test/extractor-tests/generated/Function/Function_getAbi.ql e5c9c97de036ddd51cae5d99d41847c35c6b2eabbbd145f4467cb501edc606d8 0b81511528bd0ef9e63b19edfc3cb638d8af43eb87d018fad69d6ef8f8221454
test/extractor-tests/generated/Function/Function_getAttr.ql 44067ee11bdec8e91774ff10de0704a8c5c1b60816d587378e86bf3d82e1f660 b4bebf9441bda1f2d1e34e9261e07a7468cbabf53cf8047384f3c8b11869f04e
test/extractor-tests/generated/Function/Function_getBody.ql cf2716a751e309deba703ee4da70e607aae767c1961d3c0ac5b6728f7791f608 3beaf4032924720cb881ef6618a3dd22316f88635c86cbc1be60e3bdad173e21

3
rust/ql/.gitattributes generated vendored
View File

@@ -18,6 +18,7 @@
/lib/codeql/rust/elements/BreakExpr.qll linguist-generated
/lib/codeql/rust/elements/CallExpr.qll linguist-generated
/lib/codeql/rust/elements/CallExprBase.qll linguist-generated
/lib/codeql/rust/elements/Callable.qll linguist-generated
/lib/codeql/rust/elements/CastExpr.qll linguist-generated
/lib/codeql/rust/elements/ClosureBinder.qll linguist-generated
/lib/codeql/rust/elements/ClosureExpr.qll linguist-generated
@@ -189,6 +190,7 @@
/lib/codeql/rust/elements/internal/CallExprBaseImpl.qll linguist-generated
/lib/codeql/rust/elements/internal/CallExprConstructor.qll linguist-generated
/lib/codeql/rust/elements/internal/CallExprImpl.qll linguist-generated
/lib/codeql/rust/elements/internal/CallableImpl.qll linguist-generated
/lib/codeql/rust/elements/internal/CastExprConstructor.qll linguist-generated
/lib/codeql/rust/elements/internal/CastExprImpl.qll linguist-generated
/lib/codeql/rust/elements/internal/ClosureBinderConstructor.qll linguist-generated
@@ -465,6 +467,7 @@
/lib/codeql/rust/elements/internal/generated/BreakExpr.qll linguist-generated
/lib/codeql/rust/elements/internal/generated/CallExpr.qll linguist-generated
/lib/codeql/rust/elements/internal/generated/CallExprBase.qll linguist-generated
/lib/codeql/rust/elements/internal/generated/Callable.qll linguist-generated
/lib/codeql/rust/elements/internal/generated/CastExpr.qll linguist-generated
/lib/codeql/rust/elements/internal/generated/ClosureBinder.qll linguist-generated
/lib/codeql/rust/elements/internal/generated/ClosureExpr.qll linguist-generated

View File

@@ -21,6 +21,7 @@ import codeql.rust.elements.BoxPat
import codeql.rust.elements.BreakExpr
import codeql.rust.elements.CallExpr
import codeql.rust.elements.CallExprBase
import codeql.rust.elements.Callable
import codeql.rust.elements.CastExpr
import codeql.rust.elements.ClosureBinder
import codeql.rust.elements.ClosureExpr

View File

@@ -0,0 +1,14 @@
// generated by codegen, do not edit
/**
* This module provides the public class `Callable`.
*/
private import internal.CallableImpl
import codeql.rust.elements.AstNode
import codeql.rust.elements.Attr
import codeql.rust.elements.ParamList
/**
* A callable. Either a `Function` or a `ClosureExpr`.
*/
final class Callable = Impl::Callable;

View File

@@ -4,10 +4,9 @@
*/
private import internal.ClosureExprImpl
import codeql.rust.elements.Attr
import codeql.rust.elements.Callable
import codeql.rust.elements.ClosureBinder
import codeql.rust.elements.Expr
import codeql.rust.elements.ParamList
import codeql.rust.elements.RetType
/**

View File

@@ -6,13 +6,12 @@
private import internal.FunctionImpl
import codeql.rust.elements.Abi
import codeql.rust.elements.AssocItem
import codeql.rust.elements.Attr
import codeql.rust.elements.BlockExpr
import codeql.rust.elements.Callable
import codeql.rust.elements.ExternItem
import codeql.rust.elements.GenericParamList
import codeql.rust.elements.Item
import codeql.rust.elements.Name
import codeql.rust.elements.ParamList
import codeql.rust.elements.RetType
import codeql.rust.elements.Visibility
import codeql.rust.elements.WhereClause

View File

@@ -0,0 +1,19 @@
// generated by codegen, remove this comment if you wish to edit this file
/**
* This module provides a hand-modifiable wrapper around the generated class `Callable`.
*
* INTERNAL: Do not use.
*/
private import codeql.rust.elements.internal.generated.Callable
/**
* INTERNAL: This module contains the customizable definition of `Callable` and should not
* be referenced directly.
*/
module Impl {
/**
* A callable. Either a `Function` or a `ClosureExpr`.
*/
class Callable extends Generated::Callable { }
}

View File

@@ -0,0 +1,57 @@
// generated by codegen, do not edit
/**
* This module provides the generated definition of `Callable`.
* INTERNAL: Do not import directly.
*/
private import codeql.rust.elements.internal.generated.Synth
private import codeql.rust.elements.internal.generated.Raw
import codeql.rust.elements.internal.AstNodeImpl::Impl as AstNodeImpl
import codeql.rust.elements.Attr
import codeql.rust.elements.ParamList
/**
* INTERNAL: This module contains the fully generated definition of `Callable` and should not
* be referenced directly.
*/
module Generated {
/**
* A callable. Either a `Function` or a `ClosureExpr`.
* INTERNAL: Do not reference the `Generated::Callable` class directly.
* Use the subclass `Callable`, where the following predicates are available.
*/
class Callable extends Synth::TCallable, AstNodeImpl::AstNode {
/**
* Gets the parameter list of this callable, if it exists.
*/
ParamList getParamList() {
result =
Synth::convertParamListFromRaw(Synth::convertCallableToRaw(this)
.(Raw::Callable)
.getParamList())
}
/**
* Holds if `getParamList()` exists.
*/
final predicate hasParamList() { exists(this.getParamList()) }
/**
* Gets the `index`th attr of this callable (0-based).
*/
Attr getAttr(int index) {
result =
Synth::convertAttrFromRaw(Synth::convertCallableToRaw(this).(Raw::Callable).getAttr(index))
}
/**
* Gets any of the attrs of this callable.
*/
final Attr getAnAttr() { result = this.getAttr(_) }
/**
* Gets the number of attrs of this callable.
*/
final int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) }
}
}

View File

@@ -6,11 +6,10 @@
private import codeql.rust.elements.internal.generated.Synth
private import codeql.rust.elements.internal.generated.Raw
import codeql.rust.elements.Attr
import codeql.rust.elements.internal.CallableImpl::Impl as CallableImpl
import codeql.rust.elements.ClosureBinder
import codeql.rust.elements.Expr
import codeql.rust.elements.internal.ExprImpl::Impl as ExprImpl
import codeql.rust.elements.ParamList
import codeql.rust.elements.RetType
/**
@@ -32,29 +31,9 @@ module Generated {
* INTERNAL: Do not reference the `Generated::ClosureExpr` class directly.
* Use the subclass `ClosureExpr`, where the following predicates are available.
*/
class ClosureExpr extends Synth::TClosureExpr, ExprImpl::Expr {
class ClosureExpr extends Synth::TClosureExpr, ExprImpl::Expr, CallableImpl::Callable {
override string getAPrimaryQlClass() { result = "ClosureExpr" }
/**
* Gets the `index`th attr of this closure expression (0-based).
*/
Attr getAttr(int index) {
result =
Synth::convertAttrFromRaw(Synth::convertClosureExprToRaw(this)
.(Raw::ClosureExpr)
.getAttr(index))
}
/**
* Gets any of the attrs of this closure expression.
*/
final Attr getAnAttr() { result = this.getAttr(_) }
/**
* Gets the number of attrs of this closure expression.
*/
final int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) }
/**
* Gets the body of this closure expression, if it exists.
*/
@@ -108,21 +87,6 @@ module Generated {
*/
predicate isStatic() { Synth::convertClosureExprToRaw(this).(Raw::ClosureExpr).isStatic() }
/**
* Gets the parameter list of this closure expression, if it exists.
*/
ParamList getParamList() {
result =
Synth::convertParamListFromRaw(Synth::convertClosureExprToRaw(this)
.(Raw::ClosureExpr)
.getParamList())
}
/**
* Holds if `getParamList()` exists.
*/
final predicate hasParamList() { exists(this.getParamList()) }
/**
* Gets the ret type of this closure expression, if it exists.
*/

View File

@@ -8,13 +8,12 @@ private import codeql.rust.elements.internal.generated.Synth
private import codeql.rust.elements.internal.generated.Raw
import codeql.rust.elements.Abi
import codeql.rust.elements.internal.AssocItemImpl::Impl as AssocItemImpl
import codeql.rust.elements.Attr
import codeql.rust.elements.BlockExpr
import codeql.rust.elements.internal.CallableImpl::Impl as CallableImpl
import codeql.rust.elements.internal.ExternItemImpl::Impl as ExternItemImpl
import codeql.rust.elements.GenericParamList
import codeql.rust.elements.internal.ItemImpl::Impl as ItemImpl
import codeql.rust.elements.Name
import codeql.rust.elements.ParamList
import codeql.rust.elements.RetType
import codeql.rust.elements.Visibility
import codeql.rust.elements.WhereClause
@@ -39,7 +38,7 @@ module Generated {
* Use the subclass `Function`, where the following predicates are available.
*/
class Function extends Synth::TFunction, AssocItemImpl::AssocItem, ExternItemImpl::ExternItem,
ItemImpl::Item
ItemImpl::Item, CallableImpl::Callable
{
override string getAPrimaryQlClass() { result = "Function" }
@@ -55,24 +54,6 @@ module Generated {
*/
final predicate hasAbi() { exists(this.getAbi()) }
/**
* Gets the `index`th attr of this function (0-based).
*/
Attr getAttr(int index) {
result =
Synth::convertAttrFromRaw(Synth::convertFunctionToRaw(this).(Raw::Function).getAttr(index))
}
/**
* Gets any of the attrs of this function.
*/
final Attr getAnAttr() { result = this.getAttr(_) }
/**
* Gets the number of attrs of this function.
*/
final int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) }
/**
* Gets the body of this function, if it exists.
*/
@@ -139,21 +120,6 @@ module Generated {
*/
final predicate hasName() { exists(this.getName()) }
/**
* Gets the parameter list of this function, if it exists.
*/
ParamList getParamList() {
result =
Synth::convertParamListFromRaw(Synth::convertFunctionToRaw(this)
.(Raw::Function)
.getParamList())
}
/**
* Holds if `getParamList()` exists.
*/
final predicate hasParamList() { exists(this.getParamList()) }
/**
* Gets the ret type of this function, if it exists.
*/

View File

@@ -163,6 +163,26 @@ private module Impl {
)
}
private Element getImmediateChildOfCallable(Callable e, int index, string partialPredicateCall) {
exists(int b, int bAstNode, int n, int nParamList, int nAttr |
b = 0 and
bAstNode = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAstNode(e, i, _)) | i) and
n = bAstNode and
nParamList = n + 1 and
nAttr = nParamList + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and
(
none()
or
result = getImmediateChildOfAstNode(e, index - b, partialPredicateCall)
or
index = n and result = e.getParamList() and partialPredicateCall = "ParamList()"
or
result = e.getAttr(index - nParamList) and
partialPredicateCall = "Attr(" + (index - nParamList).toString() + ")"
)
)
}
private Element getImmediateChildOfClosureBinder(
ClosureBinder e, int index, string partialPredicateCall
) {
@@ -1428,35 +1448,27 @@ private module Impl {
private Element getImmediateChildOfClosureExpr(
ClosureExpr e, int index, string partialPredicateCall
) {
exists(
int b, int bExpr, int n, int nAttr, int nBody, int nClosureBinder, int nParamList,
int nRetType
|
exists(int b, int bExpr, int bCallable, int n, int nBody, int nClosureBinder, int nRetType |
b = 0 and
bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and
n = bExpr and
nAttr = n + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and
nBody = nAttr + 1 and
bCallable =
bExpr + 1 + max(int i | i = -1 or exists(getImmediateChildOfCallable(e, i, _)) | i) and
n = bCallable and
nBody = n + 1 and
nClosureBinder = nBody + 1 and
nParamList = nClosureBinder + 1 and
nRetType = nParamList + 1 and
nRetType = nClosureBinder + 1 and
(
none()
or
result = getImmediateChildOfExpr(e, index - b, partialPredicateCall)
or
result = e.getAttr(index - n) and
partialPredicateCall = "Attr(" + (index - n).toString() + ")"
result = getImmediateChildOfCallable(e, index - bExpr, partialPredicateCall)
or
index = nAttr and result = e.getBody() and partialPredicateCall = "Body()"
index = n and result = e.getBody() and partialPredicateCall = "Body()"
or
index = nBody and result = e.getClosureBinder() and partialPredicateCall = "ClosureBinder()"
or
index = nClosureBinder and
result = e.getParamList() and
partialPredicateCall = "ParamList()"
or
index = nParamList and result = e.getRetType() and partialPredicateCall = "RetType()"
index = nClosureBinder and result = e.getRetType() and partialPredicateCall = "RetType()"
)
)
}
@@ -2893,23 +2905,22 @@ private module Impl {
private Element getImmediateChildOfFunction(Function e, int index, string partialPredicateCall) {
exists(
int b, int bAssocItem, int bExternItem, int bItem, int n, int nAbi, int nAttr, int nBody,
int nGenericParamList, int nName, int nParamList, int nRetType, int nVisibility,
int nWhereClause
int b, int bAssocItem, int bExternItem, int bItem, int bCallable, int n, int nAbi, int nBody,
int nGenericParamList, int nName, int nRetType, int nVisibility, int nWhereClause
|
b = 0 and
bAssocItem = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfAssocItem(e, i, _)) | i) and
bExternItem =
bAssocItem + 1 + max(int i | i = -1 or exists(getImmediateChildOfExternItem(e, i, _)) | i) and
bItem = bExternItem + 1 + max(int i | i = -1 or exists(getImmediateChildOfItem(e, i, _)) | i) and
n = bItem and
bCallable =
bItem + 1 + max(int i | i = -1 or exists(getImmediateChildOfCallable(e, i, _)) | i) and
n = bCallable and
nAbi = n + 1 and
nAttr = nAbi + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and
nBody = nAttr + 1 and
nBody = nAbi + 1 and
nGenericParamList = nBody + 1 and
nName = nGenericParamList + 1 and
nParamList = nName + 1 and
nRetType = nParamList + 1 and
nRetType = nName + 1 and
nVisibility = nRetType + 1 and
nWhereClause = nVisibility + 1 and
(
@@ -2921,12 +2932,11 @@ private module Impl {
or
result = getImmediateChildOfItem(e, index - bExternItem, partialPredicateCall)
or
result = getImmediateChildOfCallable(e, index - bItem, partialPredicateCall)
or
index = n and result = e.getAbi() and partialPredicateCall = "Abi()"
or
result = e.getAttr(index - nAbi) and
partialPredicateCall = "Attr(" + (index - nAbi).toString() + ")"
or
index = nAttr and result = e.getBody() and partialPredicateCall = "Body()"
index = nAbi and result = e.getBody() and partialPredicateCall = "Body()"
or
index = nBody and
result = e.getGenericParamList() and
@@ -2934,9 +2944,7 @@ private module Impl {
or
index = nGenericParamList and result = e.getName() and partialPredicateCall = "Name()"
or
index = nName and result = e.getParamList() and partialPredicateCall = "ParamList()"
or
index = nParamList and result = e.getRetType() and partialPredicateCall = "RetType()"
index = nName and result = e.getRetType() and partialPredicateCall = "RetType()"
or
index = nRetType and result = e.getVisibility() and partialPredicateCall = "Visibility()"
or

View File

@@ -123,6 +123,22 @@ module Raw {
Meta getMeta() { attr_meta(this, result) }
}
/**
* INTERNAL: Do not use.
* A callable. Either a `Function` or a `ClosureExpr`.
*/
class Callable extends @callable, AstNode {
/**
* Gets the parameter list of this callable, if it exists.
*/
ParamList getParamList() { callable_param_lists(this, result) }
/**
* Gets the `index`th attr of this callable (0-based).
*/
Attr getAttr(int index) { callable_attrs(this, index, result) }
}
/**
* INTERNAL: Do not use.
* A ClosureBinder. For example:
@@ -1500,14 +1516,9 @@ module Raw {
* static |x| yield x;
* ```
*/
class ClosureExpr extends @closure_expr, Expr {
class ClosureExpr extends @closure_expr, Expr, Callable {
override string toString() { result = "ClosureExpr" }
/**
* Gets the `index`th attr of this closure expression (0-based).
*/
Attr getAttr(int index) { closure_expr_attrs(this, index, result) }
/**
* Gets the body of this closure expression, if it exists.
*/
@@ -1543,11 +1554,6 @@ module Raw {
*/
predicate isStatic() { closure_expr_is_static(this) }
/**
* Gets the parameter list of this closure expression, if it exists.
*/
ParamList getParamList() { closure_expr_param_lists(this, result) }
/**
* Gets the ret type of this closure expression, if it exists.
*/
@@ -3275,7 +3281,7 @@ module Raw {
* }
* ```
*/
class Function extends @function, AssocItem, ExternItem, Item {
class Function extends @function, AssocItem, ExternItem, Item, Callable {
override string toString() { result = "Function" }
/**
@@ -3283,11 +3289,6 @@ module Raw {
*/
Abi getAbi() { function_abis(this, result) }
/**
* Gets the `index`th attr of this function (0-based).
*/
Attr getAttr(int index) { function_attrs(this, index, result) }
/**
* Gets the body of this function, if it exists.
*/
@@ -3328,11 +3329,6 @@ module Raw {
*/
Name getName() { function_names(this, result) }
/**
* Gets the parameter list of this function, if it exists.
*/
ParamList getParamList() { function_param_lists(this, result) }
/**
* Gets the ret type of this function, if it exists.
*/

View File

@@ -592,8 +592,8 @@ module Synth {
* INTERNAL: Do not use.
*/
class TAstNode =
TAbi or TArgList or TAssocItem or TAssocItemList or TAttr or TClosureBinder or TExpr or
TExternItem or TExternItemList or TFieldList or TFormatArgsArg or TGenericArg or
TAbi or TArgList or TAssocItem or TAssocItemList or TAttr or TCallable or TClosureBinder or
TExpr or TExternItem or TExternItemList or TFieldList or TFormatArgsArg or TGenericArg or
TGenericArgList or TGenericParam or TGenericParamList or TItemList or TLabel or TLetElse or
TLifetime or TMatchArm or TMatchArmList or TMatchGuard or TMeta or TName or TNameRef or
TParam or TParamList or TPat or TPath or TPathSegment or TRecordExprField or
@@ -608,6 +608,11 @@ module Synth {
*/
class TCallExprBase = TCallExpr or TMethodCallExpr;
/**
* INTERNAL: Do not use.
*/
class TCallable = TClosureExpr or TFunction;
/**
* INTERNAL: Do not use.
*/
@@ -1568,6 +1573,8 @@ module Synth {
or
result = convertAttrFromRaw(e)
or
result = convertCallableFromRaw(e)
or
result = convertClosureBinderFromRaw(e)
or
result = convertExprFromRaw(e)
@@ -1679,6 +1686,16 @@ module Synth {
result = convertMethodCallExprFromRaw(e)
}
/**
* INTERNAL: Do not use.
* Converts a raw DB element to a synthesized `TCallable`, if possible.
*/
TCallable convertCallableFromRaw(Raw::Element e) {
result = convertClosureExprFromRaw(e)
or
result = convertFunctionFromRaw(e)
}
/**
* INTERNAL: Do not use.
* Converts a raw DB element to a synthesized `TElement`, if possible.
@@ -2846,6 +2863,8 @@ module Synth {
or
result = convertAttrToRaw(e)
or
result = convertCallableToRaw(e)
or
result = convertClosureBinderToRaw(e)
or
result = convertExprToRaw(e)
@@ -2957,6 +2976,16 @@ module Synth {
result = convertMethodCallExprToRaw(e)
}
/**
* INTERNAL: Do not use.
* Converts a synthesized `TCallable` to a raw DB element, if possible.
*/
Raw::Element convertCallableToRaw(TCallable e) {
result = convertClosureExprToRaw(e)
or
result = convertFunctionToRaw(e)
}
/**
* INTERNAL: Do not use.
* Converts a synthesized `TElement` to a raw DB element, if possible.

View File

@@ -139,6 +139,7 @@ locatable_locations(
| @assoc_item
| @assoc_item_list
| @attr
| @callable
| @closure_binder
| @expr
| @extern_item
@@ -255,6 +256,24 @@ attr_meta(
int meta: @meta ref
);
@callable =
@closure_expr
| @function
;
#keyset[id]
callable_param_lists(
int id: @callable ref,
int param_list: @param_list ref
);
#keyset[id, index]
callable_attrs(
int id: @callable ref,
int index: int ref,
int attr: @attr ref
);
closure_binders(
unique int id: @closure_binder
);
@@ -1395,13 +1414,6 @@ closure_exprs(
unique int id: @closure_expr
);
#keyset[id, index]
closure_expr_attrs(
int id: @closure_expr ref,
int index: int ref,
int attr: @attr ref
);
#keyset[id]
closure_expr_bodies(
int id: @closure_expr ref,
@@ -1439,12 +1451,6 @@ closure_expr_is_static(
int id: @closure_expr ref
);
#keyset[id]
closure_expr_param_lists(
int id: @closure_expr ref,
int param_list: @param_list ref
);
#keyset[id]
closure_expr_ret_types(
int id: @closure_expr ref,
@@ -2733,13 +2739,6 @@ function_abis(
int abi: @abi ref
);
#keyset[id, index]
function_attrs(
int id: @function ref,
int index: int ref,
int attr: @attr ref
);
#keyset[id]
function_bodies(
int id: @function ref,
@@ -2783,12 +2782,6 @@ function_names(
int name: @name ref
);
#keyset[id]
function_param_lists(
int id: @function ref,
int param_list: @param_list ref
);
#keyset[id]
function_ret_types(
int id: @function ref,

View File

@@ -3,12 +3,12 @@ import codeql.rust.elements
import TestUtils
from
ClosureExpr x, int getNumberOfAttrs, string hasBody, string hasClosureBinder, string isAsync,
string isConst, string isGen, string isMove, string isStatic, string hasParamList,
string hasRetType
ClosureExpr x, string hasParamList, int getNumberOfAttrs, string hasBody, string hasClosureBinder,
string isAsync, string isConst, string isGen, string isMove, string isStatic, string hasRetType
where
toBeTested(x) and
not x.isUnknown() and
(if x.hasParamList() then hasParamList = "yes" else hasParamList = "no") and
getNumberOfAttrs = x.getNumberOfAttrs() and
(if x.hasBody() then hasBody = "yes" else hasBody = "no") and
(if x.hasClosureBinder() then hasClosureBinder = "yes" else hasClosureBinder = "no") and
@@ -17,8 +17,7 @@ where
(if x.isGen() then isGen = "yes" else isGen = "no") and
(if x.isMove() then isMove = "yes" else isMove = "no") and
(if x.isStatic() then isStatic = "yes" else isStatic = "no") and
(if x.hasParamList() then hasParamList = "yes" else hasParamList = "no") and
if x.hasRetType() then hasRetType = "yes" else hasRetType = "no"
select x, "getNumberOfAttrs:", getNumberOfAttrs, "hasBody:", hasBody, "hasClosureBinder:",
hasClosureBinder, "isAsync:", isAsync, "isConst:", isConst, "isGen:", isGen, "isMove:", isMove,
"isStatic:", isStatic, "hasParamList:", hasParamList, "hasRetType:", hasRetType
select x, "hasParamList:", hasParamList, "getNumberOfAttrs:", getNumberOfAttrs, "hasBody:", hasBody,
"hasClosureBinder:", hasClosureBinder, "isAsync:", isAsync, "isConst:", isConst, "isGen:", isGen,
"isMove:", isMove, "isStatic:", isStatic, "hasRetType:", hasRetType

View File

@@ -3,14 +3,15 @@ import codeql.rust.elements
import TestUtils
from
Function x, string hasAbi, int getNumberOfAttrs, string hasBody, string hasGenericParamList,
string isAsync, string isConst, string isDefault, string isGen, string isUnsafe, string hasName,
string hasParamList, string hasRetType, string hasVisibility, string hasWhereClause
Function x, string hasParamList, int getNumberOfAttrs, string hasAbi, string hasBody,
string hasGenericParamList, string isAsync, string isConst, string isDefault, string isGen,
string isUnsafe, string hasName, string hasRetType, string hasVisibility, string hasWhereClause
where
toBeTested(x) and
not x.isUnknown() and
(if x.hasAbi() then hasAbi = "yes" else hasAbi = "no") and
(if x.hasParamList() then hasParamList = "yes" else hasParamList = "no") and
getNumberOfAttrs = x.getNumberOfAttrs() and
(if x.hasAbi() then hasAbi = "yes" else hasAbi = "no") and
(if x.hasBody() then hasBody = "yes" else hasBody = "no") and
(if x.hasGenericParamList() then hasGenericParamList = "yes" else hasGenericParamList = "no") and
(if x.isAsync() then isAsync = "yes" else isAsync = "no") and
@@ -19,12 +20,10 @@ where
(if x.isGen() then isGen = "yes" else isGen = "no") and
(if x.isUnsafe() then isUnsafe = "yes" else isUnsafe = "no") and
(if x.hasName() then hasName = "yes" else hasName = "no") and
(if x.hasParamList() then hasParamList = "yes" else hasParamList = "no") and
(if x.hasRetType() then hasRetType = "yes" else hasRetType = "no") and
(if x.hasVisibility() then hasVisibility = "yes" else hasVisibility = "no") and
if x.hasWhereClause() then hasWhereClause = "yes" else hasWhereClause = "no"
select x, "hasAbi:", hasAbi, "getNumberOfAttrs:", getNumberOfAttrs, "hasBody:", hasBody,
"hasGenericParamList:", hasGenericParamList, "isAsync:", isAsync, "isConst:", isConst,
"isDefault:", isDefault, "isGen:", isGen, "isUnsafe:", isUnsafe, "hasName:", hasName,
"hasParamList:", hasParamList, "hasRetType:", hasRetType, "hasVisibility:", hasVisibility,
"hasWhereClause:", hasWhereClause
select x, "hasParamList:", hasParamList, "getNumberOfAttrs:", getNumberOfAttrs, "hasAbi:", hasAbi,
"hasBody:", hasBody, "hasGenericParamList:", hasGenericParamList, "isAsync:", isAsync, "isConst:",
isConst, "isDefault:", isDefault, "isGen:", isGen, "isUnsafe:", isUnsafe, "hasName:", hasName,
"hasRetType:", hasRetType, "hasVisibility:", hasVisibility, "hasWhereClause:", hasWhereClause