Conversation
Restore currentLoc and currentExpLoc after the doDecl call in the FOR statement handler to prevent the increment expression from inheriting the initialization location.
sim642
approved these changes
Jan 23, 2026
sim642
left a comment
Member
There was a problem hiding this comment.
Based on the Goblint location test changes in goblint/analyzer#1930 this improves the situation.
I added some comments and TODOs because it's not clear to me which previously-existing location changes under A.FOR are still necessary and which are not, even though I added them at some point.
There are still odd small offsets as well, but there seem to be unrelated problems in the positioning code that I'll open separate issues about.
mseri
pushed a commit
to ocaml/opam-repository
that referenced
this pull request
Jun 12, 2026
CHANGES: * Add cast kinds (goblint/cil#179, goblint/cil#199). * Add `_Static_assert` checking (goblint/cil#65, goblint/cil#209). * Optimize `hasAttribute`, etc. (goblint/cil#221, goblint/cil#222, goblint/cil#223, goblint/cil#224). * Remove hardcoded unary minus constant folding in `Cabs2cil` (goblint/cil#216). * Fix unary plus integer promotion (goblint/cil#200). * Add division overflow check to modulo constant folding (goblint/cil#217). * Add impure expression support to `__auto_type` (goblint/cil#207). * Add more `__builtin_*` evaluation (goblint/cil#204, goblint/cil#205, goblint/cil#206). * Fix `for` loop component locations (goblint/cil#183, goblint/cil#211).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Solves #183
The parser now captures distinct location ranges for each component of the for loop, e.g.:
int i = 0i < 5i++Changes
for_clausegrammar rule to return location rangesFORstatement to track separate locations for initialization, condition, and incrementcabs2cilto use the component-specific locations when processing each part