From 353f1cafe6749696a100860893a19da569126601 Mon Sep 17 00:00:00 2001 From: Paolo Tranquilli Date: Tue, 3 Dec 2024 15:09:20 +0100 Subject: [PATCH 1/3] Rust: distinguish `[a, b]` from `[a; b]` This splits the `ArrayExpr` class into `ArrayListExpr` and `ArrayRepeatExpr`. This uses the `synth.from_class` machinery to integrate seamlessly into the generated code, by hiding the extracted `ArrayExpr` behind an internal class and replacing it with a hierarchy of those two classes under a new `ArrayExpr` class. --- rust/ast-generator/src/main.rs | 8 ++ rust/extractor/src/generated/.generated.list | 2 +- rust/extractor/src/generated/top.rs | 44 +++++---- rust/extractor/src/translate/generated.rs | 8 +- rust/ql/.generated.list | 35 ++++--- rust/ql/.gitattributes | 17 +++- .../internal/generated/CfgNodes.qll | 99 ++++++++++++++++--- rust/ql/lib/codeql/rust/elements.qll | 2 + .../ql/lib/codeql/rust/elements/ArrayExpr.qll | 3 +- .../codeql/rust/elements/ArrayListExpr.qll | 15 +++ .../codeql/rust/elements/ArrayRepeatExpr.qll | 16 +++ .../internal/ArrayExprConstructor.qll | 14 --- .../rust/elements/internal/ArrayExprImpl.qll | 8 +- .../elements/internal/ArrayExprInternal.qll | 13 +++ .../internal/ArrayExprInternalConstructor.qll | 17 ++++ .../internal/ArrayExprInternalImpl.qll | 16 +++ .../internal/ArrayListExprConstructor.qll | 13 +++ .../elements/internal/ArrayListExprImpl.qll | 34 +++++++ .../internal/ArrayRepeatExprConstructor.qll | 13 +++ .../elements/internal/ArrayRepeatExprImpl.qll | 41 ++++++++ .../elements/internal/generated/ArrayExpr.qll | 28 +----- .../internal/generated/ArrayExprInternal.qll | 72 ++++++++++++++ .../internal/generated/ArrayListExpr.qll | 27 +++++ .../internal/generated/ArrayRepeatExpr.qll | 38 +++++++ .../internal/generated/ParentChild.qll | 64 +++++++++++- .../generated/PureSynthConstructors.qll | 2 + .../rust/elements/internal/generated/Raw.qll | 22 ++--- .../elements/internal/generated/Synth.qll | 79 +++++++++++++-- .../internal/generated/SynthConstructors.qll | 4 +- rust/ql/lib/rust.dbscheme | 19 ++-- .../generated/.generated_tests.list | 3 +- .../extractor-tests/generated/.gitattributes | 3 +- .../generated/ArrayExpr/ArrayExpr.expected | 2 - .../generated/ArrayExpr/ArrayExpr.ql | 11 --- .../ArrayExpr/ArrayExpr_getAttr.expected | 0 .../ArrayExpr/ArrayExpr_getExpr.expected | 5 - .../generated/ArrayExpr/gen_array_expr.rs | 7 -- .../ArrayListExpr/ArrayListExpr.expected | 1 + .../generated/ArrayListExpr/ArrayListExpr.ql | 10 ++ .../ArrayListExpr_getExpr.expected | 3 + .../ArrayListExpr_getExpr.ql} | 2 +- .../ArrayListExpr/gen_array_list_expr.rs | 6 ++ .../ArrayRepeatExpr/ArrayRepeatExpr.expected | 1 + .../ArrayRepeatExpr/ArrayRepeatExpr.ql | 13 +++ .../ArrayRepeatExpr_getExpr.expected | 2 + .../ArrayRepeatExpr_getExpr.ql} | 4 +- .../ArrayRepeatExpr/gen_array_repeat_expr.rs | 6 ++ rust/schema/annotations.py | 33 ++++++- rust/schema/ast.py | 3 +- 49 files changed, 724 insertions(+), 164 deletions(-) create mode 100644 rust/ql/lib/codeql/rust/elements/ArrayListExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/ArrayRepeatExpr.qll delete mode 100644 rust/ql/lib/codeql/rust/elements/internal/ArrayExprConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ArrayExprInternal.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ArrayExprInternalConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ArrayExprInternalImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ArrayListExprConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ArrayListExprImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ArrayRepeatExprConstructor.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/ArrayRepeatExprImpl.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ArrayExprInternal.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ArrayListExpr.qll create mode 100644 rust/ql/lib/codeql/rust/elements/internal/generated/ArrayRepeatExpr.qll delete mode 100644 rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr.ql delete mode 100644 rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr_getAttr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr_getExpr.expected delete mode 100644 rust/ql/test/extractor-tests/generated/ArrayExpr/gen_array_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.expected create mode 100644 rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.ql create mode 100644 rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getExpr.expected rename rust/ql/test/extractor-tests/generated/{ArrayExpr/ArrayExpr_getExpr.ql => ArrayListExpr/ArrayListExpr_getExpr.ql} (83%) create mode 100644 rust/ql/test/extractor-tests/generated/ArrayListExpr/gen_array_list_expr.rs create mode 100644 rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.expected create mode 100644 rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.ql create mode 100644 rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getExpr.expected rename rust/ql/test/extractor-tests/generated/{ArrayExpr/ArrayExpr_getAttr.ql => ArrayRepeatExpr/ArrayRepeatExpr_getExpr.ql} (64%) create mode 100644 rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/gen_array_repeat_expr.rs diff --git a/rust/ast-generator/src/main.rs b/rust/ast-generator/src/main.rs index dbc9686a90f6..ec67da694234 100644 --- a/rust/ast-generator/src/main.rs +++ b/rust/ast-generator/src/main.rs @@ -21,6 +21,7 @@ fn class_name(type_name: &str) -> String { "Fn" => "Function", "Literal" => "LiteralExpr", "Type" => "TypeRef", + "ArrayExpr" => "ArrayExprInternal", _ => type_name, }; name.to_owned() @@ -354,6 +355,13 @@ fn get_fields(node: &AstNodeSrc) -> Vec { is_many: false, }); } + "ArrayExpr" => { + result.push(FieldInfo { + name: "is_semicolon".to_string(), + tp: "predicate".to_string(), + is_many: true, + }); + } _ => {} } diff --git a/rust/extractor/src/generated/.generated.list b/rust/extractor/src/generated/.generated.list index ec1f28154422..c1c9196eacdd 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 272ecf2f56f35211d2449dbf55b1907d8414a8e4cceded03fd12f6f599852c73 272ecf2f56f35211d2449dbf55b1907d8414a8e4cceded03fd12f6f599852c73 +top.rs 761143f6f40632476e4bdddb66814720a4fa4b3b655ebad3ea2bfa35161f5ce8 761143f6f40632476e4bdddb66814720a4fa4b3b655ebad3ea2bfa35161f5ce8 diff --git a/rust/extractor/src/generated/top.rs b/rust/extractor/src/generated/top.rs index 73048514fda3..e5380272fce8 100644 --- a/rust/extractor/src/generated/top.rs +++ b/rust/extractor/src/generated/top.rs @@ -2987,62 +2987,66 @@ impl From> for trap::Label { } #[derive(Debug)] -pub struct ArrayExpr { - pub id: trap::TrapId, +pub struct ArrayExprInternal { + pub id: trap::TrapId, pub attrs: Vec>, pub exprs: Vec>, + pub is_semicolon: bool, } -impl trap::TrapEntry for ArrayExpr { +impl trap::TrapEntry for ArrayExprInternal { 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("array_exprs", vec![id.into()]); + out.add_tuple("array_expr_internals", vec![id.into()]); for (i, v) in self.attrs.into_iter().enumerate() { - out.add_tuple("array_expr_attrs", vec![id.into(), i.into(), v.into()]); + out.add_tuple("array_expr_internal_attrs", vec![id.into(), i.into(), v.into()]); } for (i, v) in self.exprs.into_iter().enumerate() { - out.add_tuple("array_expr_exprs", vec![id.into(), i.into(), v.into()]); + out.add_tuple("array_expr_internal_exprs", vec![id.into(), i.into(), v.into()]); + } + if self.is_semicolon { + out.add_tuple("array_expr_internal_is_semicolon", vec![id.into()]); } } } -impl trap::TrapClass for ArrayExpr { - fn class_name() -> &'static str { "ArrayExpr" } +impl trap::TrapClass for ArrayExprInternal { + fn class_name() -> &'static str { "ArrayExprInternal" } } -impl From> for trap::Label { - fn from(value: trap::Label) -> Self { - // SAFETY: this is safe because in the dbscheme ArrayExpr is a subclass of AstNode +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme ArrayExprInternal 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 ArrayExpr is a subclass of Element +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme ArrayExprInternal is a subclass of Element 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 ArrayExpr is a subclass of Expr +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme ArrayExprInternal 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 ArrayExpr is a subclass of Locatable +impl From> for trap::Label { + fn from(value: trap::Label) -> Self { + // SAFETY: this is safe because in the dbscheme ArrayExprInternal is a subclass of Locatable unsafe { Self::from_untyped(value.as_untyped()) } diff --git a/rust/extractor/src/translate/generated.rs b/rust/extractor/src/translate/generated.rs index 8e4a7986fbf7..e2826bc1ab7b 100644 --- a/rust/extractor/src/translate/generated.rs +++ b/rust/extractor/src/translate/generated.rs @@ -198,16 +198,18 @@ impl Translator<'_> { label } - pub(crate) fn emit_array_expr(&mut self, node: ast::ArrayExpr) -> Label { + pub(crate) fn emit_array_expr(&mut self, node: ast::ArrayExpr) -> Label { let attrs = node.attrs().map(|x| self.emit_attr(x)).collect(); let exprs = node.exprs().map(|x| self.emit_expr(x)).collect(); - let label = self.trap.emit(generated::ArrayExpr { + let is_semicolon = node.semicolon_token().is_some(); + let label = self.trap.emit(generated::ArrayExprInternal { id: TrapId::Star, attrs, exprs, + is_semicolon, }); self.emit_location(label, &node); - emit_detached!(ArrayExpr, self, node, label); + emit_detached!(ArrayExprInternal, self, node, label); self.emit_tokens(&node, label.into(), node.syntax().children_with_tokens()); label } diff --git a/rust/ql/.generated.list b/rust/ql/.generated.list index b0c71e3ef015..c4b09b740fdc 100644 --- a/rust/ql/.generated.list +++ b/rust/ql/.generated.list @@ -1,8 +1,10 @@ -lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll a8e083c7d8c4dea6459c5e128e2123f5cf8fd14c076f2256ebda508c13d553cd 16fcc0d34097b0b37a0041281515ca028d2702eec6d9c1d03c39a1158883bdef +lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll 707922d0b7d9718dbe552c3cba830d9ca66673f366f9e86e70137cd739029822 4a133879d2657597dd61f8e4b72944d8d81fb9115fb21488654804d05726911a lib/codeql/rust/elements/Abi.qll 4c973d28b6d628f5959d1f1cc793704572fd0acaae9a97dfce82ff9d73f73476 250f68350180af080f904cd34cb2af481c5c688dc93edf7365fd0ae99855e893 lib/codeql/rust/elements/Addressable.qll 13011bfd2e1556694c3d440cc34af8527da4df49ad92b62f2939d3699ff2cea5 ddb25935f7553a1a384b1abe2e4b4fa90ab50b952dadec32fd867afcb054f4be lib/codeql/rust/elements/ArgList.qll 661f5100f5d3ef8351452d9058b663a2a5c720eea8cf11bedd628969741486a2 28e424aac01a90fb58cd6f9f83c7e4cf379eea39e636bc0ba07efc818be71c71 -lib/codeql/rust/elements/ArrayExpr.qll a3e6e122632f4011644ec31b37f88b32fe3f2b7e388e7e878a6883309937049f 12ccb5873d95c433da5606fd371d182ef2f71b78d0c53c2d6dec10fa45852bdc +lib/codeql/rust/elements/ArrayExpr.qll 04e5710b083ce29b51e9c9cefd3fa24df5fbf79b0dbaef23b1724d7e708372e5 dd0b89075c985e67aaeb19e1750cc9301f0c1c991232d67a185797dcfe75b223 +lib/codeql/rust/elements/ArrayListExpr.qll 451aedcecb479c385ff497588c7a07fda304fd5b873270223a4f2c804e96b245 a8cb008f6f732215623b5626c84b37b651ca01ccafb2cf4c835df35d5140c6ad +lib/codeql/rust/elements/ArrayRepeatExpr.qll d7be62b0840660beffabb5951b40ae1c1b77d1d6bdab9a75ec7f1d456420a1d3 847fc9105a7e1c99e1fbedf4ea7bcd198f3392819b6c1fab9c893c2c06f8a3cd lib/codeql/rust/elements/ArrayType.qll affd43d308200d60d08e8924cdbb2a17a827ebaa62a296e07bb9ce97451e3c4c 80589a7f79bf2ac293a027faf2589b3027a6c4a286533f2ffccad259a306a8cb lib/codeql/rust/elements/AsmExpr.qll 2f1c78e92b56d66a559543b2103d8f880dd4fa4c6907346f668b3714cf2355e9 12e174fc469c067c957f6c1a5969ab56a71a07c537ca930a564cce81c7ab4481 lib/codeql/rust/elements/AssocItem.qll 5e514287bbe353d1d637991e7af836e5659ad66922df99af68ab61399e7f8f9a 3733af54938271161ee2720c32ac43228d519b5c46b7cea1e4bbe3dc634f8857 @@ -174,7 +176,10 @@ lib/codeql/rust/elements/internal/AbiImpl.qll 01439712ecadc9dc8da6f74d2e19cee13c lib/codeql/rust/elements/internal/AddressableImpl.qll e01a6104980960f5708d5a0ada774ba21db9a344e33deeaf3d3239c627268c77 b8bfc711b267df305ac9fe5f6a994f051ddeca7fc95dacd76d1bae2d4fa7adde lib/codeql/rust/elements/internal/ArgListConstructor.qll a73685c8792ae23a2d628e7357658efb3f6e34006ff6e9661863ef116ec0b015 0bee572a046e8dfc031b1216d729843991519d94ae66280f5e795d20aea07a22 lib/codeql/rust/elements/internal/ArgListImpl.qll 19664651c06b46530f0ae5745ccb3233afc97b9152e053761d641de6e9c62d38 40af167e571f5c255f264b3be7cc7f5ff42ec109661ca03dcee94e92f8facfc6 -lib/codeql/rust/elements/internal/ArrayExprConstructor.qll f4ac4efefe5fe4fe1e666f35b1ee92d2243d977b3f3308151c89f61582203c09 4167ae58ec869f7dbd8467093c4a53afd7c1efcf1cc865efa62b4eb484bd7ff8 +lib/codeql/rust/elements/internal/ArrayExprImpl.qll b43ef2dc4b3ae6c9d89b61abe41a3723309c341fdc881d8c3264c251d669c321 667ea0b7fccda95365562e4755435af634cc043dd46fe965be0676b8883e3d2a +lib/codeql/rust/elements/internal/ArrayExprInternal.qll 07a219b3d3fba3ff8b18e77686b2f58ab01acd99e0f5d5cad5d91af937e228f5 7528fc0e2064c481f0d6cbff3835950a044e429a2cd00c4d8442d2e132560d37 +lib/codeql/rust/elements/internal/ArrayExprInternalConstructor.qll f9756bc40beee99c5e4355bf157030b440c532dff5bdf43e848b3aa1a00fea90 39467f7f313e6f9ede1fe92375ee408098dc65291ca8ee50e36a3684a2767836 +lib/codeql/rust/elements/internal/ArrayExprInternalImpl.qll ae4488846c8309b2d4a51d54b36fce0a75107917c0b1f8af5ccf40797f570580 37838c7d6a04b95a16ed46e963d7e56def7a30b5e5ef1ab7e0dfdb5f256fa874 lib/codeql/rust/elements/internal/ArrayTypeConstructor.qll 9e92e6c40df992b4d71ae0e80392e81499604c7586a671b89d31d2d98060380e 76a1915a88f50ffa60bf129237bae2d66cf26d2a9018aca8ccb343929e847531 lib/codeql/rust/elements/internal/ArrayTypeImpl.qll e22d4f4eb21ba1ea44dd53e0c80aa60ec3a42818c1fc2d512c92dc496a6e2cb3 1b4a7347dbb9310ace1e9e3d08c3ba53c1dc441539cebcb4a78f64a58097bc0a lib/codeql/rust/elements/internal/AsmExprConstructor.qll 36c68023b58beec30af9f05d9d902a4c49faa0206b5528d6aad494a91da07941 4d91b7d30def03e634b92c0d7b99b47c3aadd75f4499f425b80355bc775ea5b6 @@ -414,7 +419,10 @@ lib/codeql/rust/elements/internal/YieldExprImpl.qll af184649a348ddd0be16dee9daae lib/codeql/rust/elements/internal/generated/Abi.qll 87e1ea6b2a8ebf60e1c69176632740e4e27fc56c3f173939b098ba376562b5fa 94b2121e71c4ec94d53a79f972c05a8484ef0d80ed638f53031e7cf4dc5343d5 lib/codeql/rust/elements/internal/generated/Addressable.qll 96a8b45166dd035b8d2c6d36b8b67019f2d4d0b4ccff6d492677c0c87197613e d8f1ce29feafc8ff7179399fc7eac5db031a7e1a8bc6b2cd75cfce1da3132e9b lib/codeql/rust/elements/internal/generated/ArgList.qll 1b75b2d7dcf524eb468a0268af6293e9d17832d6bedf3feec49a535824339b57 2bcaf464454bdfdda45fbd24d063f0f1df0eb69f684197b37105adc8f72cd1ea -lib/codeql/rust/elements/internal/generated/ArrayExpr.qll 2ca97b602a707fe2c566002d8709792bb166ae52fdb7da28d7c4b8e0d66dd4bc 1cae1ef017171ec9a1ca28b4f2993b1ee26d22b51b3b04816d9b4e89fdff1fb3 +lib/codeql/rust/elements/internal/generated/ArrayExpr.qll 64d194a9a9d6467d123b90f910775ffc28b6c04e44990d6a1af6d1dbb2ec5bf5 ccc6183f9e90a6c11c5f79a068003a7d63db227fa69287d3ac12d48e8af63ac7 +lib/codeql/rust/elements/internal/generated/ArrayExprInternal.qll 67a7b0fae04b11cf771727ff39a123fb2d5ce6e2d650d32478fcb33a26ed5688 15833405fa85f6abe0e5146dac283cb5a142a07f08300ccc15a1dae30ed88942 +lib/codeql/rust/elements/internal/generated/ArrayListExpr.qll f325163c2bd401286305330482bee20d060cecd24afa9e49deab7ba7e72ca056 ae3f5b303e31fc6c48b38172304ee8dcf3af2b2ba693767824ea8a944b6be0eb +lib/codeql/rust/elements/internal/generated/ArrayRepeatExpr.qll c8da67cf3bd67e1101b6ebc342f0b4ba2d9366c300f2eadeb017efedfcb3b5de 0e6ba406b156b07a4d3c28eca187ff9f90b2ef6a73899c0dc703d69953d49e6a lib/codeql/rust/elements/internal/generated/ArrayType.qll 225ac477f67865d72b2a2e17420f5e52c25452a3c14f7ff367f873a859f97783 0030e3bf296dd5b69ea912fc85dc7120b060780033083127257cdca792dc3f4b lib/codeql/rust/elements/internal/generated/AsmExpr.qll b5fef59589c02c17857a4a7f5c7b5efb747a1e98710167efa5c2e88cffd7bcbb b43b297a3b4894e8dd92ef3a23b76f2684c303d41e6030398e69b7754ebea9cd lib/codeql/rust/elements/internal/generated/AssocItem.qll aa7c06e001b67e4a59476fa7299e09f8da16c93f91aff0ec9812c64386e7c023 0032b45e34e6aba9c4b3d319b108efa0de8ad679b5f254a1ec7c606877ff5e95 @@ -512,7 +520,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 db7a782f11a14305acc666c865118475e2d324d2bf5d4110b157e1d488b62b75 3b5d31528d0baa0ceee139097e93461d18503797a1507288dc43428f378500e2 +lib/codeql/rust/elements/internal/generated/ParentChild.qll 2a2132e9df63ceeee7e2abbb6b6d9fd62856ae93d113b60ae7d8311d4c9535be b7aaa62c085e71c2dff42e7f2886770c48d964dfe45981c2857af4b9126a8a7b lib/codeql/rust/elements/internal/generated/Pat.qll 3605ac062be2f294ee73336e9669027b8b655f4ad55660e1eab35266275154ee 7f9400db2884d336dd1d21df2a8093759c2a110be9bf6482ce8e80ae0fd74ed4 lib/codeql/rust/elements/internal/generated/Path.qll 4c1c8e840ed57880e574142b081b11d7a7428a009f10e3aa8f4645e211f6b2e0 989668cf0f1bdee7557e2f97c01e41d2a56848227fed41477833f5fc1e1d35f6 lib/codeql/rust/elements/internal/generated/PathExpr.qll 2096e3c1db22ee488a761690adabfc9cfdea501c99f7c5d96c0019cb113fc506 54245ce0449c4e263173213df01e079d5168a758503a5dbd61b25ad35a311140 @@ -522,10 +530,10 @@ lib/codeql/rust/elements/internal/generated/PathSegment.qll 0fa07886deb0fc4d909d lib/codeql/rust/elements/internal/generated/PathType.qll df6fd322ba0d99d6cb315edce8dbf099b661b84fdfcc3ad629fdd1fd066c1986 e11c8615cd7b02034b47b58f30a7b6fcbc6d33ec53303288dfd34d9a25f5a186 lib/codeql/rust/elements/internal/generated/PrefixExpr.qll c9ede5f2deb7b41bc8240969e8554f645057018fe96e7e9ad9c2924c8b14722b 5ae2e3c3dc8fa73e7026ef6534185afa6b0b5051804435d8b741dd3640c864e1 lib/codeql/rust/elements/internal/generated/PtrType.qll 40099c5a4041314b66932dfd777c9e2bef90a0711fb8d7c2c2cec764c003ac4a cf8297d93557356a572223d3e8acca701837c4b1f54e8d4351ba195fb7ed27f8 -lib/codeql/rust/elements/internal/generated/PureSynthConstructors.qll ea294a3ba33fd1bc632046c4fedbcb84dcb961a8e4599969d65893b19d90e590 ea294a3ba33fd1bc632046c4fedbcb84dcb961a8e4599969d65893b19d90e590 +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 efd93730de217cf50dcba5875595263a5eadf9f7e4e1272401342a094d158614 229b251b3d118932e31e78ac4dfb75f48b766f240f20d436062785606d44467b -lib/codeql/rust/elements/internal/generated/Raw.qll 7de290d66bd594f4c5b5a296502792e803e9f1084bb2616d9774196e33b16c87 28150fdd3cff3bb49b407f0c2119602be13e78cbb1f8fd749edd31f5d9772f7a +lib/codeql/rust/elements/internal/generated/Raw.qll bb1c4724c3d702a189b41c2d56fa0ce89b957d99daece3229443625f20f7a427 6ace458b3b15e2dc887d11d9b18aebfd27201730ee763076cfe9ec3434a46c12 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 @@ -551,8 +559,8 @@ 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 65873a7fa44e223edc5e76cc768591a036eb2550960a6b6882476f43a01aefba 3e08e2bdfba53ae26d8f48f2d240b92b44c603f03105518c37a963e0cbe63e3f -lib/codeql/rust/elements/internal/generated/SynthConstructors.qll e929c49ea60810a2bbc19ad38110b8bbaf21db54dae90393b21a3459a54abf6f e929c49ea60810a2bbc19ad38110b8bbaf21db54dae90393b21a3459a54abf6f +lib/codeql/rust/elements/internal/generated/Synth.qll d5358d9ac151c7e5940dbc3c2e3ddbabbb3160d9ea9ba8e8879d7e0b459bf871 1365f2db99d8aae7188197f840efc7c457f63b1ed8b1366974104d8470295069 +lib/codeql/rust/elements/internal/generated/SynthConstructors.qll 410b2360c1469a655e1a8c7586add83477d129fcb53f61d438502bf43dfb4af2 410b2360c1469a655e1a8c7586add83477d129fcb53f61d438502bf43dfb4af2 lib/codeql/rust/elements/internal/generated/Token.qll 77a91a25ca5669703cf3a4353b591cef4d72caa6b0b9db07bb9e005d69c848d1 2fdffc4882ed3a6ca9ac6d1fb5f1ac5a471ca703e2ffdc642885fa558d6e373b lib/codeql/rust/elements/internal/generated/TokenTree.qll 8577c2b097c1be2f0f7daa5acfcf146f78674a424d99563e08a84dd3e6d91b46 d2f30764e84dbfc0a6a5d3d8a5f935cd432413688cb32da9c94e420fbc10665c lib/codeql/rust/elements/internal/generated/Trait.qll 8fa41b50fa0f68333534f2b66bb4ec8e103ff09ac8fa5c2cc64bc04beafec205 ce1c9aa6d0e2f05d28aab8e1165c3b9fb8e24681ade0cf6a9df2e8617abeae7e @@ -586,14 +594,15 @@ lib/codeql/rust/elements/internal/generated/WhileExpr.qll 7edf1f23fbf953a2baabcd 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 ced76fbeebc6e2e972ecaed65ef97851f90a215cf330f28a0f31a253f1c03442 ced76fbeebc6e2e972ecaed65ef97851f90a215cf330f28a0f31a253f1c03442 +lib/codeql/rust/elements.qll c5dabb77abc45a329a4b90c80e421383e558ca33bb6392350a1ce6c7bea84adb c5dabb77abc45a329a4b90c80e421383e558ca33bb6392350a1ce6c7bea84adb 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 test/extractor-tests/generated/ArgList/ArgList_getArg.ql c07c946218489a0ad5fe89e5fd4a7f0ad84a73dc2e650729f48a340cb133be84 ff2382c0693f47e5eb1290aca325290e60c19d877b25b1d7e2ee96009f5fe934 -test/extractor-tests/generated/ArrayExpr/ArrayExpr.ql fd4e504678714c99a987069e5013bda04313573cec2bab31b74bc4559bb73d7f 0b63120b61964a215ec451793a1b5aef525882484ad62193d7635b5a370881d4 -test/extractor-tests/generated/ArrayExpr/ArrayExpr_getAttr.ql ce143c8b416c35270cca839848baf6d8cda74251f3717314e0f332fcb74a9259 c86d282153feee3facad752ed0fc1638be0cbaafca4ec620f337ad61b694cade -test/extractor-tests/generated/ArrayExpr/ArrayExpr_getExpr.ql e8b7e24db6fc6098131fea1053430920b2e2f33d2aa52b10d2ff29b9efd70a88 a52b6b2476104695b395d86bbd1a99068372ca56989ea94b150055e664ba034a +test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.ql 5b6c0d3f9c75e2cfde4fbe6dc443cb992e91925ba108664b04b88f9567322c28 01b891665f2c8a98770e4b4ac284aafc0d680dbaa10ad54a7799eda62048e21a +test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getExpr.ql 6920b532623e8c919701a83a059d9b1aac9e8673e7fdbe26e0a8af5ad6a34b8a 601137c715ce947d79f39d5b131d7ab167a16d29477eacdb1380cd647c4ebac4 +test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.ql cdf73db3b37a9b98a1c63c51bdca9691fcd16f952ce8730385240b7194c55819 8dc29fb0db5df4c4cdd87b406cea92e6e6602908d087af16037a2dec6f9204b8 +test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getExpr.ql 6b00037350fc36cc46345a290bda4c4d4ff99050b970d23eb94294313046a884 0687638b46e43bba9dda35d78ff7b40f976e5e38271eec77e7a21c28349dc42c test/extractor-tests/generated/ArrayType/ArrayType.ql d781ea647d60218777261d82230bd85f989a4768a043e736d268363b5a777390 b5c7fa0aa1b8b1f3a82b8af7254bf20efd3477bba83ad53530959d1733636604 test/extractor-tests/generated/ArrayType/ArrayType_getConstArg.ql b6a250873bc2d553219b8301a15bd19a4044f590085992c532a800bf3ab744cb 5e6b9dbbe2d3ea7f6fa3fba4811517a528d5eb58169b69d1b9113e1508c6e627 test/extractor-tests/generated/ArrayType/ArrayType_getTy.ql 1c23613e509ada3ffc1f727d0db7c5955dbc104d886fe5f9d8f39413b54d16b0 a662d234e1e54159d931a873f20ed8953d9b27778c7a6ca898f86b31d1dae0cc diff --git a/rust/ql/.gitattributes b/rust/ql/.gitattributes index c75ea349c0d1..29bee7221b9b 100644 --- a/rust/ql/.gitattributes +++ b/rust/ql/.gitattributes @@ -5,6 +5,8 @@ /lib/codeql/rust/elements/Addressable.qll linguist-generated /lib/codeql/rust/elements/ArgList.qll linguist-generated /lib/codeql/rust/elements/ArrayExpr.qll linguist-generated +/lib/codeql/rust/elements/ArrayListExpr.qll linguist-generated +/lib/codeql/rust/elements/ArrayRepeatExpr.qll linguist-generated /lib/codeql/rust/elements/ArrayType.qll linguist-generated /lib/codeql/rust/elements/AsmExpr.qll linguist-generated /lib/codeql/rust/elements/AssocItem.qll linguist-generated @@ -176,7 +178,10 @@ /lib/codeql/rust/elements/internal/AddressableImpl.qll linguist-generated /lib/codeql/rust/elements/internal/ArgListConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/ArgListImpl.qll linguist-generated -/lib/codeql/rust/elements/internal/ArrayExprConstructor.qll linguist-generated +/lib/codeql/rust/elements/internal/ArrayExprImpl.qll linguist-generated +/lib/codeql/rust/elements/internal/ArrayExprInternal.qll linguist-generated +/lib/codeql/rust/elements/internal/ArrayExprInternalConstructor.qll linguist-generated +/lib/codeql/rust/elements/internal/ArrayExprInternalImpl.qll linguist-generated /lib/codeql/rust/elements/internal/ArrayTypeConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/ArrayTypeImpl.qll linguist-generated /lib/codeql/rust/elements/internal/AsmExprConstructor.qll linguist-generated @@ -417,6 +422,9 @@ /lib/codeql/rust/elements/internal/generated/Addressable.qll linguist-generated /lib/codeql/rust/elements/internal/generated/ArgList.qll linguist-generated /lib/codeql/rust/elements/internal/generated/ArrayExpr.qll linguist-generated +/lib/codeql/rust/elements/internal/generated/ArrayExprInternal.qll linguist-generated +/lib/codeql/rust/elements/internal/generated/ArrayListExpr.qll linguist-generated +/lib/codeql/rust/elements/internal/generated/ArrayRepeatExpr.qll linguist-generated /lib/codeql/rust/elements/internal/generated/ArrayType.qll linguist-generated /lib/codeql/rust/elements/internal/generated/AsmExpr.qll linguist-generated /lib/codeql/rust/elements/internal/generated/AssocItem.qll linguist-generated @@ -593,9 +601,10 @@ /test/extractor-tests/generated/Abi/Abi_getAbiString.ql linguist-generated /test/extractor-tests/generated/ArgList/ArgList.ql linguist-generated /test/extractor-tests/generated/ArgList/ArgList_getArg.ql linguist-generated -/test/extractor-tests/generated/ArrayExpr/ArrayExpr.ql linguist-generated -/test/extractor-tests/generated/ArrayExpr/ArrayExpr_getAttr.ql linguist-generated -/test/extractor-tests/generated/ArrayExpr/ArrayExpr_getExpr.ql linguist-generated +/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.ql linguist-generated +/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getExpr.ql linguist-generated +/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.ql linguist-generated +/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getExpr.ql linguist-generated /test/extractor-tests/generated/ArrayType/ArrayType.ql linguist-generated /test/extractor-tests/generated/ArrayType/ArrayType_getConstArg.ql linguist-generated /test/extractor-tests/generated/ArrayType/ArrayType_getTy.ql 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 1c3afbc83b0b..f84547933c02 100644 --- a/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll +++ b/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll @@ -81,7 +81,7 @@ module MakeCfgNodes Input> { } /** - * An array expression. For example: + * The base class for array expressions. For example: * ```rust * [1, 2, 3]; * [1; 10]; @@ -95,21 +95,6 @@ module MakeCfgNodes Input> { /** Gets the underlying `ArrayExpr`. */ ArrayExpr getArrayExpr() { result = node } - /** - * Gets the `index`th attr of this array expression (0-based). - */ - Attr getAttr(int index) { result = node.getAttr(index) } - - /** - * Gets any of the attrs of this array expression. - */ - Attr getAnAttr() { result = this.getAttr(_) } - - /** - * Gets the number of attrs of this array expression. - */ - int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } - /** * Gets the `index`th expression of this array expression (0-based). */ @@ -128,6 +113,64 @@ module MakeCfgNodes Input> { int getNumberOfExprs() { result = count(int i | exists(this.getExpr(i))) } } + final private class ParentArrayListExpr extends ParentAstNode, ArrayListExpr { + override predicate relevantChild(AstNode child) { none() } + } + + /** + * An array expression with a list of elements. For example: + * ```rust + * [1, 2, 3]; + * ``` + */ + final class ArrayListExprCfgNode extends CfgNodeFinal, ArrayExprCfgNode { + private ArrayListExpr node; + + ArrayListExprCfgNode() { node = this.getAstNode() } + + /** Gets the underlying `ArrayListExpr`. */ + ArrayListExpr getArrayListExpr() { result = node } + } + + final private class ParentArrayRepeatExpr extends ParentAstNode, ArrayRepeatExpr { + override predicate relevantChild(AstNode child) { + none() + or + child = this.getRepeatOperand() + or + child = this.getRepeatLength() + } + } + + /** + * An array expression with a repeat oeprand and a repeat length. For example: + * ```rust + * [1; 10]; + * ``` + */ + final class ArrayRepeatExprCfgNode extends CfgNodeFinal, ArrayExprCfgNode { + private ArrayRepeatExpr node; + + ArrayRepeatExprCfgNode() { node = this.getAstNode() } + + /** Gets the underlying `ArrayRepeatExpr`. */ + ArrayRepeatExpr getArrayRepeatExpr() { result = node } + + /** + * Gets the repeat operand of this array repeat expression. + */ + ExprCfgNode getRepeatOperand() { + any(ChildMapping mapping).hasCfgChild(node, node.getRepeatOperand(), this, result) + } + + /** + * Gets the repeat length of this array repeat expression. + */ + ExprCfgNode getRepeatLength() { + any(ChildMapping mapping).hasCfgChild(node, node.getRepeatLength(), this, result) + } + } + final private class ParentAsmExpr extends ParentAstNode, AsmExpr { override predicate relevantChild(AstNode child) { none() @@ -3127,6 +3170,30 @@ module MakeCfgNodes Input> { cfgNode ) or + pred = "getRepeatOperand" and + parent = + any(Nodes::ArrayRepeatExprCfgNode cfgNode, ArrayRepeatExpr astNode | + astNode = cfgNode.getArrayRepeatExpr() and + child = getDesugared(astNode.getRepeatOperand()) and + i = -1 and + hasCfgNode(child) and + not child = cfgNode.getRepeatOperand().getAstNode() + | + cfgNode + ) + or + pred = "getRepeatLength" and + parent = + any(Nodes::ArrayRepeatExprCfgNode cfgNode, ArrayRepeatExpr astNode | + astNode = cfgNode.getArrayRepeatExpr() and + child = getDesugared(astNode.getRepeatLength()) and + i = -1 and + hasCfgNode(child) and + not child = cfgNode.getRepeatLength().getAstNode() + | + cfgNode + ) + or pred = "getExpr" and parent = any(Nodes::AsmExprCfgNode cfgNode, AsmExpr astNode | diff --git a/rust/ql/lib/codeql/rust/elements.qll b/rust/ql/lib/codeql/rust/elements.qll index e37dde90d618..44d6291e20ad 100644 --- a/rust/ql/lib/codeql/rust/elements.qll +++ b/rust/ql/lib/codeql/rust/elements.qll @@ -7,6 +7,8 @@ import codeql.rust.elements.Abi import codeql.rust.elements.Addressable import codeql.rust.elements.ArgList import codeql.rust.elements.ArrayExpr +import codeql.rust.elements.ArrayListExpr +import codeql.rust.elements.ArrayRepeatExpr import codeql.rust.elements.ArrayType import codeql.rust.elements.AsmExpr import codeql.rust.elements.AssocItem diff --git a/rust/ql/lib/codeql/rust/elements/ArrayExpr.qll b/rust/ql/lib/codeql/rust/elements/ArrayExpr.qll index 9b039cc15344..f24e2dc1b109 100644 --- a/rust/ql/lib/codeql/rust/elements/ArrayExpr.qll +++ b/rust/ql/lib/codeql/rust/elements/ArrayExpr.qll @@ -4,11 +4,10 @@ */ private import internal.ArrayExprImpl -import codeql.rust.elements.Attr import codeql.rust.elements.Expr /** - * An array expression. For example: + * The base class for array expressions. For example: * ```rust * [1, 2, 3]; * [1; 10]; diff --git a/rust/ql/lib/codeql/rust/elements/ArrayListExpr.qll b/rust/ql/lib/codeql/rust/elements/ArrayListExpr.qll new file mode 100644 index 000000000000..0bca9602d8a5 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ArrayListExpr.qll @@ -0,0 +1,15 @@ +// generated by codegen, do not edit +/** + * This module provides the public class `ArrayListExpr`. + */ + +private import internal.ArrayListExprImpl +import codeql.rust.elements.ArrayExpr + +/** + * An array expression with a list of elements. For example: + * ```rust + * [1, 2, 3]; + * ``` + */ +final class ArrayListExpr = Impl::ArrayListExpr; diff --git a/rust/ql/lib/codeql/rust/elements/ArrayRepeatExpr.qll b/rust/ql/lib/codeql/rust/elements/ArrayRepeatExpr.qll new file mode 100644 index 000000000000..4253f75f0319 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/ArrayRepeatExpr.qll @@ -0,0 +1,16 @@ +// generated by codegen, do not edit +/** + * This module provides the public class `ArrayRepeatExpr`. + */ + +private import internal.ArrayRepeatExprImpl +import codeql.rust.elements.ArrayExpr +import codeql.rust.elements.Expr + +/** + * An array expression with a repeat oeprand and a repeat length. For example: + * ```rust + * [1; 10]; + * ``` + */ +final class ArrayRepeatExpr = Impl::ArrayRepeatExpr; diff --git a/rust/ql/lib/codeql/rust/elements/internal/ArrayExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/internal/ArrayExprConstructor.qll deleted file mode 100644 index bd4a8362cc54..000000000000 --- a/rust/ql/lib/codeql/rust/elements/internal/ArrayExprConstructor.qll +++ /dev/null @@ -1,14 +0,0 @@ -// generated by codegen, remove this comment if you wish to edit this file -/** - * This module defines the hook used internally to tweak the characteristic predicate of - * `ArrayExpr` synthesized instances. - * INTERNAL: Do not use. - */ - -private import codeql.rust.elements.internal.generated.Raw - -/** - * The characteristic predicate of `ArrayExpr` synthesized instances. - * INTERNAL: Do not use. - */ -predicate constructArrayExpr(Raw::ArrayExpr id) { any() } diff --git a/rust/ql/lib/codeql/rust/elements/internal/ArrayExprImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/ArrayExprImpl.qll index 8bda9a2d46e2..2958347e369b 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/ArrayExprImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/ArrayExprImpl.qll @@ -1,3 +1,4 @@ +// generated by codegen, remove this comment if you wish to edit this file /** * This module provides a hand-modifiable wrapper around the generated class `ArrayExpr`. * @@ -11,15 +12,12 @@ private import codeql.rust.elements.internal.generated.ArrayExpr * be referenced directly. */ module Impl { - // the following QLdoc is generated: if you need to edit it, do it in the schema file /** - * An array expression. For example: + * The base class for array expressions. For example: * ```rust * [1, 2, 3]; * [1; 10]; * ``` */ - class ArrayExpr extends Generated::ArrayExpr { - override string toString() { result = "[...]" } - } + class ArrayExpr extends Generated::ArrayExpr { } } diff --git a/rust/ql/lib/codeql/rust/elements/internal/ArrayExprInternal.qll b/rust/ql/lib/codeql/rust/elements/internal/ArrayExprInternal.qll new file mode 100644 index 000000000000..d904ecd23e8c --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/ArrayExprInternal.qll @@ -0,0 +1,13 @@ +// generated by codegen, do not edit +/** + * This module provides the class `ArrayExprInternal`. + */ + +private import ArrayExprInternalImpl +import codeql.rust.elements.Attr +import codeql.rust.elements.Expr + +/** + * INTERNAL: Do not use. + */ +final class ArrayExprInternal = Impl::ArrayExprInternal; diff --git a/rust/ql/lib/codeql/rust/elements/internal/ArrayExprInternalConstructor.qll b/rust/ql/lib/codeql/rust/elements/internal/ArrayExprInternalConstructor.qll new file mode 100644 index 000000000000..a4b29741d26b --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/ArrayExprInternalConstructor.qll @@ -0,0 +1,17 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `ArrayExprInternal` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.elements.internal.generated.Raw +private import codeql.rust.elements.internal.generated.PureSynthConstructors + +/** + * The characteristic predicate of `ArrayExprInternal` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructArrayExprInternal(Raw::ArrayExprInternal id) { + not constructArrayListExpr(id) and not constructArrayRepeatExpr(id) +} diff --git a/rust/ql/lib/codeql/rust/elements/internal/ArrayExprInternalImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/ArrayExprInternalImpl.qll new file mode 100644 index 000000000000..df972e84525d --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/ArrayExprInternalImpl.qll @@ -0,0 +1,16 @@ +// generated by codegen, remove this comment if you wish to edit this file +/** + * This module provides a hand-modifiable wrapper around the generated class `ArrayExprInternal`. + * + * INTERNAL: Do not use. + */ + +private import codeql.rust.elements.internal.generated.ArrayExprInternal + +/** + * INTERNAL: This module contains the customizable definition of `ArrayExprInternal` and should not + * be referenced directly. + */ +module Impl { + class ArrayExprInternal extends Generated::ArrayExprInternal { } +} diff --git a/rust/ql/lib/codeql/rust/elements/internal/ArrayListExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/internal/ArrayListExprConstructor.qll new file mode 100644 index 000000000000..97ad88afa2a7 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/ArrayListExprConstructor.qll @@ -0,0 +1,13 @@ +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `ArrayListExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.elements.internal.generated.Raw + +/** + * The characteristic predicate of `ArrayListExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructArrayListExpr(Raw::ArrayExprInternal id) { not id.isSemicolon() } diff --git a/rust/ql/lib/codeql/rust/elements/internal/ArrayListExprImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/ArrayListExprImpl.qll new file mode 100644 index 000000000000..7815b82d18b5 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/ArrayListExprImpl.qll @@ -0,0 +1,34 @@ +/** + * This module provides a hand-modifiable wrapper around the generated class `ArrayListExpr`. + * + * INTERNAL: Do not use. + */ + +private import codeql.rust.elements.internal.generated.ArrayListExpr +private import codeql.rust.elements.internal.generated.Raw +private import codeql.rust.elements.internal.generated.Synth +private import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the customizable definition of `ArrayListExpr` and should not + * be referenced directly. + */ +module Impl { + // the following QLdoc is generated: if you need to edit it, do it in the schema file + /** + * An array expression with a list of elements. For example: + * ```rust + * [1, 2, 3]; + * ``` + */ + class ArrayListExpr extends Generated::ArrayListExpr { + cached + private Raw::ArrayExprInternal getUnderlyingEntity() { this = Synth::TArrayListExpr(result) } + + override string toString() { result = "[...]" } + + override Expr getExpr(int index) { + result = Synth::convertExprFromRaw(this.getUnderlyingEntity().getExpr(index)) + } + } +} diff --git a/rust/ql/lib/codeql/rust/elements/internal/ArrayRepeatExprConstructor.qll b/rust/ql/lib/codeql/rust/elements/internal/ArrayRepeatExprConstructor.qll new file mode 100644 index 000000000000..3f6e661d4168 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/ArrayRepeatExprConstructor.qll @@ -0,0 +1,13 @@ +/** + * This module defines the hook used internally to tweak the characteristic predicate of + * `ArrayRepeatExpr` synthesized instances. + * INTERNAL: Do not use. + */ + +private import codeql.rust.elements.internal.generated.Raw + +/** + * The characteristic predicate of `ArrayRepeatExpr` synthesized instances. + * INTERNAL: Do not use. + */ +predicate constructArrayRepeatExpr(Raw::ArrayExprInternal id) { id.isSemicolon() } diff --git a/rust/ql/lib/codeql/rust/elements/internal/ArrayRepeatExprImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/ArrayRepeatExprImpl.qll new file mode 100644 index 000000000000..2f1f75a48a80 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/ArrayRepeatExprImpl.qll @@ -0,0 +1,41 @@ +/** + * This module provides a hand-modifiable wrapper around the generated class `ArrayRepeatExpr`. + * + * INTERNAL: Do not use. + */ + +private import codeql.rust.elements.internal.generated.ArrayRepeatExpr +private import codeql.rust.elements.internal.generated.Raw +private import codeql.rust.elements.internal.generated.Synth + +/** + * INTERNAL: This module contains the customizable definition of `ArrayRepeatExpr` and should not + * be referenced directly. + */ +module Impl { + // the following QLdoc is generated: if you need to edit it, do it in the schema file + /** + * An array expression with a repeat oeprand and a repeat length. For example: + * ```rust + * [1; 10]; + * ``` + */ + class ArrayRepeatExpr extends Generated::ArrayRepeatExpr { + cached + private Raw::ArrayExprInternal getUnderlyingEntity() { this = Synth::TArrayRepeatExpr(result) } + + override string toString() { + result = + "[" + this.getRepeatOperand().toAbbreviatedString() + "; " + + this.getRepeatLength().toAbbreviatedString() + "]" + } + + override Expr getRepeatOperand() { result = this.getExpr(0) } + + override Expr getRepeatLength() { result = this.getExpr(1) } + + override Expr getExpr(int index) { + result = Synth::convertExprFromRaw(this.getUnderlyingEntity().getExpr(index)) + } + } +} diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayExpr.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayExpr.qll index 95ffb4911296..b3362b557dcb 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayExpr.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayExpr.qll @@ -6,7 +6,6 @@ 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.Expr import codeql.rust.elements.internal.ExprImpl::Impl as ExprImpl @@ -16,7 +15,7 @@ import codeql.rust.elements.internal.ExprImpl::Impl as ExprImpl */ module Generated { /** - * An array expression. For example: + * The base class for array expressions. For example: * ```rust * [1, 2, 3]; * [1; 10]; @@ -25,33 +24,10 @@ module Generated { * Use the subclass `ArrayExpr`, where the following predicates are available. */ class ArrayExpr extends Synth::TArrayExpr, ExprImpl::Expr { - override string getAPrimaryQlClass() { result = "ArrayExpr" } - - /** - * Gets the `index`th attr of this array expression (0-based). - */ - Attr getAttr(int index) { - result = - Synth::convertAttrFromRaw(Synth::convertArrayExprToRaw(this).(Raw::ArrayExpr).getAttr(index)) - } - - /** - * Gets any of the attrs of this array expression. - */ - final Attr getAnAttr() { result = this.getAttr(_) } - - /** - * Gets the number of attrs of this array expression. - */ - final int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } - /** * Gets the `index`th expression of this array expression (0-based). */ - Expr getExpr(int index) { - result = - Synth::convertExprFromRaw(Synth::convertArrayExprToRaw(this).(Raw::ArrayExpr).getExpr(index)) - } + Expr getExpr(int index) { none() } /** * Gets any of the expressions of this array expression. diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayExprInternal.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayExprInternal.qll new file mode 100644 index 000000000000..15c86caa17b1 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayExprInternal.qll @@ -0,0 +1,72 @@ +// generated by codegen, do not edit +/** + * This module provides the generated definition of `ArrayExprInternal`. + * 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.Attr +import codeql.rust.elements.Expr +import codeql.rust.elements.internal.ExprImpl::Impl as ExprImpl + +/** + * INTERNAL: This module contains the fully generated definition of `ArrayExprInternal` and should not + * be referenced directly. + */ +module Generated { + /** + * INTERNAL: Do not reference the `Generated::ArrayExprInternal` class directly. + * Use the subclass `ArrayExprInternal`, where the following predicates are available. + */ + class ArrayExprInternal extends Synth::TArrayExprInternal, ExprImpl::Expr { + override string getAPrimaryQlClass() { result = "ArrayExprInternal" } + + /** + * Gets the `index`th attr of this array expression internal (0-based). + */ + Attr getAttr(int index) { + result = + Synth::convertAttrFromRaw(Synth::convertArrayExprInternalToRaw(this) + .(Raw::ArrayExprInternal) + .getAttr(index)) + } + + /** + * Gets any of the attrs of this array expression internal. + */ + final Attr getAnAttr() { result = this.getAttr(_) } + + /** + * Gets the number of attrs of this array expression internal. + */ + final int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } + + /** + * Gets the `index`th expression of this array expression internal (0-based). + */ + Expr getExpr(int index) { + result = + Synth::convertExprFromRaw(Synth::convertArrayExprInternalToRaw(this) + .(Raw::ArrayExprInternal) + .getExpr(index)) + } + + /** + * Gets any of the expressions of this array expression internal. + */ + final Expr getAnExpr() { result = this.getExpr(_) } + + /** + * Gets the number of expressions of this array expression internal. + */ + final int getNumberOfExprs() { result = count(int i | exists(this.getExpr(i))) } + + /** + * Holds if this array expression internal is semicolon. + */ + predicate isSemicolon() { + Synth::convertArrayExprInternalToRaw(this).(Raw::ArrayExprInternal).isSemicolon() + } + } +} diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayListExpr.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayListExpr.qll new file mode 100644 index 000000000000..657be83802da --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayListExpr.qll @@ -0,0 +1,27 @@ +// generated by codegen, do not edit +/** + * This module provides the generated definition of `ArrayListExpr`. + * 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.ArrayExprImpl::Impl as ArrayExprImpl + +/** + * INTERNAL: This module contains the fully generated definition of `ArrayListExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * An array expression with a list of elements. For example: + * ```rust + * [1, 2, 3]; + * ``` + * INTERNAL: Do not reference the `Generated::ArrayListExpr` class directly. + * Use the subclass `ArrayListExpr`, where the following predicates are available. + */ + class ArrayListExpr extends Synth::TArrayListExpr, ArrayExprImpl::ArrayExpr { + override string getAPrimaryQlClass() { result = "ArrayListExpr" } + } +} diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayRepeatExpr.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayRepeatExpr.qll new file mode 100644 index 000000000000..8451ad5c34f7 --- /dev/null +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayRepeatExpr.qll @@ -0,0 +1,38 @@ +// generated by codegen, do not edit +/** + * This module provides the generated definition of `ArrayRepeatExpr`. + * 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.ArrayExprImpl::Impl as ArrayExprImpl +import codeql.rust.elements.Expr + +/** + * INTERNAL: This module contains the fully generated definition of `ArrayRepeatExpr` and should not + * be referenced directly. + */ +module Generated { + /** + * An array expression with a repeat oeprand and a repeat length. For example: + * ```rust + * [1; 10]; + * ``` + * INTERNAL: Do not reference the `Generated::ArrayRepeatExpr` class directly. + * Use the subclass `ArrayRepeatExpr`, where the following predicates are available. + */ + class ArrayRepeatExpr extends Synth::TArrayRepeatExpr, ArrayExprImpl::ArrayExpr { + override string getAPrimaryQlClass() { result = "ArrayRepeatExpr" } + + /** + * Gets the repeat operand of this array repeat expression. + */ + Expr getRepeatOperand() { none() } + + /** + * Gets the repeat length of this array repeat expression. + */ + Expr getRepeatLength() { none() } + } +} 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 6709629e8b4f..eeca98f1bf51 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll @@ -4,6 +4,7 @@ */ import codeql.rust.elements +import codeql.rust.elements.internal.ArrayExprInternal private module Impl { private Element getImmediateChildOfElement(Element e, int index, string partialPredicateCall) { @@ -1189,6 +1190,25 @@ private module Impl { } private Element getImmediateChildOfArrayExpr(ArrayExpr e, int index, string partialPredicateCall) { + exists(int b, int bExpr, int n, int nExpr | + b = 0 and + bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and + n = bExpr and + nExpr = n + 1 + max(int i | i = -1 or exists(e.getExpr(i)) | i) and + ( + none() + or + result = getImmediateChildOfExpr(e, index - b, partialPredicateCall) + or + result = e.getExpr(index - n) and + partialPredicateCall = "Expr(" + (index - n).toString() + ")" + ) + ) + } + + private Element getImmediateChildOfArrayExprInternal( + ArrayExprInternal e, int index, string partialPredicateCall + ) { exists(int b, int bExpr, int n, int nAttr, int nExpr | b = 0 and bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and @@ -2785,6 +2805,44 @@ private module Impl { ) } + private Element getImmediateChildOfArrayListExpr( + ArrayListExpr e, int index, string partialPredicateCall + ) { + exists(int b, int bArrayExpr, int n | + b = 0 and + bArrayExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArrayExpr(e, i, _)) | i) and + n = bArrayExpr and + ( + none() + or + result = getImmediateChildOfArrayExpr(e, index - b, partialPredicateCall) + ) + ) + } + + private Element getImmediateChildOfArrayRepeatExpr( + ArrayRepeatExpr e, int index, string partialPredicateCall + ) { + exists(int b, int bArrayExpr, int n, int nRepeatOperand, int nRepeatLength | + b = 0 and + bArrayExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfArrayExpr(e, i, _)) | i) and + n = bArrayExpr and + nRepeatOperand = n + 1 and + nRepeatLength = nRepeatOperand + 1 and + ( + none() + or + result = getImmediateChildOfArrayExpr(e, index - b, partialPredicateCall) + or + index = n and result = e.getRepeatOperand() and partialPredicateCall = "RepeatOperand()" + or + index = nRepeatOperand and + result = e.getRepeatLength() and + partialPredicateCall = "RepeatLength()" + ) + ) + } + private Element getImmediateChildOfBlockExpr(BlockExpr e, int index, string partialPredicateCall) { exists(int b, int bLabelableExpr, int n, int nAttr, int nStmtList | b = 0 and @@ -3694,7 +3752,7 @@ private module Impl { or result = getImmediateChildOfWherePred(e, index, partialAccessor) or - result = getImmediateChildOfArrayExpr(e, index, partialAccessor) + result = getImmediateChildOfArrayExprInternal(e, index, partialAccessor) or result = getImmediateChildOfArrayType(e, index, partialAccessor) or @@ -3844,6 +3902,10 @@ private module Impl { or result = getImmediateChildOfYieldExpr(e, index, partialAccessor) or + result = getImmediateChildOfArrayListExpr(e, index, partialAccessor) + or + result = getImmediateChildOfArrayRepeatExpr(e, index, partialAccessor) + or result = getImmediateChildOfBlockExpr(e, index, partialAccessor) or result = getImmediateChildOfCallExpr(e, index, partialAccessor) diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/PureSynthConstructors.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/PureSynthConstructors.qll index 382ab59ed8ce..699d14d9bf5f 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/PureSynthConstructors.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/PureSynthConstructors.qll @@ -3,6 +3,8 @@ * This module exports all modules providing `Element` subclasses. */ +import codeql.rust.elements.internal.ArrayListExprConstructor +import codeql.rust.elements.internal.ArrayRepeatExprConstructor import codeql.rust.elements.internal.FormatConstructor import codeql.rust.elements.internal.FormatArgumentConstructor import codeql.rust.elements.internal.FormatTemplateVariableAccessConstructor 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 1c85daa22cfa..078fb6429991 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Raw.qll @@ -1104,24 +1104,24 @@ module Raw { /** * INTERNAL: Do not use. - * An array expression. For example: - * ```rust - * [1, 2, 3]; - * [1; 10]; - * ``` */ - class ArrayExpr extends @array_expr, Expr { - override string toString() { result = "ArrayExpr" } + class ArrayExprInternal extends @array_expr_internal, Expr { + override string toString() { result = "ArrayExprInternal" } + + /** + * Gets the `index`th attr of this array expression internal (0-based). + */ + Attr getAttr(int index) { array_expr_internal_attrs(this, index, result) } /** - * Gets the `index`th attr of this array expression (0-based). + * Gets the `index`th expression of this array expression internal (0-based). */ - Attr getAttr(int index) { array_expr_attrs(this, index, result) } + Expr getExpr(int index) { array_expr_internal_exprs(this, index, result) } /** - * Gets the `index`th expression of this array expression (0-based). + * Holds if this array expression internal is semicolon. */ - Expr getExpr(int index) { array_expr_exprs(this, index, result) } + predicate isSemicolon() { array_expr_internal_is_semicolon(this) } } /** 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 0b4fa39cd848..3a68b9de28e3 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/Synth.qll @@ -25,7 +25,15 @@ module Synth { /** * INTERNAL: Do not use. */ - TArrayExpr(Raw::ArrayExpr id) { constructArrayExpr(id) } or + TArrayExprInternal(Raw::ArrayExprInternal id) { constructArrayExprInternal(id) } or + /** + * INTERNAL: Do not use. + */ + TArrayListExpr(Raw::ArrayExprInternal id) { constructArrayListExpr(id) } or + /** + * INTERNAL: Do not use. + */ + TArrayRepeatExpr(Raw::ArrayExprInternal id) { constructArrayRepeatExpr(id) } or /** * INTERNAL: Do not use. */ @@ -616,6 +624,11 @@ module Synth { */ class TAddressable = TItem or TVariant; + /** + * INTERNAL: Do not use. + */ + class TArrayExpr = TArrayListExpr or TArrayRepeatExpr; + /** * INTERNAL: Do not use. */ @@ -650,8 +663,8 @@ module Synth { * INTERNAL: Do not use. */ class TExpr = - TArrayExpr or TAsmExpr or TAwaitExpr or TBecomeExpr or TBinaryExpr or TBreakExpr or - TCallExprBase or TCastExpr or TClosureExpr or TContinueExpr or TFieldExpr or + TArrayExpr or TArrayExprInternal or TAsmExpr or TAwaitExpr or TBecomeExpr or TBinaryExpr or + TBreakExpr or TCallExprBase or TCastExpr or TClosureExpr or TContinueExpr or TFieldExpr or TFormatArgsExpr or TIfExpr or TIndexExpr or TLabelableExpr or TLetExpr or TLiteralExpr or TMacroExpr or TMatchExpr or TOffsetOfExpr or TParenExpr or TPathExprBase or TPrefixExpr or TRangeExpr or TRecordExpr or TRefExpr or TReturnExpr or TTryExpr or TTupleExpr or @@ -760,9 +773,23 @@ module Synth { /** * INTERNAL: Do not use. - * Converts a raw element to a synthesized `TArrayExpr`, if possible. + * Converts a raw element to a synthesized `TArrayExprInternal`, if possible. + */ + TArrayExprInternal convertArrayExprInternalFromRaw(Raw::Element e) { + result = TArrayExprInternal(e) + } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TArrayListExpr`, if possible. */ - TArrayExpr convertArrayExprFromRaw(Raw::Element e) { result = TArrayExpr(e) } + TArrayListExpr convertArrayListExprFromRaw(Raw::Element e) { result = TArrayListExpr(e) } + + /** + * INTERNAL: Do not use. + * Converts a raw element to a synthesized `TArrayRepeatExpr`, if possible. + */ + TArrayRepeatExpr convertArrayRepeatExprFromRaw(Raw::Element e) { result = TArrayRepeatExpr(e) } /** * INTERNAL: Do not use. @@ -1644,6 +1671,16 @@ module Synth { result = convertVariantFromRaw(e) } + /** + * INTERNAL: Do not use. + * Converts a raw DB element to a synthesized `TArrayExpr`, if possible. + */ + TArrayExpr convertArrayExprFromRaw(Raw::Element e) { + result = convertArrayListExprFromRaw(e) + or + result = convertArrayRepeatExprFromRaw(e) + } + /** * INTERNAL: Do not use. * Converts a raw DB element to a synthesized `TAssocItem`, if possible. @@ -1815,6 +1852,8 @@ module Synth { TExpr convertExprFromRaw(Raw::Element e) { result = convertArrayExprFromRaw(e) or + result = convertArrayExprInternalFromRaw(e) + or result = convertAsmExprFromRaw(e) or result = convertAwaitExprFromRaw(e) @@ -2146,9 +2185,23 @@ module Synth { /** * INTERNAL: Do not use. - * Converts a synthesized `TArrayExpr` to a raw DB element, if possible. + * Converts a synthesized `TArrayExprInternal` to a raw DB element, if possible. + */ + Raw::Element convertArrayExprInternalToRaw(TArrayExprInternal e) { + e = TArrayExprInternal(result) + } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TArrayListExpr` to a raw DB element, if possible. + */ + Raw::Element convertArrayListExprToRaw(TArrayListExpr e) { e = TArrayListExpr(result) } + + /** + * INTERNAL: Do not use. + * Converts a synthesized `TArrayRepeatExpr` to a raw DB element, if possible. */ - Raw::Element convertArrayExprToRaw(TArrayExpr e) { e = TArrayExpr(result) } + Raw::Element convertArrayRepeatExprToRaw(TArrayRepeatExpr e) { e = TArrayRepeatExpr(result) } /** * INTERNAL: Do not use. @@ -3028,6 +3081,16 @@ module Synth { result = convertVariantToRaw(e) } + /** + * INTERNAL: Do not use. + * Converts a synthesized `TArrayExpr` to a raw DB element, if possible. + */ + Raw::Element convertArrayExprToRaw(TArrayExpr e) { + result = convertArrayListExprToRaw(e) + or + result = convertArrayRepeatExprToRaw(e) + } + /** * INTERNAL: Do not use. * Converts a synthesized `TAssocItem` to a raw DB element, if possible. @@ -3199,6 +3262,8 @@ module Synth { Raw::Element convertExprToRaw(TExpr e) { result = convertArrayExprToRaw(e) or + result = convertArrayExprInternalToRaw(e) + or result = convertAsmExprToRaw(e) or result = convertAwaitExprToRaw(e) diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/SynthConstructors.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/SynthConstructors.qll index 9b68c858c6a5..ad2946105e88 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/SynthConstructors.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/SynthConstructors.qll @@ -5,7 +5,9 @@ import codeql.rust.elements.internal.AbiConstructor import codeql.rust.elements.internal.ArgListConstructor -import codeql.rust.elements.internal.ArrayExprConstructor +import codeql.rust.elements.internal.ArrayExprInternalConstructor +import codeql.rust.elements.internal.ArrayListExprConstructor +import codeql.rust.elements.internal.ArrayRepeatExprConstructor import codeql.rust.elements.internal.ArrayTypeConstructor import codeql.rust.elements.internal.AsmExprConstructor import codeql.rust.elements.internal.AssocItemListConstructor diff --git a/rust/ql/lib/rust.dbscheme b/rust/ql/lib/rust.dbscheme index fe0f5bc436c9..56aead11ede0 100644 --- a/rust/ql/lib/rust.dbscheme +++ b/rust/ql/lib/rust.dbscheme @@ -303,7 +303,7 @@ closure_binder_generic_param_lists( ); @expr = - @array_expr + @array_expr_internal | @asm_expr | @await_expr | @become_expr @@ -1087,24 +1087,29 @@ where_pred_type_bound_lists( int type_bound_list: @type_bound_list ref ); -array_exprs( - unique int id: @array_expr +array_expr_internals( + unique int id: @array_expr_internal ); #keyset[id, index] -array_expr_attrs( - int id: @array_expr ref, +array_expr_internal_attrs( + int id: @array_expr_internal ref, int index: int ref, int attr: @attr ref ); #keyset[id, index] -array_expr_exprs( - int id: @array_expr ref, +array_expr_internal_exprs( + int id: @array_expr_internal ref, int index: int ref, int expr: @expr ref ); +#keyset[id] +array_expr_internal_is_semicolon( + int id: @array_expr_internal ref +); + array_types( unique int id: @array_type ); diff --git a/rust/ql/test/extractor-tests/generated/.generated_tests.list b/rust/ql/test/extractor-tests/generated/.generated_tests.list index 1fe8e805b268..a966b68bf50c 100644 --- a/rust/ql/test/extractor-tests/generated/.generated_tests.list +++ b/rust/ql/test/extractor-tests/generated/.generated_tests.list @@ -1,6 +1,7 @@ Abi/gen_abi.rs 5d2f6eccb2bab86080188be9700ab64a34fa6e8e8e7b08f65a5c97d1de0a900c 5d2f6eccb2bab86080188be9700ab64a34fa6e8e8e7b08f65a5c97d1de0a900c ArgList/gen_arg_list.rs 569d0b9b0479de5453ae0f89e4f90e32b02ee84dfb3d815821d722ece6f75b64 569d0b9b0479de5453ae0f89e4f90e32b02ee84dfb3d815821d722ece6f75b64 -ArrayExpr/gen_array_expr.rs e4863b428ea2b5cfd59773f201e58fd905f7363512e54e4fdebd02c297bd85ff e4863b428ea2b5cfd59773f201e58fd905f7363512e54e4fdebd02c297bd85ff +ArrayListExpr/gen_array_list_expr.rs 99a1233b77a6b6eb0a538025688ca5a0824118a123bef0fe3f92a81834b17924 99a1233b77a6b6eb0a538025688ca5a0824118a123bef0fe3f92a81834b17924 +ArrayRepeatExpr/gen_array_repeat_expr.rs 2d3ed378b055681b71efda5c50989d2465c8b4210bd1ad52a05d68c55aaa61e2 2d3ed378b055681b71efda5c50989d2465c8b4210bd1ad52a05d68c55aaa61e2 ArrayType/gen_array_type.rs 3cb5f35006648d676ead1088aa330cd34beaabaaad7b9aa952e6375bc1cec5cb 3cb5f35006648d676ead1088aa330cd34beaabaaad7b9aa952e6375bc1cec5cb AsmExpr/gen_asm_expr.rs 00b21fd66fe12785174bd0160d0317a6c78ff05dbba73313eb07b56531cf3158 00b21fd66fe12785174bd0160d0317a6c78ff05dbba73313eb07b56531cf3158 AssocTypeArg/gen_assoc_type_arg.rs 00ec0e22c4d73338de605dc3b1b1306bc83a95f87376ce976f08d2f9923cc2b4 00ec0e22c4d73338de605dc3b1b1306bc83a95f87376ce976f08d2f9923cc2b4 diff --git a/rust/ql/test/extractor-tests/generated/.gitattributes b/rust/ql/test/extractor-tests/generated/.gitattributes index 782715565d2f..96f501b978d8 100644 --- a/rust/ql/test/extractor-tests/generated/.gitattributes +++ b/rust/ql/test/extractor-tests/generated/.gitattributes @@ -2,7 +2,8 @@ /.gitattributes linguist-generated /Abi/gen_abi.rs linguist-generated /ArgList/gen_arg_list.rs linguist-generated -/ArrayExpr/gen_array_expr.rs linguist-generated +/ArrayListExpr/gen_array_list_expr.rs linguist-generated +/ArrayRepeatExpr/gen_array_repeat_expr.rs linguist-generated /ArrayType/gen_array_type.rs linguist-generated /AsmExpr/gen_asm_expr.rs linguist-generated /AssocTypeArg/gen_assoc_type_arg.rs linguist-generated diff --git a/rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr.expected b/rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr.expected deleted file mode 100644 index e1ab176fe514..000000000000 --- a/rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr.expected +++ /dev/null @@ -1,2 +0,0 @@ -| gen_array_expr.rs:5:5:5:13 | [...] | getNumberOfAttrs: | 0 | getNumberOfExprs: | 3 | -| gen_array_expr.rs:6:5:6:11 | [...] | getNumberOfAttrs: | 0 | getNumberOfExprs: | 2 | diff --git a/rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr.ql b/rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr.ql deleted file mode 100644 index e0f2223f57bc..000000000000 --- a/rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr.ql +++ /dev/null @@ -1,11 +0,0 @@ -// generated by codegen, do not edit -import codeql.rust.elements -import TestUtils - -from ArrayExpr x, int getNumberOfAttrs, int getNumberOfExprs -where - toBeTested(x) and - not x.isUnknown() and - getNumberOfAttrs = x.getNumberOfAttrs() and - getNumberOfExprs = x.getNumberOfExprs() -select x, "getNumberOfAttrs:", getNumberOfAttrs, "getNumberOfExprs:", getNumberOfExprs diff --git a/rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr_getAttr.expected b/rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr_getAttr.expected deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr_getExpr.expected b/rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr_getExpr.expected deleted file mode 100644 index 393fb28f2bfa..000000000000 --- a/rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr_getExpr.expected +++ /dev/null @@ -1,5 +0,0 @@ -| gen_array_expr.rs:5:5:5:13 | [...] | 0 | gen_array_expr.rs:5:6:5:6 | 1 | -| gen_array_expr.rs:5:5:5:13 | [...] | 1 | gen_array_expr.rs:5:9:5:9 | 2 | -| gen_array_expr.rs:5:5:5:13 | [...] | 2 | gen_array_expr.rs:5:12:5:12 | 3 | -| gen_array_expr.rs:6:5:6:11 | [...] | 0 | gen_array_expr.rs:6:6:6:6 | 1 | -| gen_array_expr.rs:6:5:6:11 | [...] | 1 | gen_array_expr.rs:6:9:6:10 | 10 | diff --git a/rust/ql/test/extractor-tests/generated/ArrayExpr/gen_array_expr.rs b/rust/ql/test/extractor-tests/generated/ArrayExpr/gen_array_expr.rs deleted file mode 100644 index 48252cde12f9..000000000000 --- a/rust/ql/test/extractor-tests/generated/ArrayExpr/gen_array_expr.rs +++ /dev/null @@ -1,7 +0,0 @@ -// generated by codegen, do not edit - -fn test_array_expr() -> () { - // An array expression. For example: - [1, 2, 3]; - [1; 10]; -} diff --git a/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.expected b/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.expected new file mode 100644 index 000000000000..5fa9032183aa --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.expected @@ -0,0 +1 @@ +| gen_array_list_expr.rs:5:5:5:13 | [...] | getNumberOfExprs: | 3 | diff --git a/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.ql b/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.ql new file mode 100644 index 000000000000..ab884cf297b2 --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.ql @@ -0,0 +1,10 @@ +// generated by codegen, do not edit +import codeql.rust.elements +import TestUtils + +from ArrayListExpr x, int getNumberOfExprs +where + toBeTested(x) and + not x.isUnknown() and + getNumberOfExprs = x.getNumberOfExprs() +select x, "getNumberOfExprs:", getNumberOfExprs diff --git a/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getExpr.expected b/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getExpr.expected new file mode 100644 index 000000000000..ac836b145bd7 --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getExpr.expected @@ -0,0 +1,3 @@ +| gen_array_list_expr.rs:5:5:5:13 | [...] | 0 | gen_array_list_expr.rs:5:6:5:6 | 1 | +| gen_array_list_expr.rs:5:5:5:13 | [...] | 1 | gen_array_list_expr.rs:5:9:5:9 | 2 | +| gen_array_list_expr.rs:5:5:5:13 | [...] | 2 | gen_array_list_expr.rs:5:12:5:12 | 3 | diff --git a/rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr_getExpr.ql b/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getExpr.ql similarity index 83% rename from rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr_getExpr.ql rename to rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getExpr.ql index f75aef4b1e1e..96d635c3c175 100644 --- a/rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr_getExpr.ql +++ b/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getExpr.ql @@ -2,6 +2,6 @@ import codeql.rust.elements import TestUtils -from ArrayExpr x, int index +from ArrayListExpr x, int index where toBeTested(x) and not x.isUnknown() select x, index, x.getExpr(index) diff --git a/rust/ql/test/extractor-tests/generated/ArrayListExpr/gen_array_list_expr.rs b/rust/ql/test/extractor-tests/generated/ArrayListExpr/gen_array_list_expr.rs new file mode 100644 index 000000000000..41e569a67ae3 --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/ArrayListExpr/gen_array_list_expr.rs @@ -0,0 +1,6 @@ +// generated by codegen, do not edit + +fn test_array_list_expr() -> () { + // An array expression with a list of elements. For example: + [1, 2, 3]; +} diff --git a/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.expected b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.expected new file mode 100644 index 000000000000..15ea26f6b599 --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.expected @@ -0,0 +1 @@ +| gen_array_repeat_expr.rs:5:5:5:11 | [1; 10] | getNumberOfExprs: | 2 | getRepeatOperand: | gen_array_repeat_expr.rs:5:6:5:6 | 1 | getRepeatLength: | gen_array_repeat_expr.rs:5:9:5:10 | 10 | diff --git a/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.ql b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.ql new file mode 100644 index 000000000000..aa7d306beb34 --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.ql @@ -0,0 +1,13 @@ +// generated by codegen, do not edit +import codeql.rust.elements +import TestUtils + +from ArrayRepeatExpr x, int getNumberOfExprs, Expr getRepeatOperand, Expr getRepeatLength +where + toBeTested(x) and + not x.isUnknown() and + getNumberOfExprs = x.getNumberOfExprs() and + getRepeatOperand = x.getRepeatOperand() and + getRepeatLength = x.getRepeatLength() +select x, "getNumberOfExprs:", getNumberOfExprs, "getRepeatOperand:", getRepeatOperand, + "getRepeatLength:", getRepeatLength diff --git a/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getExpr.expected b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getExpr.expected new file mode 100644 index 000000000000..ccf6290172e6 --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getExpr.expected @@ -0,0 +1,2 @@ +| gen_array_repeat_expr.rs:5:5:5:11 | [1; 10] | 0 | gen_array_repeat_expr.rs:5:6:5:6 | 1 | +| gen_array_repeat_expr.rs:5:5:5:11 | [1; 10] | 1 | gen_array_repeat_expr.rs:5:9:5:10 | 10 | diff --git a/rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr_getAttr.ql b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getExpr.ql similarity index 64% rename from rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr_getAttr.ql rename to rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getExpr.ql index 89113fe91f0b..63352ff7776e 100644 --- a/rust/ql/test/extractor-tests/generated/ArrayExpr/ArrayExpr_getAttr.ql +++ b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getExpr.ql @@ -2,6 +2,6 @@ import codeql.rust.elements import TestUtils -from ArrayExpr x, int index +from ArrayRepeatExpr x, int index where toBeTested(x) and not x.isUnknown() -select x, index, x.getAttr(index) +select x, index, x.getExpr(index) diff --git a/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/gen_array_repeat_expr.rs b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/gen_array_repeat_expr.rs new file mode 100644 index 000000000000..f30f1916d4a8 --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/gen_array_repeat_expr.rs @@ -0,0 +1,6 @@ +// generated by codegen, do not edit + +fn test_array_repeat_expr() -> () { + // An array expression with a repeat oeprand and a repeat length. For example: + [1; 10]; +} diff --git a/rust/schema/annotations.py b/rust/schema/annotations.py index b0d7296dbad5..dd241d5b7505 100644 --- a/rust/schema/annotations.py +++ b/rust/schema/annotations.py @@ -550,15 +550,44 @@ class _: """ -@annotate(ArrayExpr, cfg = True) +@annotate(ArrayExprInternal) +@ql.internal +@qltest.skip class _: + pass + +class ArrayExpr(Expr): """ - An array expression. For example: + The base class for array expressions. For example: ```rust [1, 2, 3]; [1; 10]; ``` """ + exprs: list[Expr] | child + +@synth.from_class(ArrayExprInternal) +class ArrayListExpr(ArrayExpr): + """ + An array expression with a list of elements. For example: + ```rust + [1, 2, 3]; + ``` + """ + __cfg__ = True + +@synth.from_class(ArrayExprInternal) +class ArrayRepeatExpr(ArrayExpr): + """ + An array expression with a repeat oeprand and a repeat length. For example: + ```rust + [1; 10]; + ``` + """ + __cfg__ = True + + repeat_operand: Expr | child + repeat_length: Expr | child @annotate(LiteralExpr, cfg = True) diff --git a/rust/schema/ast.py b/rust/schema/ast.py index 1f5a35d7bc21..bd5cd0b8f928 100644 --- a/rust/schema/ast.py +++ b/rust/schema/ast.py @@ -38,9 +38,10 @@ class Abi(AstNode): class ArgList(AstNode): args: list["Expr"] | child -class ArrayExpr(Expr): +class ArrayExprInternal(Expr): attrs: list["Attr"] | child exprs: list["Expr"] | child + is_semicolon: predicate class ArrayType(TypeRef): const_arg: optional["ConstArg"] | child From c113503b41c1941bb94747c119d7749a5deae8b2 Mon Sep 17 00:00:00 2001 From: Paolo Tranquilli Date: Tue, 3 Dec 2024 15:14:50 +0100 Subject: [PATCH 2/3] Rust: fix doc typo --- .pre-commit-config.yaml | 2 +- rust/ql/.generated.list | 6 +++--- .../codeql/rust/controlflow/internal/generated/CfgNodes.qll | 2 +- rust/ql/lib/codeql/rust/elements/ArrayRepeatExpr.qll | 2 +- .../codeql/rust/elements/internal/ArrayRepeatExprImpl.qll | 2 +- .../rust/elements/internal/generated/ArrayRepeatExpr.qll | 2 +- .../ql/test/extractor-tests/generated/.generated_tests.list | 2 +- .../generated/ArrayRepeatExpr/gen_array_repeat_expr.rs | 2 +- rust/schema/annotations.py | 2 +- 9 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2b677468025b..c0bd4abd0d02 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -72,7 +72,7 @@ repos: - id: rust-codegen name: Run Rust checked in code generation - files: ^misc/codegen/|^rust/(schema.py$|codegen/|.*/generated/|ql/lib/(rust\.dbscheme$|codeql/rust/elements)|\.generated.list) + files: ^misc/codegen/|^rust/(prefix\.dbscheme|schema/|codegen/|.*/generated/|ql/lib/(rust\.dbscheme$|codeql/rust/elements)|\.generated.list) language: system entry: bazel run //rust/codegen -- --quiet pass_filenames: false diff --git a/rust/ql/.generated.list b/rust/ql/.generated.list index c4b09b740fdc..93bfbb28bef8 100644 --- a/rust/ql/.generated.list +++ b/rust/ql/.generated.list @@ -1,10 +1,10 @@ -lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll 707922d0b7d9718dbe552c3cba830d9ca66673f366f9e86e70137cd739029822 4a133879d2657597dd61f8e4b72944d8d81fb9115fb21488654804d05726911a +lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll 2dfc45d5b2b93b3aa226924da7f9321c2d7a20e60ac7a6a48215118f73fdb181 f1ec54884508eb1f72dcda6677f8e11b79043e906b1c7f3e408e1606e290e347 lib/codeql/rust/elements/Abi.qll 4c973d28b6d628f5959d1f1cc793704572fd0acaae9a97dfce82ff9d73f73476 250f68350180af080f904cd34cb2af481c5c688dc93edf7365fd0ae99855e893 lib/codeql/rust/elements/Addressable.qll 13011bfd2e1556694c3d440cc34af8527da4df49ad92b62f2939d3699ff2cea5 ddb25935f7553a1a384b1abe2e4b4fa90ab50b952dadec32fd867afcb054f4be lib/codeql/rust/elements/ArgList.qll 661f5100f5d3ef8351452d9058b663a2a5c720eea8cf11bedd628969741486a2 28e424aac01a90fb58cd6f9f83c7e4cf379eea39e636bc0ba07efc818be71c71 lib/codeql/rust/elements/ArrayExpr.qll 04e5710b083ce29b51e9c9cefd3fa24df5fbf79b0dbaef23b1724d7e708372e5 dd0b89075c985e67aaeb19e1750cc9301f0c1c991232d67a185797dcfe75b223 lib/codeql/rust/elements/ArrayListExpr.qll 451aedcecb479c385ff497588c7a07fda304fd5b873270223a4f2c804e96b245 a8cb008f6f732215623b5626c84b37b651ca01ccafb2cf4c835df35d5140c6ad -lib/codeql/rust/elements/ArrayRepeatExpr.qll d7be62b0840660beffabb5951b40ae1c1b77d1d6bdab9a75ec7f1d456420a1d3 847fc9105a7e1c99e1fbedf4ea7bcd198f3392819b6c1fab9c893c2c06f8a3cd +lib/codeql/rust/elements/ArrayRepeatExpr.qll 4b7ed5be7d2caaf69f6fc0cd05b0e2416c52d547b1a73fb23d5a13007f75f4dd f6366f21cc48376b5fdf37e8c5c2b19415d4cbdeef09f33bb99cde5cb0f5b0e7 lib/codeql/rust/elements/ArrayType.qll affd43d308200d60d08e8924cdbb2a17a827ebaa62a296e07bb9ce97451e3c4c 80589a7f79bf2ac293a027faf2589b3027a6c4a286533f2ffccad259a306a8cb lib/codeql/rust/elements/AsmExpr.qll 2f1c78e92b56d66a559543b2103d8f880dd4fa4c6907346f668b3714cf2355e9 12e174fc469c067c957f6c1a5969ab56a71a07c537ca930a564cce81c7ab4481 lib/codeql/rust/elements/AssocItem.qll 5e514287bbe353d1d637991e7af836e5659ad66922df99af68ab61399e7f8f9a 3733af54938271161ee2720c32ac43228d519b5c46b7cea1e4bbe3dc634f8857 @@ -422,7 +422,7 @@ lib/codeql/rust/elements/internal/generated/ArgList.qll 1b75b2d7dcf524eb468a0268 lib/codeql/rust/elements/internal/generated/ArrayExpr.qll 64d194a9a9d6467d123b90f910775ffc28b6c04e44990d6a1af6d1dbb2ec5bf5 ccc6183f9e90a6c11c5f79a068003a7d63db227fa69287d3ac12d48e8af63ac7 lib/codeql/rust/elements/internal/generated/ArrayExprInternal.qll 67a7b0fae04b11cf771727ff39a123fb2d5ce6e2d650d32478fcb33a26ed5688 15833405fa85f6abe0e5146dac283cb5a142a07f08300ccc15a1dae30ed88942 lib/codeql/rust/elements/internal/generated/ArrayListExpr.qll f325163c2bd401286305330482bee20d060cecd24afa9e49deab7ba7e72ca056 ae3f5b303e31fc6c48b38172304ee8dcf3af2b2ba693767824ea8a944b6be0eb -lib/codeql/rust/elements/internal/generated/ArrayRepeatExpr.qll c8da67cf3bd67e1101b6ebc342f0b4ba2d9366c300f2eadeb017efedfcb3b5de 0e6ba406b156b07a4d3c28eca187ff9f90b2ef6a73899c0dc703d69953d49e6a +lib/codeql/rust/elements/internal/generated/ArrayRepeatExpr.qll ac2035488d5b9328f01ce2dd5bd7598e3af1cbb383ddb48b648e1e8908ea82fc 3ec910b184115fb3750692287e8039560e20bd6a5fb26ac1f9c346424d8eaa48 lib/codeql/rust/elements/internal/generated/ArrayType.qll 225ac477f67865d72b2a2e17420f5e52c25452a3c14f7ff367f873a859f97783 0030e3bf296dd5b69ea912fc85dc7120b060780033083127257cdca792dc3f4b lib/codeql/rust/elements/internal/generated/AsmExpr.qll b5fef59589c02c17857a4a7f5c7b5efb747a1e98710167efa5c2e88cffd7bcbb b43b297a3b4894e8dd92ef3a23b76f2684c303d41e6030398e69b7754ebea9cd lib/codeql/rust/elements/internal/generated/AssocItem.qll aa7c06e001b67e4a59476fa7299e09f8da16c93f91aff0ec9812c64386e7c023 0032b45e34e6aba9c4b3d319b108efa0de8ad679b5f254a1ec7c606877ff5e95 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 f84547933c02..97d44793667c 100644 --- a/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll +++ b/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll @@ -143,7 +143,7 @@ module MakeCfgNodes Input> { } /** - * An array expression with a repeat oeprand and a repeat length. For example: + * An array expression with a repeat operand and a repeat length. For example: * ```rust * [1; 10]; * ``` diff --git a/rust/ql/lib/codeql/rust/elements/ArrayRepeatExpr.qll b/rust/ql/lib/codeql/rust/elements/ArrayRepeatExpr.qll index 4253f75f0319..7e6be8cc2632 100644 --- a/rust/ql/lib/codeql/rust/elements/ArrayRepeatExpr.qll +++ b/rust/ql/lib/codeql/rust/elements/ArrayRepeatExpr.qll @@ -8,7 +8,7 @@ import codeql.rust.elements.ArrayExpr import codeql.rust.elements.Expr /** - * An array expression with a repeat oeprand and a repeat length. For example: + * An array expression with a repeat operand and a repeat length. For example: * ```rust * [1; 10]; * ``` diff --git a/rust/ql/lib/codeql/rust/elements/internal/ArrayRepeatExprImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/ArrayRepeatExprImpl.qll index 2f1f75a48a80..dbf8bcf46fa3 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/ArrayRepeatExprImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/ArrayRepeatExprImpl.qll @@ -15,7 +15,7 @@ private import codeql.rust.elements.internal.generated.Synth module Impl { // the following QLdoc is generated: if you need to edit it, do it in the schema file /** - * An array expression with a repeat oeprand and a repeat length. For example: + * An array expression with a repeat operand and a repeat length. For example: * ```rust * [1; 10]; * ``` diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayRepeatExpr.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayRepeatExpr.qll index 8451ad5c34f7..df7b21452a1c 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayRepeatExpr.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayRepeatExpr.qll @@ -15,7 +15,7 @@ import codeql.rust.elements.Expr */ module Generated { /** - * An array expression with a repeat oeprand and a repeat length. For example: + * An array expression with a repeat operand and a repeat length. For example: * ```rust * [1; 10]; * ``` diff --git a/rust/ql/test/extractor-tests/generated/.generated_tests.list b/rust/ql/test/extractor-tests/generated/.generated_tests.list index a966b68bf50c..b2f6bcd4cb16 100644 --- a/rust/ql/test/extractor-tests/generated/.generated_tests.list +++ b/rust/ql/test/extractor-tests/generated/.generated_tests.list @@ -1,7 +1,7 @@ Abi/gen_abi.rs 5d2f6eccb2bab86080188be9700ab64a34fa6e8e8e7b08f65a5c97d1de0a900c 5d2f6eccb2bab86080188be9700ab64a34fa6e8e8e7b08f65a5c97d1de0a900c ArgList/gen_arg_list.rs 569d0b9b0479de5453ae0f89e4f90e32b02ee84dfb3d815821d722ece6f75b64 569d0b9b0479de5453ae0f89e4f90e32b02ee84dfb3d815821d722ece6f75b64 ArrayListExpr/gen_array_list_expr.rs 99a1233b77a6b6eb0a538025688ca5a0824118a123bef0fe3f92a81834b17924 99a1233b77a6b6eb0a538025688ca5a0824118a123bef0fe3f92a81834b17924 -ArrayRepeatExpr/gen_array_repeat_expr.rs 2d3ed378b055681b71efda5c50989d2465c8b4210bd1ad52a05d68c55aaa61e2 2d3ed378b055681b71efda5c50989d2465c8b4210bd1ad52a05d68c55aaa61e2 +ArrayRepeatExpr/gen_array_repeat_expr.rs 8cc7c0a435a02864290db6a498a5fcf227d8ee7ed87ee1943ad4d326c8314a0e 8cc7c0a435a02864290db6a498a5fcf227d8ee7ed87ee1943ad4d326c8314a0e ArrayType/gen_array_type.rs 3cb5f35006648d676ead1088aa330cd34beaabaaad7b9aa952e6375bc1cec5cb 3cb5f35006648d676ead1088aa330cd34beaabaaad7b9aa952e6375bc1cec5cb AsmExpr/gen_asm_expr.rs 00b21fd66fe12785174bd0160d0317a6c78ff05dbba73313eb07b56531cf3158 00b21fd66fe12785174bd0160d0317a6c78ff05dbba73313eb07b56531cf3158 AssocTypeArg/gen_assoc_type_arg.rs 00ec0e22c4d73338de605dc3b1b1306bc83a95f87376ce976f08d2f9923cc2b4 00ec0e22c4d73338de605dc3b1b1306bc83a95f87376ce976f08d2f9923cc2b4 diff --git a/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/gen_array_repeat_expr.rs b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/gen_array_repeat_expr.rs index f30f1916d4a8..9c68fb96f86e 100644 --- a/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/gen_array_repeat_expr.rs +++ b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/gen_array_repeat_expr.rs @@ -1,6 +1,6 @@ // generated by codegen, do not edit fn test_array_repeat_expr() -> () { - // An array expression with a repeat oeprand and a repeat length. For example: + // An array expression with a repeat operand and a repeat length. For example: [1; 10]; } diff --git a/rust/schema/annotations.py b/rust/schema/annotations.py index dd241d5b7505..2978cb13c66f 100644 --- a/rust/schema/annotations.py +++ b/rust/schema/annotations.py @@ -579,7 +579,7 @@ class ArrayListExpr(ArrayExpr): @synth.from_class(ArrayExprInternal) class ArrayRepeatExpr(ArrayExpr): """ - An array expression with a repeat oeprand and a repeat length. For example: + An array expression with a repeat operand and a repeat length. For example: ```rust [1; 10]; ``` From 277c9f408713f0c3ada3312d398300f8f33bbca0 Mon Sep 17 00:00:00 2001 From: Paolo Tranquilli Date: Tue, 3 Dec 2024 16:12:56 +0100 Subject: [PATCH 3/3] Rust: add back `getAttr` to `ArrayExpr` --- rust/ast-generator/src/main.rs | 2 +- rust/ql/.generated.list | 15 ++++++++------- rust/ql/.gitattributes | 3 ++- .../internal/generated/CfgNodes.qll | 15 +++++++++++++++ .../ql/lib/codeql/rust/elements/ArrayExpr.qll | 1 + .../rust/elements/internal/ArrayExprImpl.qll | 19 +++++++++++++++++-- .../elements/internal/ArrayListExprImpl.qll | 7 ------- .../elements/internal/ArrayRepeatExprImpl.qll | 7 ------- .../elements/internal/generated/ArrayExpr.qll | 16 ++++++++++++++++ .../internal/generated/ParentChild.qll | 6 +++++- .../ArrayListExpr/ArrayListExpr.expected | 2 +- .../generated/ArrayListExpr/ArrayListExpr.ql | 7 ++++--- .../ArrayListExpr_getAttr.expected | 0 .../ArrayListExpr/ArrayListExpr_getAttr.ql | 7 +++++++ .../ArrayRepeatExpr/ArrayRepeatExpr.expected | 2 +- .../ArrayRepeatExpr/ArrayRepeatExpr.ql | 9 ++++++--- .../ArrayRepeatExpr_getAttr.expected | 0 .../ArrayRepeatExpr_getAttr.ql | 7 +++++++ rust/schema/annotations.py | 1 + 19 files changed, 92 insertions(+), 34 deletions(-) create mode 100644 rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getAttr.expected create mode 100644 rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getAttr.ql create mode 100644 rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getAttr.expected create mode 100644 rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getAttr.ql diff --git a/rust/ast-generator/src/main.rs b/rust/ast-generator/src/main.rs index ec67da694234..c4be6312e6a2 100644 --- a/rust/ast-generator/src/main.rs +++ b/rust/ast-generator/src/main.rs @@ -359,7 +359,7 @@ fn get_fields(node: &AstNodeSrc) -> Vec { result.push(FieldInfo { name: "is_semicolon".to_string(), tp: "predicate".to_string(), - is_many: true, + is_many: false, }); } _ => {} diff --git a/rust/ql/.generated.list b/rust/ql/.generated.list index 93bfbb28bef8..0154b5943d08 100644 --- a/rust/ql/.generated.list +++ b/rust/ql/.generated.list @@ -1,8 +1,8 @@ -lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll 2dfc45d5b2b93b3aa226924da7f9321c2d7a20e60ac7a6a48215118f73fdb181 f1ec54884508eb1f72dcda6677f8e11b79043e906b1c7f3e408e1606e290e347 +lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll 2a4a561c08eafa7dfcac45c40b1bbde65e401983be3af4e0850f016a6bb2a732 9c86adf714e681e013dc4a0d944f2aa153a143ef8a8033d87254db9ae18cd896 lib/codeql/rust/elements/Abi.qll 4c973d28b6d628f5959d1f1cc793704572fd0acaae9a97dfce82ff9d73f73476 250f68350180af080f904cd34cb2af481c5c688dc93edf7365fd0ae99855e893 lib/codeql/rust/elements/Addressable.qll 13011bfd2e1556694c3d440cc34af8527da4df49ad92b62f2939d3699ff2cea5 ddb25935f7553a1a384b1abe2e4b4fa90ab50b952dadec32fd867afcb054f4be lib/codeql/rust/elements/ArgList.qll 661f5100f5d3ef8351452d9058b663a2a5c720eea8cf11bedd628969741486a2 28e424aac01a90fb58cd6f9f83c7e4cf379eea39e636bc0ba07efc818be71c71 -lib/codeql/rust/elements/ArrayExpr.qll 04e5710b083ce29b51e9c9cefd3fa24df5fbf79b0dbaef23b1724d7e708372e5 dd0b89075c985e67aaeb19e1750cc9301f0c1c991232d67a185797dcfe75b223 +lib/codeql/rust/elements/ArrayExpr.qll e4e7cff3518c50ec908271906dd46c1fbe9098faa1e8cd06a27f0a6e8d165ed1 fe02a4f4197f57ecd1e8e82d6c9384148ec29d8b106d7f696795b2f325e4a71b lib/codeql/rust/elements/ArrayListExpr.qll 451aedcecb479c385ff497588c7a07fda304fd5b873270223a4f2c804e96b245 a8cb008f6f732215623b5626c84b37b651ca01ccafb2cf4c835df35d5140c6ad lib/codeql/rust/elements/ArrayRepeatExpr.qll 4b7ed5be7d2caaf69f6fc0cd05b0e2416c52d547b1a73fb23d5a13007f75f4dd f6366f21cc48376b5fdf37e8c5c2b19415d4cbdeef09f33bb99cde5cb0f5b0e7 lib/codeql/rust/elements/ArrayType.qll affd43d308200d60d08e8924cdbb2a17a827ebaa62a296e07bb9ce97451e3c4c 80589a7f79bf2ac293a027faf2589b3027a6c4a286533f2ffccad259a306a8cb @@ -176,7 +176,6 @@ lib/codeql/rust/elements/internal/AbiImpl.qll 01439712ecadc9dc8da6f74d2e19cee13c lib/codeql/rust/elements/internal/AddressableImpl.qll e01a6104980960f5708d5a0ada774ba21db9a344e33deeaf3d3239c627268c77 b8bfc711b267df305ac9fe5f6a994f051ddeca7fc95dacd76d1bae2d4fa7adde lib/codeql/rust/elements/internal/ArgListConstructor.qll a73685c8792ae23a2d628e7357658efb3f6e34006ff6e9661863ef116ec0b015 0bee572a046e8dfc031b1216d729843991519d94ae66280f5e795d20aea07a22 lib/codeql/rust/elements/internal/ArgListImpl.qll 19664651c06b46530f0ae5745ccb3233afc97b9152e053761d641de6e9c62d38 40af167e571f5c255f264b3be7cc7f5ff42ec109661ca03dcee94e92f8facfc6 -lib/codeql/rust/elements/internal/ArrayExprImpl.qll b43ef2dc4b3ae6c9d89b61abe41a3723309c341fdc881d8c3264c251d669c321 667ea0b7fccda95365562e4755435af634cc043dd46fe965be0676b8883e3d2a lib/codeql/rust/elements/internal/ArrayExprInternal.qll 07a219b3d3fba3ff8b18e77686b2f58ab01acd99e0f5d5cad5d91af937e228f5 7528fc0e2064c481f0d6cbff3835950a044e429a2cd00c4d8442d2e132560d37 lib/codeql/rust/elements/internal/ArrayExprInternalConstructor.qll f9756bc40beee99c5e4355bf157030b440c532dff5bdf43e848b3aa1a00fea90 39467f7f313e6f9ede1fe92375ee408098dc65291ca8ee50e36a3684a2767836 lib/codeql/rust/elements/internal/ArrayExprInternalImpl.qll ae4488846c8309b2d4a51d54b36fce0a75107917c0b1f8af5ccf40797f570580 37838c7d6a04b95a16ed46e963d7e56def7a30b5e5ef1ab7e0dfdb5f256fa874 @@ -419,7 +418,7 @@ lib/codeql/rust/elements/internal/YieldExprImpl.qll af184649a348ddd0be16dee9daae lib/codeql/rust/elements/internal/generated/Abi.qll 87e1ea6b2a8ebf60e1c69176632740e4e27fc56c3f173939b098ba376562b5fa 94b2121e71c4ec94d53a79f972c05a8484ef0d80ed638f53031e7cf4dc5343d5 lib/codeql/rust/elements/internal/generated/Addressable.qll 96a8b45166dd035b8d2c6d36b8b67019f2d4d0b4ccff6d492677c0c87197613e d8f1ce29feafc8ff7179399fc7eac5db031a7e1a8bc6b2cd75cfce1da3132e9b lib/codeql/rust/elements/internal/generated/ArgList.qll 1b75b2d7dcf524eb468a0268af6293e9d17832d6bedf3feec49a535824339b57 2bcaf464454bdfdda45fbd24d063f0f1df0eb69f684197b37105adc8f72cd1ea -lib/codeql/rust/elements/internal/generated/ArrayExpr.qll 64d194a9a9d6467d123b90f910775ffc28b6c04e44990d6a1af6d1dbb2ec5bf5 ccc6183f9e90a6c11c5f79a068003a7d63db227fa69287d3ac12d48e8af63ac7 +lib/codeql/rust/elements/internal/generated/ArrayExpr.qll 73806a0de8168b38a9436fa6b8c6d68c92eeab3d64a1ae7edfff82f871929992 7ad998cdd8f4fed226473517ad7a5765cb35608033047aad53bf8aa3969fd03b lib/codeql/rust/elements/internal/generated/ArrayExprInternal.qll 67a7b0fae04b11cf771727ff39a123fb2d5ce6e2d650d32478fcb33a26ed5688 15833405fa85f6abe0e5146dac283cb5a142a07f08300ccc15a1dae30ed88942 lib/codeql/rust/elements/internal/generated/ArrayListExpr.qll f325163c2bd401286305330482bee20d060cecd24afa9e49deab7ba7e72ca056 ae3f5b303e31fc6c48b38172304ee8dcf3af2b2ba693767824ea8a944b6be0eb lib/codeql/rust/elements/internal/generated/ArrayRepeatExpr.qll ac2035488d5b9328f01ce2dd5bd7598e3af1cbb383ddb48b648e1e8908ea82fc 3ec910b184115fb3750692287e8039560e20bd6a5fb26ac1f9c346424d8eaa48 @@ -520,7 +519,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 2a2132e9df63ceeee7e2abbb6b6d9fd62856ae93d113b60ae7d8311d4c9535be b7aaa62c085e71c2dff42e7f2886770c48d964dfe45981c2857af4b9126a8a7b +lib/codeql/rust/elements/internal/generated/ParentChild.qll 8bec00eb2527dad0c361736d318745169296e4e949fc4263790d25c3286b2f79 91b5bd23de043906d91b3d7b75cd75b9cdc77e037a2be2af75912bc285068cbc lib/codeql/rust/elements/internal/generated/Pat.qll 3605ac062be2f294ee73336e9669027b8b655f4ad55660e1eab35266275154ee 7f9400db2884d336dd1d21df2a8093759c2a110be9bf6482ce8e80ae0fd74ed4 lib/codeql/rust/elements/internal/generated/Path.qll 4c1c8e840ed57880e574142b081b11d7a7428a009f10e3aa8f4645e211f6b2e0 989668cf0f1bdee7557e2f97c01e41d2a56848227fed41477833f5fc1e1d35f6 lib/codeql/rust/elements/internal/generated/PathExpr.qll 2096e3c1db22ee488a761690adabfc9cfdea501c99f7c5d96c0019cb113fc506 54245ce0449c4e263173213df01e079d5168a758503a5dbd61b25ad35a311140 @@ -599,9 +598,11 @@ test/extractor-tests/generated/Abi/Abi.ql 7f6e7dc4af86eca3ebdc79b10373988cd0871b test/extractor-tests/generated/Abi/Abi_getAbiString.ql a496762fcec5a0887b87023bbf93e9b650f02e20113e25c44d6e4281ae8f5335 14109c7ce11ba25e3cd6e7f1b3fcb4cb00622f2a4eac91bfe43145c5f366bc52 test/extractor-tests/generated/ArgList/ArgList.ql e412927756e72165d0e7c5c9bd3fca89d08197bbf760db8fb7683c64bb2229bc 043dba8506946fbb87753e22c387987d7eded6ddb963aa067f9e60ef9024d684 test/extractor-tests/generated/ArgList/ArgList_getArg.ql c07c946218489a0ad5fe89e5fd4a7f0ad84a73dc2e650729f48a340cb133be84 ff2382c0693f47e5eb1290aca325290e60c19d877b25b1d7e2ee96009f5fe934 -test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.ql 5b6c0d3f9c75e2cfde4fbe6dc443cb992e91925ba108664b04b88f9567322c28 01b891665f2c8a98770e4b4ac284aafc0d680dbaa10ad54a7799eda62048e21a +test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.ql e6f9fe0dd6af5a1223e1e59827346aa2975bd665aeda36e8844ffb3a79c5e532 38576b6f7257c119917442e4f54fc883480e4da86d2542a1ac16d723ebbba039 +test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getAttr.ql f1ca0521f641bed17581121c0f07c7f8737d9891acdde2c68de59a0684e86a34 496da6513cfee28a31274a2e72b5a58d843407ac5e4870296da0f0b8e7fc85c1 test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getExpr.ql 6920b532623e8c919701a83a059d9b1aac9e8673e7fdbe26e0a8af5ad6a34b8a 601137c715ce947d79f39d5b131d7ab167a16d29477eacdb1380cd647c4ebac4 -test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.ql cdf73db3b37a9b98a1c63c51bdca9691fcd16f952ce8730385240b7194c55819 8dc29fb0db5df4c4cdd87b406cea92e6e6602908d087af16037a2dec6f9204b8 +test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.ql 60a0df80fd34ca5c960b5e060c7090f8bbb8af83aba7099aa298a80e19a13346 c41f80601c7f50eee01c0ed7587e0198296d6a8a5b95c98dd8f865901d34ba5c +test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getAttr.ql fc6ca212aa633b73ee21f7564631c9ad345f15839656d88940dc686cf076a344 d580a367305adbe168996a294329b1adec36956a500ae9717a4af78cb2bef4e6 test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getExpr.ql 6b00037350fc36cc46345a290bda4c4d4ff99050b970d23eb94294313046a884 0687638b46e43bba9dda35d78ff7b40f976e5e38271eec77e7a21c28349dc42c test/extractor-tests/generated/ArrayType/ArrayType.ql d781ea647d60218777261d82230bd85f989a4768a043e736d268363b5a777390 b5c7fa0aa1b8b1f3a82b8af7254bf20efd3477bba83ad53530959d1733636604 test/extractor-tests/generated/ArrayType/ArrayType_getConstArg.ql b6a250873bc2d553219b8301a15bd19a4044f590085992c532a800bf3ab744cb 5e6b9dbbe2d3ea7f6fa3fba4811517a528d5eb58169b69d1b9113e1508c6e627 diff --git a/rust/ql/.gitattributes b/rust/ql/.gitattributes index 29bee7221b9b..f8cf236c7a53 100644 --- a/rust/ql/.gitattributes +++ b/rust/ql/.gitattributes @@ -178,7 +178,6 @@ /lib/codeql/rust/elements/internal/AddressableImpl.qll linguist-generated /lib/codeql/rust/elements/internal/ArgListConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/ArgListImpl.qll linguist-generated -/lib/codeql/rust/elements/internal/ArrayExprImpl.qll linguist-generated /lib/codeql/rust/elements/internal/ArrayExprInternal.qll linguist-generated /lib/codeql/rust/elements/internal/ArrayExprInternalConstructor.qll linguist-generated /lib/codeql/rust/elements/internal/ArrayExprInternalImpl.qll linguist-generated @@ -602,8 +601,10 @@ /test/extractor-tests/generated/ArgList/ArgList.ql linguist-generated /test/extractor-tests/generated/ArgList/ArgList_getArg.ql linguist-generated /test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.ql linguist-generated +/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getAttr.ql linguist-generated /test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getExpr.ql linguist-generated /test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.ql linguist-generated +/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getAttr.ql linguist-generated /test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getExpr.ql linguist-generated /test/extractor-tests/generated/ArrayType/ArrayType.ql linguist-generated /test/extractor-tests/generated/ArrayType/ArrayType_getConstArg.ql 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 97d44793667c..99cf29a5e98a 100644 --- a/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll +++ b/rust/ql/lib/codeql/rust/controlflow/internal/generated/CfgNodes.qll @@ -111,6 +111,21 @@ module MakeCfgNodes Input> { * Gets the number of expressions of this array expression. */ int getNumberOfExprs() { result = count(int i | exists(this.getExpr(i))) } + + /** + * Gets the `index`th attr of this array expression (0-based). + */ + Attr getAttr(int index) { result = node.getAttr(index) } + + /** + * Gets any of the attrs of this array expression. + */ + Attr getAnAttr() { result = this.getAttr(_) } + + /** + * Gets the number of attrs of this array expression. + */ + int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } } final private class ParentArrayListExpr extends ParentAstNode, ArrayListExpr { diff --git a/rust/ql/lib/codeql/rust/elements/ArrayExpr.qll b/rust/ql/lib/codeql/rust/elements/ArrayExpr.qll index f24e2dc1b109..b1895a1295a0 100644 --- a/rust/ql/lib/codeql/rust/elements/ArrayExpr.qll +++ b/rust/ql/lib/codeql/rust/elements/ArrayExpr.qll @@ -4,6 +4,7 @@ */ private import internal.ArrayExprImpl +import codeql.rust.elements.Attr import codeql.rust.elements.Expr /** diff --git a/rust/ql/lib/codeql/rust/elements/internal/ArrayExprImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/ArrayExprImpl.qll index 2958347e369b..13abb32bcce4 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/ArrayExprImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/ArrayExprImpl.qll @@ -1,4 +1,3 @@ -// generated by codegen, remove this comment if you wish to edit this file /** * This module provides a hand-modifiable wrapper around the generated class `ArrayExpr`. * @@ -6,12 +5,15 @@ */ private import codeql.rust.elements.internal.generated.ArrayExpr +private import codeql.rust.elements.internal.generated.Raw +private import codeql.rust.elements.internal.generated.Synth /** * INTERNAL: This module contains the customizable definition of `ArrayExpr` and should not * be referenced directly. */ module Impl { + // the following QLdoc is generated: if you need to edit it, do it in the schema file /** * The base class for array expressions. For example: * ```rust @@ -19,5 +21,18 @@ module Impl { * [1; 10]; * ``` */ - class ArrayExpr extends Generated::ArrayExpr { } + class ArrayExpr extends Generated::ArrayExpr { + cached + private Raw::ArrayExprInternal getUnderlyingEntity() { + this = Synth::TArrayListExpr(result) or this = Synth::TArrayRepeatExpr(result) + } + + override Expr getExpr(int index) { + result = Synth::convertExprFromRaw(this.getUnderlyingEntity().getExpr(index)) + } + + override Attr getAttr(int index) { + result = Synth::convertAttrFromRaw(this.getUnderlyingEntity().getAttr(index)) + } + } } diff --git a/rust/ql/lib/codeql/rust/elements/internal/ArrayListExprImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/ArrayListExprImpl.qll index 7815b82d18b5..8b22613dca3d 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/ArrayListExprImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/ArrayListExprImpl.qll @@ -22,13 +22,6 @@ module Impl { * ``` */ class ArrayListExpr extends Generated::ArrayListExpr { - cached - private Raw::ArrayExprInternal getUnderlyingEntity() { this = Synth::TArrayListExpr(result) } - override string toString() { result = "[...]" } - - override Expr getExpr(int index) { - result = Synth::convertExprFromRaw(this.getUnderlyingEntity().getExpr(index)) - } } } diff --git a/rust/ql/lib/codeql/rust/elements/internal/ArrayRepeatExprImpl.qll b/rust/ql/lib/codeql/rust/elements/internal/ArrayRepeatExprImpl.qll index dbf8bcf46fa3..66e83a6badbb 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/ArrayRepeatExprImpl.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/ArrayRepeatExprImpl.qll @@ -21,9 +21,6 @@ module Impl { * ``` */ class ArrayRepeatExpr extends Generated::ArrayRepeatExpr { - cached - private Raw::ArrayExprInternal getUnderlyingEntity() { this = Synth::TArrayRepeatExpr(result) } - override string toString() { result = "[" + this.getRepeatOperand().toAbbreviatedString() + "; " + @@ -33,9 +30,5 @@ module Impl { override Expr getRepeatOperand() { result = this.getExpr(0) } override Expr getRepeatLength() { result = this.getExpr(1) } - - override Expr getExpr(int index) { - result = Synth::convertExprFromRaw(this.getUnderlyingEntity().getExpr(index)) - } } } diff --git a/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayExpr.qll b/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayExpr.qll index b3362b557dcb..cb6d92d0dd5f 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayExpr.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/ArrayExpr.qll @@ -6,6 +6,7 @@ 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.Expr import codeql.rust.elements.internal.ExprImpl::Impl as ExprImpl @@ -38,5 +39,20 @@ module Generated { * Gets the number of expressions of this array expression. */ final int getNumberOfExprs() { result = count(int i | exists(this.getExpr(i))) } + + /** + * Gets the `index`th attr of this array expression (0-based). + */ + Attr getAttr(int index) { none() } + + /** + * Gets any of the attrs of this array expression. + */ + final Attr getAnAttr() { result = this.getAttr(_) } + + /** + * Gets the number of attrs of this array expression. + */ + final int getNumberOfAttrs() { result = count(int i | exists(this.getAttr(i))) } } } 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 eeca98f1bf51..dbf0d9d3191b 100644 --- a/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll +++ b/rust/ql/lib/codeql/rust/elements/internal/generated/ParentChild.qll @@ -1190,11 +1190,12 @@ private module Impl { } private Element getImmediateChildOfArrayExpr(ArrayExpr e, int index, string partialPredicateCall) { - exists(int b, int bExpr, int n, int nExpr | + exists(int b, int bExpr, int n, int nExpr, int nAttr | b = 0 and bExpr = b + 1 + max(int i | i = -1 or exists(getImmediateChildOfExpr(e, i, _)) | i) and n = bExpr and nExpr = n + 1 + max(int i | i = -1 or exists(e.getExpr(i)) | i) and + nAttr = nExpr + 1 + max(int i | i = -1 or exists(e.getAttr(i)) | i) and ( none() or @@ -1202,6 +1203,9 @@ private module Impl { or result = e.getExpr(index - n) and partialPredicateCall = "Expr(" + (index - n).toString() + ")" + or + result = e.getAttr(index - nExpr) and + partialPredicateCall = "Attr(" + (index - nExpr).toString() + ")" ) ) } diff --git a/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.expected b/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.expected index 5fa9032183aa..31fd8036aad7 100644 --- a/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.expected +++ b/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.expected @@ -1 +1 @@ -| gen_array_list_expr.rs:5:5:5:13 | [...] | getNumberOfExprs: | 3 | +| gen_array_list_expr.rs:5:5:5:13 | [...] | getNumberOfExprs: | 3 | getNumberOfAttrs: | 0 | diff --git a/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.ql b/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.ql index ab884cf297b2..72f74d5ce34d 100644 --- a/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.ql +++ b/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr.ql @@ -2,9 +2,10 @@ import codeql.rust.elements import TestUtils -from ArrayListExpr x, int getNumberOfExprs +from ArrayListExpr x, int getNumberOfExprs, int getNumberOfAttrs where toBeTested(x) and not x.isUnknown() and - getNumberOfExprs = x.getNumberOfExprs() -select x, "getNumberOfExprs:", getNumberOfExprs + getNumberOfExprs = x.getNumberOfExprs() and + getNumberOfAttrs = x.getNumberOfAttrs() +select x, "getNumberOfExprs:", getNumberOfExprs, "getNumberOfAttrs:", getNumberOfAttrs diff --git a/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getAttr.expected b/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getAttr.expected new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getAttr.ql b/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getAttr.ql new file mode 100644 index 000000000000..10a9b3d52b34 --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/ArrayListExpr/ArrayListExpr_getAttr.ql @@ -0,0 +1,7 @@ +// generated by codegen, do not edit +import codeql.rust.elements +import TestUtils + +from ArrayListExpr x, int index +where toBeTested(x) and not x.isUnknown() +select x, index, x.getAttr(index) diff --git a/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.expected b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.expected index 15ea26f6b599..e19394137d93 100644 --- a/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.expected +++ b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.expected @@ -1 +1 @@ -| gen_array_repeat_expr.rs:5:5:5:11 | [1; 10] | getNumberOfExprs: | 2 | getRepeatOperand: | gen_array_repeat_expr.rs:5:6:5:6 | 1 | getRepeatLength: | gen_array_repeat_expr.rs:5:9:5:10 | 10 | +| gen_array_repeat_expr.rs:5:5:5:11 | [1; 10] | getNumberOfExprs: | 2 | getNumberOfAttrs: | 0 | getRepeatOperand: | gen_array_repeat_expr.rs:5:6:5:6 | 1 | getRepeatLength: | gen_array_repeat_expr.rs:5:9:5:10 | 10 | diff --git a/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.ql b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.ql index aa7d306beb34..cda59a0d6387 100644 --- a/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.ql +++ b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr.ql @@ -2,12 +2,15 @@ import codeql.rust.elements import TestUtils -from ArrayRepeatExpr x, int getNumberOfExprs, Expr getRepeatOperand, Expr getRepeatLength +from + ArrayRepeatExpr x, int getNumberOfExprs, int getNumberOfAttrs, Expr getRepeatOperand, + Expr getRepeatLength where toBeTested(x) and not x.isUnknown() and getNumberOfExprs = x.getNumberOfExprs() and + getNumberOfAttrs = x.getNumberOfAttrs() and getRepeatOperand = x.getRepeatOperand() and getRepeatLength = x.getRepeatLength() -select x, "getNumberOfExprs:", getNumberOfExprs, "getRepeatOperand:", getRepeatOperand, - "getRepeatLength:", getRepeatLength +select x, "getNumberOfExprs:", getNumberOfExprs, "getNumberOfAttrs:", getNumberOfAttrs, + "getRepeatOperand:", getRepeatOperand, "getRepeatLength:", getRepeatLength diff --git a/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getAttr.expected b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getAttr.expected new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getAttr.ql b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getAttr.ql new file mode 100644 index 000000000000..30c64104eeef --- /dev/null +++ b/rust/ql/test/extractor-tests/generated/ArrayRepeatExpr/ArrayRepeatExpr_getAttr.ql @@ -0,0 +1,7 @@ +// generated by codegen, do not edit +import codeql.rust.elements +import TestUtils + +from ArrayRepeatExpr x, int index +where toBeTested(x) and not x.isUnknown() +select x, index, x.getAttr(index) diff --git a/rust/schema/annotations.py b/rust/schema/annotations.py index 2978cb13c66f..773d126e5d1c 100644 --- a/rust/schema/annotations.py +++ b/rust/schema/annotations.py @@ -565,6 +565,7 @@ class ArrayExpr(Expr): ``` """ exprs: list[Expr] | child + attrs: list[Attr] | child @synth.from_class(ArrayExprInternal) class ArrayListExpr(ArrayExpr):