Skip to content

Conversation

@karoliineh
Copy link
Member

Solves #183

The parser now captures distinct location ranges for each component of the for loop, e.g.:

  • Initialization: int i = 0
  • Condition: i < 5
  • Increment: i++

Changes

  • Made for_clause grammar rule to return location ranges
  • Updated FOR statement to track separate locations for initialization, condition, and increment
  • Updated cabs2cil to use the component-specific locations when processing each part
  • Updated affected visitor and printer functions

Restore currentLoc and currentExpLoc after the doDecl call in the FOR statement handler to prevent the increment expression from inheriting the initialization location.
Copy link
Member

@sim642 sim642 left a comment

Choose a reason for hiding this comment

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

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.

@sim642 sim642 added this to the 2.1.0 milestone Jan 23, 2026
@sim642 sim642 merged commit abe64c5 into develop Jan 23, 2026
30 checks passed
@sim642 sim642 deleted the issue-183 branch January 23, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants