Skip to content

Remove type argument from do_update_offset, fix calls with incorrect offset type#1984

Open
sim642 wants to merge 4 commits intomasterfrom
valuedomain-do-offset-2
Open

Remove type argument from do_update_offset, fix calls with incorrect offset type#1984
sim642 wants to merge 4 commits intomasterfrom
valuedomain-do-offset-2

Conversation

@sim642
Copy link
Copy Markdown
Member

@sim642 sim642 commented Apr 9, 2026

This is a continuation of #1914.
There I noticed that do_update_offset recursively may change the type, whereas do_eval_offset did not. This mismatch of strange because both should recurse into base value domain abstractions in the same manner.
Thus, this PR removes that argument to make things more consistent.

Simply removing the argument breaks a lot of tests. Turns out that VD.update_offset is being called in multiple places with the incorrect type which isn't the one corresponding to the offset being updated.
By fixing these (explanations in commit messages), all tests again pass.

The type-changing aspect of do_update_offset was just covering up these root issues by managing to get the type from somewhere else.

TODO

sim642 added 4 commits April 9, 2026 13:32
Makes it consistent with do_eval_offset.
This breaks a lot of tests.
The bot_value is constructed for the variable, but update_offset goes deeper into fields.
to_cil_offset is specific for partitioned arrays and drops indices.
Thus, it can compute an incorrect type which doesn't match the actual offset.
The entire var is refined, but update_offset goes deeper into fields.
@sim642 sim642 added this to the v2.8.0 Clumsy Clurichaun milestone Apr 9, 2026
@sim642 sim642 added the cleanup Refactoring, clean-up label Apr 9, 2026
Copilot AI review requested due to automatic review settings April 9, 2026 10:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the recursive “type” parameter from do_update_offset to align its recursion behavior with do_eval_offset, and fixes VD.update_offset call sites that were passing a type that didn’t correspond to the offset being updated.

Changes:

  • Simplified ValueDomain.update_offset internals by removing the recursive t: typ argument from do_update_offset.
  • Updated Base analysis write paths to compute the updated lvalue type via Offs.type_of ~base:x.vtype offs (with fallback) instead of Cilfacade.typeOfLval on an index-dropping offset.
  • Updated BaseInvariant refinement to pass Cilfacade.typeOfLval x (lval-with-offset type) instead of var.vtype.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/cdomain/value/cdomains/valueDomain.ml Removes recursive t threading in do_update_offset, keeping type usage consistent with do_eval_offset.
src/analyses/baseInvariant.ml Passes the correct offset-specific lval type into VD.update_offset during whole-variable refinement.
src/analyses/base.ml Computes the type for VD.update_offset using Offs.type_of (and improves debug/tracing output accordingly).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@michael-schwarz michael-schwarz self-requested a review April 9, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup Refactoring, clean-up

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants