Skip to content

Commit

Permalink
Add comments about synthetic location changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sim642 committed Feb 28, 2024
1 parent fb47158 commit f87d5c8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/frontc/cabs2cil.ml
Original file line number Diff line number Diff line change
Expand Up @@ -6026,6 +6026,8 @@ and doDecl (isglobal: bool) : A.definition -> chunk = function
ignore (E.log "after doDecl %a: res=%a\n"
d_loc !currentLoc d_chunk res);
*)
(* First transformed assign instruction from declaration initializer has non-synthetic statement location.
All following locations are synthetic. *)
SynthetizeLoc.eDoChunkHead (SynthetizeLoc.doChunkTail res)


Expand Down Expand Up @@ -6769,14 +6771,17 @@ and doStatement (s : A.statement) : chunk =
| A.FOR(fc1,e2,e3,s,loc,eloc) -> begin
let loc' = convLoc loc in
let eloc' = convLoc eloc in
currentLoc := loc';
currentLoc := loc'; (* For loop statement location is not synthetic. *)
currentExpLoc := SynthetizeLoc.doLoc eloc';
enterScope (); (* Just in case we have a declaration *)
let (se1, _, _) =
match fc1 with
FC_EXP e1 -> doExp false e1 ADrop
| FC_DECL d1 -> (doDecl false d1, zero, voidType)
in
(* First instruction (assignment) in for loop initializer has non-synthetic statement location before for loop.
Its expression location inside for loop parentheses is synthetic.
All other instructions are fully synthetic. *)
let se1 = SynthetizeLoc.eDoChunkHead (SynthetizeLoc.doChunkTail se1) in
let (se3, _, _) = doExp false e3 ADrop in
let se3 = SynthetizeLoc.doChunkHead se3 in
Expand Down

0 comments on commit f87d5c8

Please sign in to comment.