From a2782a12f2ea3daa3d3d0a20915210d1ef9d99d6 Mon Sep 17 00:00:00 2001 From: Tom Hvitved Date: Tue, 25 Nov 2025 10:30:52 +0100 Subject: [PATCH] Rust: Run codegen --- rust/extractor/src/generated/.generated.list | 2 +- rust/extractor/src/generated/top.rs | 289 +++++++----------- rust/ql/.generated.list | 24 +- rust/ql/.gitattributes | 2 - .../internal/generated/CfgNodes.qll | 120 ++++---- rust/ql/lib/codeql/rust/elements.qll | 1 - rust/ql/lib/codeql/rust/elements/CallExpr.qll | 9 +- .../lib/codeql/rust/elements/CallExprBase.qll | 14 - .../codeql/rust/elements/MethodCallExpr.qll | 7 +- .../elements/internal/CallExprBaseImpl.qll | 27 -- .../rust/elements/internal/CallExprImpl.qll | 6 +- .../elements/internal/MethodCallExprImpl.qll | 4 + .../elements/internal/generated/CallExpr.qll | 43 ++- .../internal/generated/CallExprBase.qll | 75 ----- .../internal/generated/MethodCallExpr.qll | 45 ++- .../internal/generated/ParentChild.qll | 108 +++---- .../rust/elements/internal/generated/Raw.qll | 221 +++++++------- .../elements/internal/generated/Synth.qll | 41 +-- rust/ql/lib/rust.dbscheme | 91 +++--- .../generated/.generated_tests.list | 4 +- .../generated/CallExpr/CallExpr.ql | 4 - .../generated/CallExpr/gen_call_expr.rs | 6 +- .../MethodCallExpr/MethodCallExpr.ql | 4 - .../MethodCallExpr/gen_method_call_expr.rs | 4 + 24 files changed, 535 insertions(+), 616 deletions(-) delete mode 100644 rust/ql/lib/codeql/rust/elements/CallExprBase.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/CallExprBaseImpl.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/CallExprBase.qll diff --git a/rust/extractor/src/generated/.generated.list b/rust/extractor/src/generated/.generated.list index fa35ec65d4c..578b21fc992 100644 --- a/rust/extractor/src/generated/.generated.list +++ b/rust/extractor/src/generated/.generated.list @@ -1,2 +1,2 @@ mod.rs 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 4bcb9def847469aae9d8649461546b7c21ec97cf6e63d3cf394e339915ce65d7 -top.rs 460e827738766301a137f1750be7cd3016e6b7e4e487c6c95972bd3e1d21b814 460e827738766301a137f1750be7cd3016e6b7e4e487c6c95972bd3e1d21b814 +top.rs b829c8ab9ec5ff07b997b9ee0b2c333d63e24eddcf7c5fc2b95a9a7f17a84a69 b829c8ab9ec5ff07b997b9ee0b2c333d63e24eddcf7c5fc2b95a9a7f17a84a69 diff --git a/rust/extractor/src/generated/top.rs b/rust/extractor/src/generated/top.rs index 3c4b51c78e6..510f6579d40 100644 --- a/rust/extractor/src/generated/top.rs +++ b/rust/extractor/src/generated/top.rs @@ -4315,44 +4315,66 @@ impl From> for trap::Label { } #[derive(Debug)] -pub struct CallExprBase { - _unused: () +pub struct CallExpr { + pub id: trap::TrapId, + pub arg_list: Option>, + pub attrs: Vec>, + pub function: Option>, } -impl trap::TrapClass for CallExprBase { - fn class_name() -> &'static str { "CallExprBase" } +impl trap::TrapEntry for CallExpr { + fn extract_id(&mut self) -> trap::TrapId { + std::mem::replace(&mut self.id, trap::TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("call_exprs", vec![id.into()]); + if let Some(v) = self.arg_list { + out.add_tuple("call_expr_arg_lists", vec![id.into(), v.into()]); + } + for (i, v) in self.attrs.into_iter().enumerate() { + out.add_tuple("call_expr_attrs", vec![id.into(), i.into(), v.into()]); + } + if let Some(v) = self.function { + out.add_tuple("call_expr_functions", vec![id.into(), v.into()]); + } + } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme CallExprBase is a subclass of Expr +impl trap::TrapClass for CallExpr { + fn class_name() -> &'static str { "CallExpr" } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme CallExpr is a subclass of Expr unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme CallExprBase is a subclass of AstNode +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme CallExpr is a subclass of AstNode unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme CallExprBase is a subclass of Locatable +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme CallExpr is a subclass of Locatable unsafe { Self::from_untyped(value.as_untyped()) } } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme CallExprBase is a subclass of Element +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme CallExpr is a subclass of Element unsafe { Self::from_untyped(value.as_untyped()) } @@ -6430,6 +6452,81 @@ impl From> for trap::Label { } } +#[derive(Debug)] +pub struct MethodCallExpr { + pub id: trap::TrapId, + pub arg_list: Option>, + pub attrs: Vec>, + pub generic_arg_list: Option>, + pub identifier: Option>, + pub receiver: Option>, +} + +impl trap::TrapEntry for MethodCallExpr { + fn extract_id(&mut self) -> trap::TrapId { + std::mem::replace(&mut self.id, trap::TrapId::Star) + } + + fn emit(self, id: trap::Label, out: &mut trap::Writer) { + out.add_tuple("method_call_exprs", vec![id.into()]); + if let Some(v) = self.arg_list { + out.add_tuple("method_call_expr_arg_lists", vec![id.into(), v.into()]); + } + for (i, v) in self.attrs.into_iter().enumerate() { + out.add_tuple("method_call_expr_attrs", vec![id.into(), i.into(), v.into()]); + } + if let Some(v) = self.generic_arg_list { + out.add_tuple("method_call_expr_generic_arg_lists", vec![id.into(), v.into()]); + } + if let Some(v) = self.identifier { + out.add_tuple("method_call_expr_identifiers", vec![id.into(), v.into()]); + } + if let Some(v) = self.receiver { + out.add_tuple("method_call_expr_receivers", vec![id.into(), v.into()]); + } + } +} + +impl trap::TrapClass for MethodCallExpr { + fn class_name() -> &'static str { "MethodCallExpr" } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme MethodCallExpr is a subclass of Expr + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme MethodCallExpr is a subclass of AstNode + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme MethodCallExpr is a subclass of Locatable + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme MethodCallExpr is a subclass of Element + unsafe { + Self::from_untyped(value.as_untyped()) + } + } +} + #[derive(Debug)] pub struct NameRef { pub id: trap::TrapId, @@ -9242,82 +9339,6 @@ impl From> for trap::Label { } } -#[derive(Debug)] -pub struct CallExpr { - pub id: trap::TrapId, - pub arg_list: Option>, - pub attrs: Vec>, - pub function: Option>, -} - -impl trap::TrapEntry for CallExpr { - fn extract_id(&mut self) -> trap::TrapId { - std::mem::replace(&mut self.id, trap::TrapId::Star) - } - - fn emit(self, id: trap::Label, out: &mut trap::Writer) { - out.add_tuple("call_exprs", vec![id.into()]); - if let Some(v) = self.arg_list { - out.add_tuple("call_expr_base_arg_lists", vec![id.into(), v.into()]); - } - for (i, v) in self.attrs.into_iter().enumerate() { - out.add_tuple("call_expr_base_attrs", vec![id.into(), i.into(), v.into()]); - } - if let Some(v) = self.function { - out.add_tuple("call_expr_functions", vec![id.into(), v.into()]); - } - } -} - -impl trap::TrapClass for CallExpr { - fn class_name() -> &'static str { "CallExpr" } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme CallExpr is a subclass of CallExprBase - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme CallExpr is a subclass of Expr - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme CallExpr is a subclass of AstNode - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme CallExpr is a subclass of Locatable - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme CallExpr is a subclass of Element - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - #[derive(Debug)] pub struct ExternBlock { pub id: trap::TrapId, @@ -9908,90 +9929,6 @@ impl From> for trap::Label { } } -#[derive(Debug)] -pub struct MethodCallExpr { - pub id: trap::TrapId, - pub arg_list: Option>, - pub attrs: Vec>, - pub generic_arg_list: Option>, - pub identifier: Option>, - pub receiver: Option>, -} - -impl trap::TrapEntry for MethodCallExpr { - fn extract_id(&mut self) -> trap::TrapId { - std::mem::replace(&mut self.id, trap::TrapId::Star) - } - - fn emit(self, id: trap::Label, out: &mut trap::Writer) { - out.add_tuple("method_call_exprs", vec![id.into()]); - if let Some(v) = self.arg_list { - out.add_tuple("call_expr_base_arg_lists", vec![id.into(), v.into()]); - } - for (i, v) in self.attrs.into_iter().enumerate() { - out.add_tuple("call_expr_base_attrs", vec![id.into(), i.into(), v.into()]); - } - if let Some(v) = self.generic_arg_list { - out.add_tuple("method_call_expr_generic_arg_lists", vec![id.into(), v.into()]); - } - if let Some(v) = self.identifier { - out.add_tuple("method_call_expr_identifiers", vec![id.into(), v.into()]); - } - if let Some(v) = self.receiver { - out.add_tuple("method_call_expr_receivers", vec![id.into(), v.into()]); - } - } -} - -impl trap::TrapClass for MethodCallExpr { - fn class_name() -> &'static str { "MethodCallExpr" } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme MethodCallExpr is a subclass of CallExprBase - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme MethodCallExpr is a subclass of Expr - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme MethodCallExpr is a subclass of AstNode - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme MethodCallExpr is a subclass of Locatable - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme MethodCallExpr is a subclass of Element - unsafe { - Self::from_untyped(value.as_untyped()) - } - } -} - #[derive(Debug)] pub struct Module { pub id: trap::TrapId, diff --git a/rust/ql/.generated.list b/rust/ql/.generated.list index 98cd6b01af4..90100ca3a74 100644 --- a/rust/ql/.generated.list +++ b/rust/ql/.generated.list @@ -1,4 +1,4 @@ -lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll 11c7521ec2231a4d0447f30fc3d0bb14aebb659bd8cf75935af1050673a3b1d6 d0a77b572a032e43f1c47622315c0cdfe17e68c2b057534b9322fc528029fb40 +lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll e606d32260326869e16bbfacf2426c856d7225814a46d2803501668b41f6ef85 c1bd283bb1c1b74c60349d0b1327407adc983e8ee62c8b7f5ab525653f46bb78 lib/codeql/rust/elements/Abi.qll 485a2e79f6f7bfd1c02a6e795a71e62dede3c3e150149d5f8f18b761253b7208 6159ba175e7ead0dd2e3f2788f49516c306ee11b1a443bd4bdc00b7017d559bd lib/codeql/rust/elements/Addressable.qll 13011bfd2e1556694c3d440cc34af8527da4df49ad92b62f2939d3699ff2cea5 ddb25935f7553a1a384b1abe2e4b4fa90ab50b952dadec32fd867afcb054f4be lib/codeql/rust/elements/Adt.qll c2afed4ac2e17039ccd98f74ea22111f4d765c4e232c50ccd3128da0d26da837 1380bde2eb667c6ec2ef5f8710aa24e926851c9e321ebc72ba514fa92c369dc3 @@ -32,8 +32,7 @@ lib/codeql/rust/elements/BinaryExpr.qll 394522da3bc3a716fc7bc40c3560143ca840f5d2 lib/codeql/rust/elements/BlockExpr.qll b5cf57119b15f27d0bc258dfa375b0ef2730c157870ff543f0dc7a8cfe514182 f6a01999606b010c81ef9c6ff1385e6640632b6f5ce067ffeb0ef0af0a0aeb92 lib/codeql/rust/elements/BoxPat.qll 1b2c3fff171aa6aa238c9460b122f26c79e04577cea67fa856de99842ba873d4 0caf8d23ed6e0997a6b8751def27641582151fba6e24fccf798712a4690b42f1 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/CallExpr.qll d62a023838adc2ddb55d6831abc69745f0324e3bda8a6751ecbe11a7f28fa9c6 ad139445ed9b98e482965bbbd57ad5e8e8aca6bd2d28193fa9411958611be3de lib/codeql/rust/elements/Callable.qll 08a46e987b8fde29069795a536fcd1ad1a96f60341f72293e4d07e20334d554f cfc2be9287000718e5ff3c2a35bb45ffc93fd36d97f2e034888e9aa2ae9af555 lib/codeql/rust/elements/CastExpr.qll 2fe1f36ba31fa29de309baf0a665cfcae67b61c73345e8f9bbd41e8c235fec45 c5b4c1e9dc24eb2357799defcb2df25989075e3a80e8663b74204a1c1b70e29a lib/codeql/rust/elements/ClosureExpr.qll 69e0b7a7c7a4c348fcada5ad4da22dd2f51747109f856be239cede315a56d695 93400650282e2d4e682b826e9f5f844aa893dda126548e41ea1c703d2bf209ca @@ -103,7 +102,7 @@ lib/codeql/rust/elements/MatchArmList.qll f221c5e344814fa44db06ab897afdc249e8e88 lib/codeql/rust/elements/MatchExpr.qll e9ef1664f020823b6f4bb72d906a9dc0c1ee6432d4a9a13f7dbdbab2b2b1ee4d 38d71e5c487abcb5682293c573343be66e499a6e131bb630604c120d34b7777b lib/codeql/rust/elements/MatchGuard.qll 58256689a90f24b16401543452c2a32f00d619ddac6c0fe8b65a8cd3e46401bb 8efb2ac03c69a9db687e382331085d7a6cfbf8eca559174ba2727a9549ec7ddd lib/codeql/rust/elements/Meta.qll b17d7bf605bd0cf4f6d6c6cf4f39a16cfc431d256d45b93663a7569181d36168 815cdfef06231de4b4b1c85e321b8ccb3e22379e5a4e111df9cc9ca6be593841 -lib/codeql/rust/elements/MethodCallExpr.qll 91b411e0fb1a0547dcad8726db460dccc61bed972741598d5cb3740593fe75a7 538d23b6db115bb699389d29a1829bb0449c08424a1fff80377828eb7ceb2563 +lib/codeql/rust/elements/MethodCallExpr.qll 763f137debe28a4627cde7ac816f3380e0d04fa996bdaa8058cb726bbdf0ef29 36b093e1c50f83ade2e6c914b2f06ca718d2363a781140dcb02244f71e859d5e lib/codeql/rust/elements/Missing.qll 70e6ac9790314752849c9888443c98223ccfc93a193998b7ce350b2c6ebe8ea4 e2f0623511acaa76b091f748d417714137a8b94f1f2bdbbd177f1c682c786dad lib/codeql/rust/elements/Module.qll 0bc85019177709256f8078d9de2a36f62f848d476225bff7bba1e35f249875c7 3fbb70e0c417a644dd0cada2c364c6e6876cfa16f37960e219c87e49c966c94e lib/codeql/rust/elements/Name.qll af41479d4260fe931d46154dda15484e4733c952b98f0e370106e6e9e8ce398b e188a0d0309dd1b684c0cb88df435b38e306eb94d6b66a2b748e75252f15e095 @@ -478,8 +477,7 @@ lib/codeql/rust/elements/internal/generated/BinaryExpr.qll 64e9bd9c571edd6e5f3e7 lib/codeql/rust/elements/internal/generated/BlockExpr.qll 5a5ddbe34bc478a7bd9b0d07d3b6f017c2d1f20581d859251a963314e6514d1f 9804c30b8b279038b864c52557535f854bd012bacdfe8e5840f1f777c74e52df lib/codeql/rust/elements/internal/generated/BoxPat.qll 597bed52f7489e0addce3266f7bee5be7c53d2d1263eceec3a252d041ca0908f b8ccf363ca5f1a988547caf1fd266a55aec7cbf8623578deea99765d264b0151 lib/codeql/rust/elements/internal/generated/BreakExpr.qll 0f428a8b2f4209b134c2ffc3e1c93c30bc6b0e9c9172f140cefa88c1f77d8690 957b39f38ff6befe9061f55bc0b403c2f1c366dd0cf63b874bae6f8216576d76 -lib/codeql/rust/elements/internal/generated/CallExpr.qll f1b8dae487077cc9d1dccf8c3cd61fd17afe860585f17ce8b860be4859be7ca4 6034fc03778e38802cdf3a6e460364b74e92912622581b31e6179951022bbbd6 -lib/codeql/rust/elements/internal/generated/CallExprBase.qll 2268e01d65015014c05166161bb28e5a1e78164d525ca16fc1e3106866cf231d b2f9b912153ba4d3e3612df4f74ac0e83077c31d5b31383bd277974081417a56 +lib/codeql/rust/elements/internal/generated/CallExpr.qll 9d4b790e254f55a7df27da70d92a684af178e5c0cd3dcf29e47c8913b8ac9b1b 192cac3ffec5160d049fc7a63d78cb0f95be373167efeaa6b0789da97ffc33b1 lib/codeql/rust/elements/internal/generated/Callable.qll 12368b998c771c6b80f54123cea4d3600af7432ab34c9e571bc0bf3894ceb17e 273a9fd9cdae56cf2edbdc9c49b15da49cd5ad04be70acbbe2475c9c50200183 lib/codeql/rust/elements/internal/generated/CastExpr.qll ddc20054b0b339ad4d40298f3461490d25d00af87c876da5ffbc6a11c0832295 f4247307afcd74d80e926f29f8c57e78c50800984483e6b6003a44681e4a71f3 lib/codeql/rust/elements/internal/generated/ClosureExpr.qll 818aff75d86821c670d8ba0720c3270681b3e070140a9c41beab2a811b43eee6 9bf2d1d38f6c4a99d7c058f8ed096141f5ba6a75d2d26a464f0d65ed4e554222 @@ -550,7 +548,7 @@ lib/codeql/rust/elements/internal/generated/MatchArmList.qll 12d969ecb267a749918 lib/codeql/rust/elements/internal/generated/MatchExpr.qll b686842e7000fd61e3a0598bf245fb4e18167b99eca9162fdfdff0b0963def22 00f1743b1b0f1a92c5a687f5260fda02d80cc5871694cad0d5e7d94bac7fe977 lib/codeql/rust/elements/internal/generated/MatchGuard.qll 58fa1d6979ef22de2bd68574c7ffcf4a021d7543445f68834d879ff8cee3abcb 072f22a7929df3c0e764b2a770b4cdf03504b3053067d9b9008d6655fb5837e1 lib/codeql/rust/elements/internal/generated/Meta.qll 15e98e8d38f5618b7053057a629b135aae5e105fbf72731833a644fb695244c0 2977b6a0781c89383e87c595b14a39851f27b2508296f3e77466eea44c916188 -lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll 0cd0f84147e5f3887d609cc58246eb493d3461aee00ff37e7d26282c835f73af 6f4c5dc1decbce54fc12300d34798b890a85129208b25565130205c9d8ee2e29 +lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll b55332bbdd47b98077bdb1e3b83cc0b6fb93ce18d0e9b1c1ae7384a33af0971d 45b62bae14368edf1bab3931d3d9c2db97f09d67ef8649cace2d3c26143b2f05 lib/codeql/rust/elements/internal/generated/Missing.qll 16735d91df04a4e1ae52fae25db5f59a044e540755734bbab46b5fbb0fe6b0bd 28ca4e49fb7e6b4734be2f2f69e7c224c570344cc160ef80c5a5cd413e750dad lib/codeql/rust/elements/internal/generated/Module.qll ebae5d8963c9fd569c0fbad1d7770abd3fd2479437f236cbce0505ba9f9af52c fa3c382115fed18a26f1a755d8749a201b9489f82c09448a88fb8e9e1435fe5f lib/codeql/rust/elements/internal/generated/Name.qll e6bd6240a051383a52b21ab539bc204ce7bcd51a1a4379e497dff008d4eef5b4 578a3b45e70f519d57b3e3a3450f6272716c849940daee49889717c7aaa85fc9 @@ -565,7 +563,7 @@ lib/codeql/rust/elements/internal/generated/ParamList.qll eaa0cd4402d3665013d47e lib/codeql/rust/elements/internal/generated/ParenExpr.qll 812d2ff65079277f39f15c084657a955a960a7c1c0e96dd60472a58d56b945eb eb8c607f43e1fcbb41f37a10de203a1db806690e10ff4f04d48ed874189cb0eb lib/codeql/rust/elements/internal/generated/ParenPat.qll 24f9dc7fce75827d6fddb856cd48f80168143151b27295c0bab6db5a06567a09 ebadbc6f5498e9ed754b39893ce0763840409a0721036a25b56e1ead7dcc09aa lib/codeql/rust/elements/internal/generated/ParenTypeRepr.qll 03f5c5b96a37adeb845352d7fcea3e098da9050e534972d14ac0f70d60a2d776 ed3d6e5d02086523087adebce4e89e35461eb95f2a66d1d4100fe23fc691b126 -lib/codeql/rust/elements/internal/generated/ParentChild.qll f04ca3d02170f7e532a480cc81748cf04f1b022d5e0e32ffcdf0f15c8f1961aa 999104d69a5435c9cab594e04b82ed26ae38b1b1d2ac1dbbb315a433c586f941 +lib/codeql/rust/elements/internal/generated/ParentChild.qll 8a6e4335bcf6f7d72f5ed6ffba5448ae88b00323fe7dac6f406c8746c03ef2dc 867a0fb166b53d7a8218a02d671f117ba7ea4e67cb16abeea6e746dc5823b85e lib/codeql/rust/elements/internal/generated/ParenthesizedArgList.qll d901fdc8142a5b8847cc98fc2afcfd16428b8ace4fbffb457e761b5fd3901a77 5dbb0aea5a13f937da666ccb042494af8f11e776ade1459d16b70a4dd193f9fb lib/codeql/rust/elements/internal/generated/Pat.qll 3605ac062be2f294ee73336e9669027b8b655f4ad55660e1eab35266275154ee 7f9400db2884d336dd1d21df2a8093759c2a110be9bf6482ce8e80ae0fd74ed4 lib/codeql/rust/elements/internal/generated/Path.qll 9b12afb46fc5a9ad3a811b05472621bbecccb900c47504feb7f29d96b28421ca bcacbffc36fb3e0c9b26523b5963af0ffa9fd6b19f00a2a31bdb2316071546bd @@ -580,7 +578,7 @@ lib/codeql/rust/elements/internal/generated/PtrTypeRepr.qll 8d0ea4f6c7f8203340bf lib/codeql/rust/elements/internal/generated/PureSynthConstructors.qll e5b8e69519012bbaae29dcb82d53f7f7ecce368c0358ec27ef6180b228a0057f e5b8e69519012bbaae29dcb82d53f7f7ecce368c0358ec27ef6180b228a0057f lib/codeql/rust/elements/internal/generated/RangeExpr.qll 23cca03bf43535f33b22a38894f70d669787be4e4f5b8fe5c8f7b964d30e9027 18624cef6c6b679eeace2a98737e472432e0ead354cca02192b4d45330f047c9 lib/codeql/rust/elements/internal/generated/RangePat.qll 80826a6a6868a803aa2372e31c52a03e1811a3f1f2abdb469f91ca0bfdd9ecb6 34ee1e208c1690cba505dff2c588837c0cd91e185e2a87d1fe673191962276a9 -lib/codeql/rust/elements/internal/generated/Raw.qll 14758dc2e2a9af251f24e24516eab0fc95d334c1da06f418ea5da3c5521642c9 a8b6637f57293a85714cc8761f8fd1e23780d58f3873acaa3c77acd9cbfcf19f +lib/codeql/rust/elements/internal/generated/Raw.qll 9920debdd14266377c45b212dd911e429ec605a28e1e6c753d5a73980f2f2621 7a53fc08c28aa5d303f8e1909407f6a90a498b0835f7f25c7e0f7c450d3374f6 lib/codeql/rust/elements/internal/generated/RefExpr.qll 7d995884e3dc1c25fc719f5d7253179344d63650e217e9ff6530285fe7a57f64 f2c3c12551deea4964b66553fb9b6423ee16fec53bd63db4796191aa60dc6c66 lib/codeql/rust/elements/internal/generated/RefPat.qll 456ede39837463ee22a630ec7ab6c8630d3664a8ea206fcc6e4f199e92fa564c 5622062765f32930465ba6b170e986706f159f6070f48adee3c20e24e8df4e05 lib/codeql/rust/elements/internal/generated/RefTypeRepr.qll 5b0663a6d234572fb3e467e276d019415caa95ef006438cc59b7af4e1783161e 0e27c8a8f0e323c0e4d6db01fca821bf07c0864d293cdf96fa891b10820c1e4b @@ -605,7 +603,7 @@ lib/codeql/rust/elements/internal/generated/StructFieldList.qll 5da528a51a6a5db9 lib/codeql/rust/elements/internal/generated/StructPat.qll c76fa005c2fd0448a8803233e1e8818c4123301eb66ac5cf69d0b9eaafc61e98 6e0dffccdce24bca20e87d5ba0f0995c9a1ae8983283e71e7dbfcf6fffc67a58 lib/codeql/rust/elements/internal/generated/StructPatField.qll 5b5c7302dbc4a902ca8e69ff31875c867e295a16a626ba3cef29cd0aa248f179 4e192a0df79947f5cb0d47fdbbba7986137a6a40a1be92ae119873e2fad67edf lib/codeql/rust/elements/internal/generated/StructPatFieldList.qll 1a95a1bd9f64fb18e9571657cf2d02a8b13c747048a1f0f74baf31b91f0392ad fc274e414ff4ed54386046505920de92755ad0b4d39a7523cdffa4830bd53b37 -lib/codeql/rust/elements/internal/generated/Synth.qll a8ea364358a2bc3a9226d451c0867e89c29509a0f54dd88ed23c77045db2c85a a44de5e84a63cb5a1bfa66b0df33bf28c9f8b6628393d0f3b2f6215dabee47bd +lib/codeql/rust/elements/internal/generated/Synth.qll 61147c264e863dc5234b391ad2b7a01e0a2fe99e18ea237ba06e31340fd0a50a 6d33624a9b571d05aba1e9459a211f75b762e72fa716259abcd994f5098e15a6 lib/codeql/rust/elements/internal/generated/SynthConstructors.qll f41abfc73415b7accb38da7c107faebfe6843c270ad54e0e54a96e930dfe479a f41abfc73415b7accb38da7c107faebfe6843c270ad54e0e54a96e930dfe479a lib/codeql/rust/elements/internal/generated/Token.qll 77a91a25ca5669703cf3a4353b591cef4d72caa6b0b9db07bb9e005d69c848d1 2fdffc4882ed3a6ca9ac6d1fb5f1ac5a471ca703e2ffdc642885fa558d6e373b lib/codeql/rust/elements/internal/generated/TokenTree.qll 1a3c4f5f30659738641abdd28cb793dab3cfde484196b59656fc0a2767e53511 de2ebb210c7759ef7a6f7ee9f805e1cac879221287281775fc80ba34a5492edf @@ -642,7 +640,7 @@ lib/codeql/rust/elements/internal/generated/WhileExpr.qll 0353aab87c49569e1fbf58 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 d3beb3a35f2b5ea47d60aeefd86fb0d6406dd0a1b7cd89aecbb2732b4e72da38 d3beb3a35f2b5ea47d60aeefd86fb0d6406dd0a1b7cd89aecbb2732b4e72da38 +lib/codeql/rust/elements.qll 5cc722db81259ee5d5b9cbed1a4d2795060ad996c80fd7121e7ce43dc392b62f 5cc722db81259ee5d5b9cbed1a4d2795060ad996c80fd7121e7ce43dc392b62f test/extractor-tests/generated/Abi/Abi.ql 086ed104ab1a7e7fe5c1ed29e03f1719a797c7096c738868bf6ebe872ab8fdaa fe23fe67ab0d9201e1177ea3f844b18ed428e13e3ce77381bf2b6910adfa3a0e test/extractor-tests/generated/ArgList/ArgList.ql da97b5b25418b2aa8cb8df793f48870c89fa00759cdade8ddba60d7f1f4bbc01 acfd5d2caf67282ad2d57b961068472100482d0f770a52a3c00214c647d18c75 test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.ql 42b365276aa43e2cad588338463542d3ce1dd0db3a428621554584b07a1431d5 08a66a8b69af35ee3bc64c35c453a19a6c9881cc6cc7e65275d1fff056121270 @@ -668,7 +666,7 @@ test/extractor-tests/generated/BinaryExpr/BinaryExpr.ql 4e849e6eaae581f487aa74d0 test/extractor-tests/generated/BlockExpr/BlockExpr.ql cd6ef66de9e56ebb74964e59617d47999fb8c9081e885acece17a3b747a35ae1 6766844c1b87e518688565f2469575af5ca4e0ff4eb0c0b620df73a451d86a0b test/extractor-tests/generated/BoxPat/BoxPat.ql 854c9ba4e045dbe7ea1666866c1c443a92597df0ce02f4ca5993142925941c39 a22c17cce0bff7d1df51b817d2cb1a61045357f91be14465166971efa5f5daad test/extractor-tests/generated/BreakExpr/BreakExpr.ql c2181211da3dfe983cfca93ead32d5d211e91181899b9477152c58124eaa846d 57e57b926e14db2efb2e88e04699608b2ba9797ee4f6c4f710135b6858982256 -test/extractor-tests/generated/CallExpr/CallExpr.ql 2a1cd4485ccd8d4eb24a75889e832612adef9bb7feae414c90572796380bc6d7 95060b92aa04d7ad1fc6603c5ec14a275a5788ecb5a19932732e28105607a3b7 +test/extractor-tests/generated/CallExpr/CallExpr.ql 16d85d6e5cb68384d0b932fb4506c1855019b819f2c5faa39a4472f39427623a 14df8383948cedaff88f514f7239c1ec8c424720d24e3546cbcd0b689acecdb1 test/extractor-tests/generated/CastExpr/CastExpr.ql 3480ec51072399409b7553ab6139c832db6ed4ca991f3a7a2282a39afe07c6f2 614c8ea7a2fe30d57583dbf84ed7a12743c2aba49d8c6252d31af3ed10853a39 test/extractor-tests/generated/ClosureExpr/ClosureExpr.ql 675ae07193241fbd710ece4f74f86e9b00f47841299b1c5934f55dbf13a4b4af 21fb0664619c9c889e9491bfd651c2814dcf0f158dd6269937bd0acc18be6b0e test/extractor-tests/generated/Comment/Comment.ql 0e0454911d2cf2e7ef5c6d860b84c57b9d490090914ebcf4fa0e8a70f777f066 cbd1c195276ef163f8d3c122344738c884dc9fb70eb2f9b7067829d735d48c4c @@ -727,7 +725,7 @@ test/extractor-tests/generated/MatchArmList/MatchArmList.ql bbc679fe6d8dedf9131d test/extractor-tests/generated/MatchExpr/MatchExpr.ql b75a5936401bb5ca38686f1413f5c8267ad685722560a2e9041dacf2f8d54abc 7da57118fe5b1f7f5cbe8d6b5f3ae70816fd4837b1c2e6401b98175b36ca233f test/extractor-tests/generated/MatchGuard/MatchGuard.ql 91de18a0a18d120db568b2c329e5cb26f83e327cf22c5825c555ea17249d7d23 0bcdb25895362128517227c860b9dad76851215c2cdf9b2d0e5cc3534278f4ec test/extractor-tests/generated/Meta/Meta.ql 43dd1cd669099b38396b316616992af6d84b0c1cee953b19235a00ab3d3bb43c 80b1885809aa074357e21707d1f8c6dca19f0b968ccff43229bb0d5c6fffb2b2 -test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql 05ca29fdab8ce600469728b964c369368e5097b2a5eb35b84a7630ef044ac6b6 aa45fdbb7fba8afee9f6cef10d337622429d3f0fb71f7fbf861afb4906bdef71 +test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql 9d5af6b4771a8725fa5b56ccb3e2a33158b18c876546b88e6dc63da1f887910a 494c8c2fe5584aac45c828b38d8bb20c113927a1e909773d4a2dbd3965d26170 test/extractor-tests/generated/Module/Module.ql d7c442fd1b1f4f00da87e2228fc1aeeab0bb86648b2aa06a9dd6f40dbae1ee28 3229388727d14048e87238bcda5fde1bed503e5cac088922381e5833cfc32fa9 test/extractor-tests/generated/Name/Name.ql b2fe417f7c816f71d12622b4f84ece74eba3c128c806266a55b53f8120fa4fb3 8bc65bbf3f2909637485f5db7830d6fc110a94c9b12eefe12d7627f41eae2256 test/extractor-tests/generated/NameRef/NameRef.ql 210a70e0957f3444195eed3a3dfbb5806e349238c0b390dc00597e6b8b05fcec d74fbce3c71aa7b08ae4cb646ccb114335767cb4fe000322f9dd371c1bb3784f diff --git a/rust/ql/.gitattributes b/rust/ql/.gitattributes index 6afbf118f11..22c7d3a1549 100644 --- a/rust/ql/.gitattributes +++ b/rust/ql/.gitattributes @@ -35,7 +35,6 @@ /lib/codeql/rust/elements/BoxPat.qll linguist-generated /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/ClosureExpr.qll linguist-generated @@ -481,7 +480,6 @@ /lib/codeql/rust/elements/internal/generated/BoxPat.qll linguist-generated /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/ClosureExpr.qll linguist-generated diff --git a/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll b/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll index 9ce771983a3..a00c78bde61 100644 --- a/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll +++ b/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll @@ -654,15 +654,19 @@ module MakeCfgNodes Input> { } /** - * A function call expression. For example: + * NOTE: Consider using `Call` instead, as that includes all kinds of calls to + * functions, and excludes instantiations of tuple structs and tuple enum variants. + * + * A call expression. For example: * ```rust * foo(42); * foo::(42); * foo[0](42); * foo(1) = 4; + * Option::Some(42); // tuple enum variant instantiation * ``` */ - final class CallExprCfgNode extends CfgNodeFinal, CallExprBaseCfgNode { + final class CallExprCfgNode extends CfgNodeFinal, ExprCfgNode { private CallExpr node; CallExprCfgNode() { node = this.getAstNode() } @@ -670,6 +674,31 @@ module MakeCfgNodes Input> { /** Gets the underlying `CallExpr`. */ CallExpr getCallExpr() { result = node } + /** + * Gets the argument list of this call expression, if it exists. + */ + ArgList getArgList() { result = node.getArgList() } + + /** + * Holds if `getArgList()` exists. + */ + predicate hasArgList() { exists(this.getArgList()) } + + /** + * Gets the `index`th attr of this call expression (0-based). + */ + Attr getAttr(int index) { result = node.getAttr(index) } + + /** + * Gets any of the attrs of this call expression. + */ + Attr getAnAttr() { result = this.getAttr(_) } + + /** + * Gets the number of attrs of this call expression. + */ + int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } + /** * Gets the function of this call expression, if it exists. */ @@ -683,62 +712,6 @@ module MakeCfgNodes Input> { predicate hasFunction() { exists(this.getFunction()) } } - final private class ParentCallExprBase extends ParentAstNode, CallExprBase { - override predicate relevantChild(AstNode child) { none() } - } - - /** - * A function or method call expression. See `CallExpr` and `MethodCallExpr` for further details. - */ - final class CallExprBaseCfgNode extends CfgNodeFinal, ExprCfgNode { - private CallExprBase node; - - CallExprBaseCfgNode() { node = this.getAstNode() } - - /** Gets the underlying `CallExprBase`. */ - CallExprBase getCallExprBase() { result = node } - - /** - * Gets the argument list of this call expression base, if it exists. - */ - ArgList getArgList() { result = node.getArgList() } - - /** - * Holds if `getArgList()` exists. - */ - predicate hasArgList() { exists(this.getArgList()) } - - /** - * Gets the `index`th attr of this call expression base (0-based). - */ - Attr getAttr(int index) { result = node.getAttr(index) } - - /** - * Gets any of the attrs of this call expression base. - */ - Attr getAnAttr() { result = this.getAttr(_) } - - /** - * Gets the number of attrs of this call expression base. - */ - int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } - - /** - * Gets the `index`th argument of this call expression base (0-based). - */ - Expr getArg(int index) { result = node.getArg(index) } - - /** - * Gets any of the arguments of this call expression base. - */ - Expr getAnArg() { result = this.getArg(_) } - - /** - * Gets the number of arguments of this call expression base. - */ - int getNumberOfArgs() { result = count(int i | exists(this.getArg(i))) } - } - final private class ParentCastExpr extends ParentAstNode, CastExpr { override predicate relevantChild(AstNode child) { none() @@ -2071,13 +2044,17 @@ module MakeCfgNodes Input> { } /** + * NOTE: Consider using `MethodCall` instead, as that also includes calls to methods using + * function call syntax (such as `Foo::method(x)`), operator calls (such as `x + y`), and + * indexing calls (such as `x[y]`). + * * A method call expression. For example: * ```rust * x.foo(42); * x.foo::(42); * ``` */ - final class MethodCallExprCfgNode extends CfgNodeFinal, CallExprBaseCfgNode { + final class MethodCallExprCfgNode extends CfgNodeFinal, ExprCfgNode { private MethodCallExpr node; MethodCallExprCfgNode() { node = this.getAstNode() } @@ -2085,6 +2062,31 @@ module MakeCfgNodes Input> { /** Gets the underlying `MethodCallExpr`. */ MethodCallExpr getMethodCallExpr() { result = node } + /** + * Gets the argument list of this method call expression, if it exists. + */ + ArgList getArgList() { result = node.getArgList() } + + /** + * Holds if `getArgList()` exists. + */ + predicate hasArgList() { exists(this.getArgList()) } + + /** + * Gets the `index`th attr of this method call expression (0-based). + */ + Attr getAttr(int index) { result = node.getAttr(index) } + + /** + * Gets any of the attrs of this method call expression. + */ + Attr getAnAttr() { result = this.getAttr(_) } + + /** + * Gets the number of attrs of this method call expression. + */ + int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } + /** * Gets the generic argument list of this method call expression, if it exists. */ diff --git a/rust/ql/lib/codeql/rust/elements.qll b/rust/ql/lib/codeql/rust/elements.qll index b42a93efc6c..9c7d0be306f 100644 --- a/rust/ql/lib/codeql/rust/elements.qll +++ b/rust/ql/lib/codeql/rust/elements.qll @@ -38,7 +38,6 @@ import codeql.rust.elements.BlockExpr 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.ClosureExpr diff --git a/rust/ql/lib/codeql/rust/elements/CallExpr.qll b/rust/ql/lib/codeql/rust/elements/CallExpr.qll index ab5631b07ca..41d509cf85a 100644 --- a/rust/ql/lib/codeql/rust/elements/CallExpr.qll +++ b/rust/ql/lib/codeql/rust/elements/CallExpr.qll @@ -4,16 +4,21 @@ */ private import internal.CallExprImpl -import codeql.rust.elements.CallExprBase +import codeql.rust.elements.ArgList +import codeql.rust.elements.Attr import codeql.rust.elements.Expr /** - * A function call expression. For example: + * NOTE: Consider using `Call` instead, as that includes all kinds of calls to + * functions, and excludes instantiations of tuple structs and tuple enum variants. + * + * A call expression. For example: * ```rust * foo(42); * foo::(42); * foo[0](42); * foo(1) = 4; + * Option::Some(42); // tuple enum variant instantiation * ``` */ final class CallExpr = Impl::CallExpr; diff --git a/rust/ql/lib/codeql/rust/elements/CallExprBase.qll b/rust/ql/lib/codeql/rust/elements/CallExprBase.qll deleted file mode 100644 index d59c4c705f7..00000000000 --- a/rust/ql/lib/codeql/rust/elements/CallExprBase.qll +++ /dev/null @@ -1,14 +0,0 @@ -// generated by codegen, do not edit -/** - * This module provides the public class `CallExprBase`. - */ - -private import internal.CallExprBaseImpl -import codeql.rust.elements.ArgList -import codeql.rust.elements.Attr -import codeql.rust.elements.Expr - -/** - * A function or method call expression. See `CallExpr` and `MethodCallExpr` for further details. - */ -final class CallExprBase = Impl::CallExprBase; diff --git a/rust/ql/lib/codeql/rust/elements/MethodCallExpr.qll b/rust/ql/lib/codeql/rust/elements/MethodCallExpr.qll index fca8b086134..0ca6cd3595b 100644 --- a/rust/ql/lib/codeql/rust/elements/MethodCallExpr.qll +++ b/rust/ql/lib/codeql/rust/elements/MethodCallExpr.qll @@ -4,12 +4,17 @@ */ private import internal.MethodCallExprImpl -import codeql.rust.elements.CallExprBase +import codeql.rust.elements.ArgList +import codeql.rust.elements.Attr import codeql.rust.elements.Expr import codeql.rust.elements.GenericArgList import codeql.rust.elements.NameRef /** + * NOTE: Consider using `MethodCall` instead, as that also includes calls to methods using + * function call syntax (such as `Foo::method(x)`), operator calls (such as `x + y`), and + * indexing calls (such as `x[y]`). + * * A method call expression. For example: * ```rust * x.foo(42); diff --git a/rust/ql/lib/codeql/rust/elements/internal/CallExprBaseImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/CallExprBaseImpl.qll deleted file mode 100644 index 05d5aee7a06..00000000000 --- a/rust/ql/lib/codeql/rust/elements/internal/CallExprBaseImpl.qll +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This module provides a hand-modifiable wrapper around the generated class `CallExprBase`. - * - * INTERNAL: Do not use. - */ - -private import codeql.rust.elements.internal.generated.CallExprBase - -/** - * INTERNAL: This module contains the customizable definition of `CallExprBase` and should not - * be referenced directly. - */ -module Impl { - private import rust - private import codeql.rust.internal.TypeInference as TypeInference - - // the following QLdoc is generated: if you need to edit it, do it in the schema file - /** - * A function or method call expression. See `CallExpr` and `MethodCallExpr` for further details. - */ - class CallExprBase extends Generated::CallExprBase { - /** Gets the static target (function or tuple struct/variant) of this call, if any. */ - final Addressable getStaticTarget() { result = TypeInference::resolveCallTarget(this) } - - override Expr getArg(int index) { result = this.getArgList().getArg(index) } - } -} diff --git a/rust/ql/lib/codeql/rust/elements/internal/CallExprImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/CallExprImpl.qll index 5723e1fdbb5..280b05c3b3c 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/CallExprImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/CallExprImpl.qll @@ -25,12 +25,16 @@ module Impl { // the following QLdoc is generated: if you need to edit it, do it in the schema file /** - * A function call expression. For example: + * NOTE: Consider using `Call` instead, as that includes all kinds of calls to + * functions, and excludes instantiations of tuple structs and tuple enum variants. + * + * A call expression. For example: * ```rust * foo(42); * foo::(42); * foo[0](42); * foo(1) = 4; + * Option::Some(42); // tuple enum variant instantiation * ``` */ class CallExpr extends Generated::CallExpr { diff --git a/rust/ql/lib/codeql/rust/elements/internal/MethodCallExprImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/MethodCallExprImpl.qll index 7617ae456bb..7e949026400 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/MethodCallExprImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/MethodCallExprImpl.qll @@ -14,6 +14,10 @@ private import codeql.rust.elements.internal.generated.MethodCallExpr module Impl { // the following QLdoc is generated: if you need to edit it, do it in the schema file /** + * NOTE: Consider using `MethodCall` instead, as that also includes calls to methods using + * function call syntax (such as `Foo::method(x)`), operator calls (such as `x + y`), and + * indexing calls (such as `x[y]`). + * * A method call expression. For example: * ```rust * x.foo(42); diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/CallExpr.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/CallExpr.qll index 829de70510b..57acb9387c9 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/CallExpr.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/CallExpr.qll @@ -6,8 +6,10 @@ private import codeql.rust.elements.internal.generated.Synth private import codeql.rust.elements.internal.generated.Raw -import codeql.rust.elements.internal.CallExprBaseImpl::Impl as CallExprBaseImpl +import codeql.rust.elements.ArgList +import codeql.rust.elements.Attr import codeql.rust.elements.Expr +import codeql.rust.elements.internal.ExprImpl::Impl as ExprImpl /** * INTERNAL: This module contains the fully generated definition of `CallExpr` and should not @@ -15,19 +17,54 @@ import codeql.rust.elements.Expr */ module Generated { /** - * A function call expression. For example: + * NOTE: Consider using `Call` instead, as that includes all kinds of calls to + * functions, and excludes instantiations of tuple structs and tuple enum variants. + * + * A call expression. For example: * ```rust * foo(42); * foo::(42); * foo[0](42); * foo(1) = 4; + * Option::Some(42); // tuple enum variant instantiation * ``` * INTERNAL: Do not reference the `Generated::CallExpr` class directly. * Use the subclass `CallExpr`, where the following predicates are available. */ - class CallExpr extends Synth::TCallExpr, CallExprBaseImpl::CallExprBase { + class CallExpr extends Synth::TCallExpr, ExprImpl::Expr { override string getAPrimaryQlClass() { result = "CallExpr" } + /** + * Gets the argument list of this call expression, if it exists. + */ + ArgList getArgList() { + result = + Synth::convertArgListFromRaw(Synth::convertCallExprToRaw(this).(Raw::CallExpr).getArgList()) + } + + /** + * Holds if `getArgList()` exists. + */ + final predicate hasArgList() { exists(this.getArgList()) } + + /** + * Gets the `index`th attr of this call expression (0-based). + */ + Attr getAttr(int index) { + result = + Synth::convertAttrFromRaw(Synth::convertCallExprToRaw(this).(Raw::CallExpr).getAttr(index)) + } + + /** + * Gets any of the attrs of this call expression. + */ + final Attr getAnAttr() { result = this.getAttr(_) } + + /** + * Gets the number of attrs of this call expression. + */ + final int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } + /** * Gets the function of this call expression, if it exists. */ diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/CallExprBase.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/CallExprBase.qll deleted file mode 100644 index 1d6364fb94f..00000000000 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/CallExprBase.qll +++ /dev/null @@ -1,75 +0,0 @@ -// generated by codegen, do not edit -/** - * This module provides the generated definition of `CallExprBase`. - * 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.ArgList -import codeql.rust.elements.Attr -import codeql.rust.elements.Expr -import codeql.rust.elements.internal.ExprImpl::Impl as ExprImpl - -/** - * INTERNAL: This module contains the fully generated definition of `CallExprBase` and should not - * be referenced directly. - */ -module Generated { - /** - * A function or method call expression. See `CallExpr` and `MethodCallExpr` for further details. - * INTERNAL: Do not reference the `Generated::CallExprBase` class directly. - * Use the subclass `CallExprBase`, where the following predicates are available. - */ - class CallExprBase extends Synth::TCallExprBase, ExprImpl::Expr { - /** - * Gets the argument list of this call expression base, if it exists. - */ - ArgList getArgList() { - result = - Synth::convertArgListFromRaw(Synth::convertCallExprBaseToRaw(this) - .(Raw::CallExprBase) - .getArgList()) - } - - /** - * Holds if `getArgList()` exists. - */ - final predicate hasArgList() { exists(this.getArgList()) } - - /** - * Gets the `index`th attr of this call expression base (0-based). - */ - Attr getAttr(int index) { - result = - Synth::convertAttrFromRaw(Synth::convertCallExprBaseToRaw(this) - .(Raw::CallExprBase) - .getAttr(index)) - } - - /** - * Gets any of the attrs of this call expression base. - */ - final Attr getAnAttr() { result = this.getAttr(_) } - - /** - * Gets the number of attrs of this call expression base. - */ - final int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } - - /** - * Gets the `index`th argument of this call expression base (0-based). - */ - Expr getArg(int index) { none() } - - /** - * Gets any of the arguments of this call expression base. - */ - final Expr getAnArg() { result = this.getArg(_) } - - /** - * Gets the number of arguments of this call expression base. - */ - final int getNumberOfArgs() { result = count(int i | exists(this.getArg(i))) } - } -} diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll index 8908b71b7af..1dc27303079 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/MethodCallExpr.qll @@ -6,8 +6,10 @@ private import codeql.rust.elements.internal.generated.Synth private import codeql.rust.elements.internal.generated.Raw -import codeql.rust.elements.internal.CallExprBaseImpl::Impl as CallExprBaseImpl +import codeql.rust.elements.ArgList +import codeql.rust.elements.Attr import codeql.rust.elements.Expr +import codeql.rust.elements.internal.ExprImpl::Impl as ExprImpl import codeql.rust.elements.GenericArgList import codeql.rust.elements.NameRef @@ -17,6 +19,10 @@ import codeql.rust.elements.NameRef */ module Generated { /** + * NOTE: Consider using `MethodCall` instead, as that also includes calls to methods using + * function call syntax (such as `Foo::method(x)`), operator calls (such as `x + y`), and + * indexing calls (such as `x[y]`). + * * A method call expression. For example: * ```rust * x.foo(42); @@ -25,9 +31,44 @@ module Generated { * INTERNAL: Do not reference the `Generated::MethodCallExpr` class directly. * Use the subclass `MethodCallExpr`, where the following predicates are available. */ - class MethodCallExpr extends Synth::TMethodCallExpr, CallExprBaseImpl::CallExprBase { + class MethodCallExpr extends Synth::TMethodCallExpr, ExprImpl::Expr { override string getAPrimaryQlClass() { result = "MethodCallExpr" } + /** + * Gets the argument list of this method call expression, if it exists. + */ + ArgList getArgList() { + result = + Synth::convertArgListFromRaw(Synth::convertMethodCallExprToRaw(this) + .(Raw::MethodCallExpr) + .getArgList()) + } + + /** + * Holds if `getArgList()` exists. + */ + final predicate hasArgList() { exists(this.getArgList()) } + + /** + * Gets the `index`th attr of this method call expression (0-based). + */ + Attr getAttr(int index) { + result = + Synth::convertAttrFromRaw(Synth::convertMethodCallExprToRaw(this) + .(Raw::MethodCallExpr) + .getAttr(index)) + } + + /** + * Gets any of the attrs of this method call expression. + */ + final Attr getAnAttr() { result = this.getAttr(_) } + + /** + * Gets the number of attrs of this method call expression. + */ + final int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } + /** * Gets the generic argument list of this method call expression, if it exists. */ diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll index 233c29e0173..9d6ec74a53e 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll @@ -1070,6 +1070,25 @@ private module Impl { ) } + private Element getImmediateChildOfCallExpr(CallExpr e, int index, string partialPredicateCall) { + exists(int n, int nArgList, int nAttr, int nFunction | + n = 0 and + nArgList = n + 1 and + nAttr = nArgList + e.getNumberOfAttrs() and + nFunction = nAttr + 1 and + ( + none() + or + index = n and result = e.getArgList() and partialPredicateCall = "ArgList()" + or + result = e.getAttr(index - nArgList) and + partialPredicateCall = "Attr(" + (index - nArgList).toString() + ")" + or + index = nAttr and result = e.getFunction() and partialPredicateCall = "Function()" + ) + ) + } + private Element getImmediateChildOfCastExpr(CastExpr e, int index, string partialPredicateCall) { exists(int n, int nAttr, int nExpr, int nTypeRepr | n = 0 and @@ -1563,6 +1582,37 @@ private module Impl { ) } + private Element getImmediateChildOfMethodCallExpr( + MethodCallExpr e, int index, string partialPredicateCall + ) { + exists(int n, int nArgList, int nAttr, int nGenericArgList, int nIdentifier, int nReceiver | + n = 0 and + nArgList = n + 1 and + nAttr = nArgList + e.getNumberOfAttrs() and + nGenericArgList = nAttr + 1 and + nIdentifier = nGenericArgList + 1 and + nReceiver = nIdentifier + 1 and + ( + none() + or + index = n and result = e.getArgList() and partialPredicateCall = "ArgList()" + or + result = e.getAttr(index - nArgList) and + partialPredicateCall = "Attr(" + (index - nArgList).toString() + ")" + or + index = nAttr and + result = e.getGenericArgList() and + partialPredicateCall = "GenericArgList()" + or + index = nGenericArgList and + result = e.getIdentifier() and + partialPredicateCall = "Identifier()" + or + index = nIdentifier and result = e.getReceiver() and partialPredicateCall = "Receiver()" + ) + ) + } + private Element getImmediateChildOfNameRef(NameRef e, int index, string partialPredicateCall) { none() } @@ -2228,25 +2278,6 @@ private module Impl { ) } - private Element getImmediateChildOfCallExpr(CallExpr e, int index, string partialPredicateCall) { - exists(int n, int nArgList, int nAttr, int nFunction | - n = 0 and - nArgList = n + 1 and - nAttr = nArgList + e.getNumberOfAttrs() and - nFunction = nAttr + 1 and - ( - none() - or - index = n and result = e.getArgList() and partialPredicateCall = "ArgList()" - or - result = e.getAttr(index - nArgList) and - partialPredicateCall = "Attr(" + (index - nArgList).toString() + ")" - or - index = nAttr and result = e.getFunction() and partialPredicateCall = "Function()" - ) - ) - } - private Element getImmediateChildOfExternBlock( ExternBlock e, int index, string partialPredicateCall ) { @@ -2421,37 +2452,6 @@ private module Impl { ) } - private Element getImmediateChildOfMethodCallExpr( - MethodCallExpr e, int index, string partialPredicateCall - ) { - exists(int n, int nArgList, int nAttr, int nGenericArgList, int nIdentifier, int nReceiver | - n = 0 and - nArgList = n + 1 and - nAttr = nArgList + e.getNumberOfAttrs() and - nGenericArgList = nAttr + 1 and - nIdentifier = nGenericArgList + 1 and - nReceiver = nIdentifier + 1 and - ( - none() - or - index = n and result = e.getArgList() and partialPredicateCall = "ArgList()" - or - result = e.getAttr(index - nArgList) and - partialPredicateCall = "Attr(" + (index - nArgList).toString() + ")" - or - index = nAttr and - result = e.getGenericArgList() and - partialPredicateCall = "GenericArgList()" - or - index = nGenericArgList and - result = e.getIdentifier() and - partialPredicateCall = "Identifier()" - or - index = nIdentifier and result = e.getReceiver() and partialPredicateCall = "Receiver()" - ) - ) - } - private Element getImmediateChildOfModule(Module e, int index, string partialPredicateCall) { exists( int n, int nAttributeMacroExpansion, int nAttr, int nItemList, int nName, int nVisibility @@ -3167,6 +3167,8 @@ private module Impl { or result = getImmediateChildOfBreakExpr(e, index, partialAccessor) or + result = getImmediateChildOfCallExpr(e, index, partialAccessor) + or result = getImmediateChildOfCastExpr(e, index, partialAccessor) or result = getImmediateChildOfClosureExpr(e, index, partialAccessor) @@ -3227,6 +3229,8 @@ private module Impl { or result = getImmediateChildOfMatchExpr(e, index, partialAccessor) or + result = getImmediateChildOfMethodCallExpr(e, index, partialAccessor) + or result = getImmediateChildOfNameRef(e, index, partialAccessor) or result = getImmediateChildOfNeverTypeRepr(e, index, partialAccessor) @@ -3311,8 +3315,6 @@ private module Impl { or result = getImmediateChildOfBlockExpr(e, index, partialAccessor) or - result = getImmediateChildOfCallExpr(e, index, partialAccessor) - or result = getImmediateChildOfExternBlock(e, index, partialAccessor) or result = getImmediateChildOfExternCrate(e, index, partialAccessor) @@ -3325,8 +3327,6 @@ private module Impl { or result = getImmediateChildOfMacroRules(e, index, partialAccessor) or - result = getImmediateChildOfMethodCallExpr(e, index, partialAccessor) - or result = getImmediateChildOfModule(e, index, partialAccessor) or result = getImmediateChildOfPathExpr(e, index, partialAccessor) diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll index aff81e9b9ab..625b5df53c7 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll @@ -2942,23 +2942,58 @@ module Raw { /** * INTERNAL: Do not use. - * A function or method call expression. See `CallExpr` and `MethodCallExpr` for further details. + * NOTE: Consider using `Call` instead, as that includes all kinds of calls to + * functions, and excludes instantiations of tuple structs and tuple enum variants. + * + * A call expression. For example: + * ```rust + * foo(42); + * foo::(42); + * foo[0](42); + * foo(1) = 4; + * Option::Some(42); // tuple enum variant instantiation + * ``` */ - class CallExprBase extends @call_expr_base, Expr { - /** - * Gets the argument list of this call expression base, if it exists. - */ - ArgList getArgList() { call_expr_base_arg_lists(this, result) } + class CallExpr extends @call_expr, Expr { + override string toString() { result = "CallExpr" } /** - * Gets the `index`th attr of this call expression base (0-based). + * Gets the argument list of this call expression, if it exists. */ - Attr getAttr(int index) { call_expr_base_attrs(this, index, result) } + ArgList getArgList() { call_expr_arg_lists(this, result) } /** - * Gets the number of attrs of this call expression base. + * Gets the `index`th attr of this call expression (0-based). */ - int getNumberOfAttrs() { result = count(int i | call_expr_base_attrs(this, i, _)) } + Attr getAttr(int index) { call_expr_attrs(this, index, result) } + + /** + * Gets the number of attrs of this call expression. + */ + int getNumberOfAttrs() { result = count(int i | call_expr_attrs(this, i, _)) } + + /** + * Gets the function of this call expression, if it exists. + */ + Expr getFunction() { call_expr_functions(this, result) } + } + + private Element getImmediateChildOfCallExpr(CallExpr e, int index) { + exists(int n, int nArgList, int nAttr, int nFunction | + n = 0 and + nArgList = n + 1 and + nAttr = nArgList + e.getNumberOfAttrs() and + nFunction = nAttr + 1 and + ( + none() + or + index = n and result = e.getArgList() + or + result = e.getAttr(index - nArgList) + or + index = nAttr and result = e.getFunction() + ) + ) } /** @@ -4345,6 +4380,76 @@ module Raw { ) } + /** + * INTERNAL: Do not use. + * NOTE: Consider using `MethodCall` instead, as that also includes calls to methods using + * function call syntax (such as `Foo::method(x)`), operator calls (such as `x + y`), and + * indexing calls (such as `x[y]`). + * + * A method call expression. For example: + * ```rust + * x.foo(42); + * x.foo::(42); + * ``` + */ + class MethodCallExpr extends @method_call_expr, Expr { + override string toString() { result = "MethodCallExpr" } + + /** + * Gets the argument list of this method call expression, if it exists. + */ + ArgList getArgList() { method_call_expr_arg_lists(this, result) } + + /** + * Gets the `index`th attr of this method call expression (0-based). + */ + Attr getAttr(int index) { method_call_expr_attrs(this, index, result) } + + /** + * Gets the number of attrs of this method call expression. + */ + int getNumberOfAttrs() { result = count(int i | method_call_expr_attrs(this, i, _)) } + + /** + * Gets the generic argument list of this method call expression, if it exists. + */ + GenericArgList getGenericArgList() { method_call_expr_generic_arg_lists(this, result) } + + /** + * Gets the identifier of this method call expression, if it exists. + */ + NameRef getIdentifier() { method_call_expr_identifiers(this, result) } + + /** + * Gets the receiver of this method call expression, if it exists. + */ + Expr getReceiver() { method_call_expr_receivers(this, result) } + } + + private Element getImmediateChildOfMethodCallExpr(MethodCallExpr e, int index) { + exists(int n, int nArgList, int nAttr, int nGenericArgList, int nIdentifier, int nReceiver | + n = 0 and + nArgList = n + 1 and + nAttr = nArgList + e.getNumberOfAttrs() and + nGenericArgList = nAttr + 1 and + nIdentifier = nGenericArgList + 1 and + nReceiver = nIdentifier + 1 and + ( + none() + or + index = n and result = e.getArgList() + or + result = e.getAttr(index - nArgList) + or + index = nAttr and result = e.getGenericArgList() + or + index = nGenericArgList and result = e.getIdentifier() + or + index = nIdentifier and result = e.getReceiver() + ) + ) + } + /** * INTERNAL: Do not use. * A reference to a name. @@ -6033,43 +6138,6 @@ module Raw { ) } - /** - * INTERNAL: Do not use. - * A function call expression. For example: - * ```rust - * foo(42); - * foo::(42); - * foo[0](42); - * foo(1) = 4; - * ``` - */ - class CallExpr extends @call_expr, CallExprBase { - override string toString() { result = "CallExpr" } - - /** - * Gets the function of this call expression, if it exists. - */ - Expr getFunction() { call_expr_functions(this, result) } - } - - private Element getImmediateChildOfCallExpr(CallExpr e, int index) { - exists(int n, int nArgList, int nAttr, int nFunction | - n = 0 and - nArgList = n + 1 and - nAttr = nArgList + e.getNumberOfAttrs() and - nFunction = nAttr + 1 and - ( - none() - or - index = n and result = e.getArgList() - or - result = e.getAttr(index - nArgList) - or - index = nAttr and result = e.getFunction() - ) - ) - } - /** * INTERNAL: Do not use. * An extern block containing foreign function declarations. @@ -6467,57 +6535,6 @@ module Raw { ) } - /** - * INTERNAL: Do not use. - * A method call expression. For example: - * ```rust - * x.foo(42); - * x.foo::(42); - * ``` - */ - class MethodCallExpr extends @method_call_expr, CallExprBase { - override string toString() { result = "MethodCallExpr" } - - /** - * Gets the generic argument list of this method call expression, if it exists. - */ - GenericArgList getGenericArgList() { method_call_expr_generic_arg_lists(this, result) } - - /** - * Gets the identifier of this method call expression, if it exists. - */ - NameRef getIdentifier() { method_call_expr_identifiers(this, result) } - - /** - * Gets the receiver of this method call expression, if it exists. - */ - Expr getReceiver() { method_call_expr_receivers(this, result) } - } - - private Element getImmediateChildOfMethodCallExpr(MethodCallExpr e, int index) { - exists(int n, int nArgList, int nAttr, int nGenericArgList, int nIdentifier, int nReceiver | - n = 0 and - nArgList = n + 1 and - nAttr = nArgList + e.getNumberOfAttrs() and - nGenericArgList = nAttr + 1 and - nIdentifier = nGenericArgList + 1 and - nReceiver = nIdentifier + 1 and - ( - none() - or - index = n and result = e.getArgList() - or - result = e.getAttr(index - nArgList) - or - index = nAttr and result = e.getGenericArgList() - or - index = nGenericArgList and result = e.getIdentifier() - or - index = nIdentifier and result = e.getReceiver() - ) - ) - } - /** * INTERNAL: Do not use. * A module declaration. For example: @@ -7907,6 +7924,8 @@ module Raw { or result = getImmediateChildOfBreakExpr(e, index) or + result = getImmediateChildOfCallExpr(e, index) + or result = getImmediateChildOfCastExpr(e, index) or result = getImmediateChildOfClosureExpr(e, index) @@ -7967,6 +7986,8 @@ module Raw { or result = getImmediateChildOfMatchExpr(e, index) or + result = getImmediateChildOfMethodCallExpr(e, index) + or result = getImmediateChildOfNameRef(e, index) or result = getImmediateChildOfNeverTypeRepr(e, index) @@ -8047,8 +8068,6 @@ module Raw { or result = getImmediateChildOfBlockExpr(e, index) or - result = getImmediateChildOfCallExpr(e, index) - or result = getImmediateChildOfExternBlock(e, index) or result = getImmediateChildOfExternCrate(e, index) @@ -8059,8 +8078,6 @@ module Raw { or result = getImmediateChildOfMacroRules(e, index) or - result = getImmediateChildOfMethodCallExpr(e, index) - or result = getImmediateChildOfModule(e, index) or result = getImmediateChildOfPathExpr(e, index) diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll index 74b4a14460a..b5fc41677b2 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll @@ -729,11 +729,6 @@ module Synth { TTypeBoundList or TTypeRepr or TUseBoundGenericArg or TUseBoundGenericArgs or TUseTree or TUseTreeList or TVariantList or TVisibility or TWhereClause or TWherePred; - /** - * INTERNAL: Do not use. - */ - class TCallExprBase = TCallExpr or TMethodCallExpr; - /** * INTERNAL: Do not use. */ @@ -744,11 +739,11 @@ module Synth { */ class TExpr = TArrayExpr or TArrayExprInternal or TAsmExpr or TAwaitExpr or TBecomeExpr or TBinaryExpr or - TBreakExpr or TCallExprBase or TCastExpr or TClosureExpr or TContinueExpr or TFieldExpr or + TBreakExpr or TCallExpr or TCastExpr or TClosureExpr or TContinueExpr or TFieldExpr or TFormatArgsExpr or TIfExpr or TIndexExpr or TLabelableExpr or TLetExpr or TLiteralExpr or - TMacroBlockExpr or TMacroExpr or TMatchExpr or TOffsetOfExpr or TParenExpr or - TPathExprBase or TPrefixExpr or TRangeExpr or TRefExpr or TReturnExpr or TStructExpr or - TTryExpr or TTupleExpr or TUnderscoreExpr or TYeetExpr or TYieldExpr; + TMacroBlockExpr or TMacroExpr or TMatchExpr or TMethodCallExpr or TOffsetOfExpr or + TParenExpr or TPathExprBase or TPrefixExpr or TRangeExpr or TRefExpr or TReturnExpr or + TStructExpr or TTryExpr or TTupleExpr or TUnderscoreExpr or TYeetExpr or TYieldExpr; /** * INTERNAL: Do not use. @@ -2229,16 +2224,6 @@ module Synth { result = convertWherePredFromRaw(e) } - /** - * INTERNAL: Do not use. - * Converts a raw DB element to a synthesized `TCallExprBase`, if possible. - */ - TCallExprBase convertCallExprBaseFromRaw(Raw::Element e) { - result = convertCallExprFromRaw(e) - or - result = convertMethodCallExprFromRaw(e) - } - /** * INTERNAL: Do not use. * Converts a raw DB element to a synthesized `TCallable`, if possible. @@ -2282,7 +2267,7 @@ module Synth { or result = convertBreakExprFromRaw(e) or - result = convertCallExprBaseFromRaw(e) + result = convertCallExprFromRaw(e) or result = convertCastExprFromRaw(e) or @@ -2310,6 +2295,8 @@ module Synth { or result = convertMatchExprFromRaw(e) or + result = convertMethodCallExprFromRaw(e) + or result = convertOffsetOfExprFromRaw(e) or result = convertParenExprFromRaw(e) @@ -3805,16 +3792,6 @@ module Synth { result = convertWherePredToRaw(e) } - /** - * INTERNAL: Do not use. - * Converts a synthesized `TCallExprBase` to a raw DB element, if possible. - */ - Raw::Element convertCallExprBaseToRaw(TCallExprBase e) { - result = convertCallExprToRaw(e) - or - result = convertMethodCallExprToRaw(e) - } - /** * INTERNAL: Do not use. * Converts a synthesized `TCallable` to a raw DB element, if possible. @@ -3858,7 +3835,7 @@ module Synth { or result = convertBreakExprToRaw(e) or - result = convertCallExprBaseToRaw(e) + result = convertCallExprToRaw(e) or result = convertCastExprToRaw(e) or @@ -3886,6 +3863,8 @@ module Synth { or result = convertMatchExprToRaw(e) or + result = convertMethodCallExprToRaw(e) + or result = convertOffsetOfExprToRaw(e) or result = convertParenExprToRaw(e) diff --git a/rust/ql/lib/rust.dbscheme b/rust/ql/lib/rust.dbscheme index 30a0713e5bf..e54d01f67a4 100644 --- a/rust/ql/lib/rust.dbscheme +++ b/rust/ql/lib/rust.dbscheme @@ -398,7 +398,7 @@ callable_attrs( | @become_expr | @binary_expr | @break_expr -| @call_expr_base +| @call_expr | @cast_expr | @closure_expr | @continue_expr @@ -412,6 +412,7 @@ callable_attrs( | @macro_block_expr | @macro_expr | @match_expr +| @method_call_expr | @offset_of_expr | @paren_expr | @path_expr_base @@ -1480,24 +1481,29 @@ break_expr_lifetimes( int lifetime: @lifetime ref ); -@call_expr_base = - @call_expr -| @method_call_expr -; +call_exprs( + unique int id: @call_expr +); #keyset[id] -call_expr_base_arg_lists( - int id: @call_expr_base ref, +call_expr_arg_lists( + int id: @call_expr ref, int arg_list: @arg_list ref ); #keyset[id, index] -call_expr_base_attrs( - int id: @call_expr_base ref, +call_expr_attrs( + int id: @call_expr ref, int index: int ref, int attr: @attr ref ); +#keyset[id] +call_expr_functions( + int id: @call_expr ref, + int function: @expr ref +); + cast_exprs( unique int id: @cast_expr ); @@ -2100,6 +2106,41 @@ match_expr_match_arm_lists( int match_arm_list: @match_arm_list ref ); +method_call_exprs( + unique int id: @method_call_expr +); + +#keyset[id] +method_call_expr_arg_lists( + int id: @method_call_expr ref, + int arg_list: @arg_list ref +); + +#keyset[id, index] +method_call_expr_attrs( + int id: @method_call_expr ref, + int index: int ref, + int attr: @attr ref +); + +#keyset[id] +method_call_expr_generic_arg_lists( + int id: @method_call_expr ref, + int generic_arg_list: @generic_arg_list ref +); + +#keyset[id] +method_call_expr_identifiers( + int id: @method_call_expr ref, + int identifier: @name_ref ref +); + +#keyset[id] +method_call_expr_receivers( + int id: @method_call_expr ref, + int receiver: @expr ref +); + name_refs( unique int id: @name_ref ); @@ -2776,16 +2817,6 @@ block_expr_stmt_lists( int stmt_list: @stmt_list ref ); -call_exprs( - unique int id: @call_expr -); - -#keyset[id] -call_expr_functions( - int id: @call_expr ref, - int function: @expr ref -); - extern_blocks( unique int id: @extern_block ); @@ -2988,28 +3019,6 @@ macro_rules_visibilities( int visibility: @visibility ref ); -method_call_exprs( - unique int id: @method_call_expr -); - -#keyset[id] -method_call_expr_generic_arg_lists( - int id: @method_call_expr ref, - int generic_arg_list: @generic_arg_list ref -); - -#keyset[id] -method_call_expr_identifiers( - int id: @method_call_expr ref, - int identifier: @name_ref ref -); - -#keyset[id] -method_call_expr_receivers( - int id: @method_call_expr ref, - int receiver: @expr ref -); - modules( unique int id: @module ); diff --git a/rust/ql/test/extractor-tests/generated/.generated_tests.list b/rust/ql/test/extractor-tests/generated/.generated_tests.list index 879695fb758..3344c64786b 100644 --- a/rust/ql/test/extractor-tests/generated/.generated_tests.list +++ b/rust/ql/test/extractor-tests/generated/.generated_tests.list @@ -23,7 +23,7 @@ BinaryExpr/gen_binary_expr.rs 5ea68396dc2e3ff7fcaf5a5201636dd175dd45be36647b6ae0 BlockExpr/gen_block_expr.rs 17b06c726e304e0efcfde8e71afd9c657860312be554366894236125cb08719e 17b06c726e304e0efcfde8e71afd9c657860312be554366894236125cb08719e BoxPat/gen_box_pat.rs 1493e24b732370b577ade38c47db17fa157df19f5390606a67a6040e49b501c0 1493e24b732370b577ade38c47db17fa157df19f5390606a67a6040e49b501c0 BreakExpr/gen_break_expr.rs aacdf9df7fc51d19742b9e813835c0bd0913017e8d62765960e06b27d58b9031 aacdf9df7fc51d19742b9e813835c0bd0913017e8d62765960e06b27d58b9031 -CallExpr/gen_call_expr.rs 013a7c878996aefb25b94b68eebc4f0b1bb74ccd09e91c491980817a383e2401 013a7c878996aefb25b94b68eebc4f0b1bb74ccd09e91c491980817a383e2401 +CallExpr/gen_call_expr.rs 521a37c5909ce06412ad6010996892f6c559f70ec26d14c545705a792530102b 521a37c5909ce06412ad6010996892f6c559f70ec26d14c545705a792530102b CastExpr/gen_cast_expr.rs c3892211fbae4fed7cb1f25ff1679fd79d2878bf0bf2bd4b7982af23d00129f5 c3892211fbae4fed7cb1f25ff1679fd79d2878bf0bf2bd4b7982af23d00129f5 ClosureExpr/gen_closure_expr.rs bd95408103b7f2084e526e6d35cf3319b2e9d7219aff4c80e4e6691180c549b4 bd95408103b7f2084e526e6d35cf3319b2e9d7219aff4c80e4e6691180c549b4 Comment/gen_comment.rs 1e1f9f43161a79c096c2056e8b7f5346385ab7addcdec68c2d53b383dd3debe6 1e1f9f43161a79c096c2056e8b7f5346385ab7addcdec68c2d53b383dd3debe6 @@ -80,7 +80,7 @@ MatchArmList/gen_match_arm_list.rs 6dcb92591c86771d2aeb762e4274d3e61a7d6c1a42da3 MatchExpr/gen_match_expr.rs 081c5d4c78cb71ccd13fb37a93d7f525267c51b179f44b5a22ca3297897002a0 081c5d4c78cb71ccd13fb37a93d7f525267c51b179f44b5a22ca3297897002a0 MatchGuard/gen_match_guard.rs f0e84a1f608c0361983c516a40216cea149620a36e0aed7ff39b0b7d77a9ab8a f0e84a1f608c0361983c516a40216cea149620a36e0aed7ff39b0b7d77a9ab8a Meta/gen_meta.rs 39172a1f7dd02fa3149e7a1fc1dc1f135aa87c84057ee721cd9b373517042b25 39172a1f7dd02fa3149e7a1fc1dc1f135aa87c84057ee721cd9b373517042b25 -MethodCallExpr/gen_method_call_expr.rs f2b4679eb1ec095981fe6bd656b632c22bf6bd0da133309da3f7ef5bd1ab4b5d f2b4679eb1ec095981fe6bd656b632c22bf6bd0da133309da3f7ef5bd1ab4b5d +MethodCallExpr/gen_method_call_expr.rs 9722747274c1d6ddca210624d0334924a6249a9906df2c8a7f416b220001cfe6 9722747274c1d6ddca210624d0334924a6249a9906df2c8a7f416b220001cfe6 Module/gen_module.rs 815605a604fea1d9276684f8d6738a4e833eacad57ceeb27e2095fc450264fc1 815605a604fea1d9276684f8d6738a4e833eacad57ceeb27e2095fc450264fc1 Name/gen_name.rs 8a7fe65ee632a47d12eaa313e7248ac9210e5a381e9522499ca68f94c39e72c0 8a7fe65ee632a47d12eaa313e7248ac9210e5a381e9522499ca68f94c39e72c0 NameRef/gen_name_ref.rs c8c922e77a7d62b8272359ccdabbf7e15411f31ca85f15a3afdd94bec7ec64e7 c8c922e77a7d62b8272359ccdabbf7e15411f31ca85f15a3afdd94bec7ec64e7 diff --git a/rust/ql/test/extractor-tests/generated/CallExpr/CallExpr.ql b/rust/ql/test/extractor-tests/generated/CallExpr/CallExpr.ql index e16ab837325..4d3b26f2f78 100644 --- a/rust/ql/test/extractor-tests/generated/CallExpr/CallExpr.ql +++ b/rust/ql/test/extractor-tests/generated/CallExpr/CallExpr.ql @@ -12,10 +12,6 @@ query predicate getAttr(CallExpr x, int index, Attr getAttr) { toBeTested(x) and not x.isUnknown() and getAttr = x.getAttr(index) } -query predicate getArg(CallExpr x, int index, Expr getArg) { - toBeTested(x) and not x.isUnknown() and getArg = x.getArg(index) -} - query predicate getFunction(CallExpr x, Expr getFunction) { toBeTested(x) and not x.isUnknown() and getFunction = x.getFunction() } diff --git a/rust/ql/test/extractor-tests/generated/CallExpr/gen_call_expr.rs b/rust/ql/test/extractor-tests/generated/CallExpr/gen_call_expr.rs index b2436cc0042..e7841e14f4b 100644 --- a/rust/ql/test/extractor-tests/generated/CallExpr/gen_call_expr.rs +++ b/rust/ql/test/extractor-tests/generated/CallExpr/gen_call_expr.rs @@ -1,9 +1,13 @@ // generated by codegen, do not edit fn test_call_expr() -> () { - // A function call expression. For example: + // NOTE: Consider using `Call` instead, as that includes all kinds of calls to + // functions, and excludes instantiations of tuple structs and tuple enum variants. + // + // A call expression. For example: foo(42); foo::(42); foo[0](42); foo(1) = 4; + Option::Some(42); // tuple enum variant instantiation } diff --git a/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql b/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql index d1b6d5a1304..8ecc14ee820 100644 --- a/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql +++ b/rust/ql/test/extractor-tests/generated/MethodCallExpr/MethodCallExpr.ql @@ -12,10 +12,6 @@ query predicate getAttr(MethodCallExpr x, int index, Attr getAttr) { toBeTested(x) and not x.isUnknown() and getAttr = x.getAttr(index) } -query predicate getArg(MethodCallExpr x, int index, Expr getArg) { - toBeTested(x) and not x.isUnknown() and getArg = x.getArg(index) -} - query predicate getGenericArgList(MethodCallExpr x, GenericArgList getGenericArgList) { toBeTested(x) and not x.isUnknown() and getGenericArgList = x.getGenericArgList() } diff --git a/rust/ql/test/extractor-tests/generated/MethodCallExpr/gen_method_call_expr.rs b/rust/ql/test/extractor-tests/generated/MethodCallExpr/gen_method_call_expr.rs index f8bf728d257..4a04fe9941d 100644 --- a/rust/ql/test/extractor-tests/generated/MethodCallExpr/gen_method_call_expr.rs +++ b/rust/ql/test/extractor-tests/generated/MethodCallExpr/gen_method_call_expr.rs @@ -1,6 +1,10 @@ // generated by codegen, do not edit fn test_method_call_expr() -> () { + // NOTE: Consider using `MethodCall` instead, as that also includes calls to methods using + // function call syntax (such as `Foo::method(x)`), operator calls (such as `x + y`), and + // indexing calls (such as `x[y]`). + // // A method call expression. For example: x.foo(42); x.foo::(42);