Skip to content

Commit 69b05e8

Browse files
committed
Add fields for OffsetOf
1 parent 7511336 commit 69b05e8

File tree

6 files changed

+59
-6
lines changed

6 files changed

+59
-6
lines changed

rust/.generated.list

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/extractor/src/generated/top.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,8 @@ impl TrapEntry for Module {
814814
pub struct OffsetOf {
815815
pub id: TrapId,
816816
pub location: Option<trap::Label>,
817+
pub container: trap::Label,
818+
pub fields: Vec<String>,
817819
}
818820

819821
impl TrapEntry for OffsetOf {
@@ -822,10 +824,13 @@ impl TrapEntry for OffsetOf {
822824
}
823825

824826
fn emit(self, id: trap::Label, out: &mut trap::Writer) {
825-
out.add_tuple("offset_ofs", vec![trap::Arg::Label(id)]);
827+
out.add_tuple("offset_ofs", vec![trap::Arg::Label(id), self.container.into()]);
826828
if let Some(v) = self.location {
827829
out.add_tuple("locatable_locations", vec![trap::Arg::Label(id), v.into()]);
828830
}
831+
for (i, &v) in self.fields.iter().enumerate() {
832+
out.add_tuple("offset_of_fields", vec![trap::Arg::Label(id), i.into(), v.into()]);
833+
}
829834
}
830835
}
831836

rust/ql/lib/codeql/rust/generated/OffsetOf.qll

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ql/lib/codeql/rust/generated/Raw.qll

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/ql/lib/rust.dbscheme

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,15 @@ module_declarations(
456456
);
457457

458458
offset_ofs(
459-
unique int id: @offset_of
459+
unique int id: @offset_of,
460+
int container: @type_ref ref
461+
);
462+
463+
#keyset[id, index]
464+
offset_of_fields(
465+
int id: @offset_of ref,
466+
int index: int ref,
467+
string field: string ref
460468
);
461469

462470
or_pats(

rust/schema.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,9 @@ class Underscore(Expr):
437437

438438

439439
class OffsetOf(Expr):
440-
pass
440+
container: TypeRef
441+
fields: list[string]
442+
441443
# InlineAsm(InlineAsm),
442444

443445

0 commit comments

Comments
 (0)