Skip to content

Commit af03cf3

Browse files
committed
Preserve fundec location in merger
1 parent eb64242 commit af03cf3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/mergecil.ml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@
13381338

13391339
let processOneGlobal (g : global) : unit =
13401340
(* Process a varinfo. Reuse an old one, or rename it if necessary *)
1341-
let processVarinfo (vi : varinfo) (vloc : location) : varinfo =
1341+
let processVarinfo ~isadef (vi : varinfo) (vloc : location) : varinfo =
13421342
if vi.vreferenced then vi (* Already done *)
13431343
else if not (externallyVisible vi) then
13441344
(* rename static and not-external inline functions no matter if merge_inlines is enabled or not,
@@ -1363,14 +1363,16 @@
13631363
vi'.vreferenced <- true;
13641364
(* Mark it as done already *)
13651365
vi'.vaddrof <- vi.vaddrof || vi'.vaddrof;
1366+
if isadef then
1367+
vi'.vdecl <- vi.vdecl;
13661368
vi'
13671369
in
13681370
try
13691371
match g with
13701372
| GVarDecl (vi, l) as g ->
13711373
currentLoc := l;
13721374
incr currentDeclIdx;
1373-
let vi' = processVarinfo vi l in
1375+
let vi' = processVarinfo ~isadef:false vi l in
13741376
if vi != vi' then (* Drop this declaration *) ()
13751377
else if H.mem emittedVarDecls vi'.vname then
13761378
(* No need to keep it *)
@@ -1382,7 +1384,7 @@
13821384
| GVar (vi, init, l) ->
13831385
currentLoc := l;
13841386
incr currentDeclIdx;
1385-
let vi' = processVarinfo vi l in
1387+
let vi' = processVarinfo ~isadef:(init.init <> None) vi l in
13861388
(* We must keep this definition even if we reuse this varinfo, because maybe the previous one was a declaration *)
13871389
H.add emittedVarDecls vi.vname true;
13881390
if mergeGlobals then
@@ -1408,7 +1410,7 @@
14081410
currentLoc := l;
14091411
incr currentDeclIdx;
14101412
(* We apply the renaming *)
1411-
fdec.svar <- processVarinfo fdec.svar l;
1413+
fdec.svar <- processVarinfo ~isadef:true fdec.svar l;
14121414
(* Get the original name. *)
14131415
let origname = try H.find originalVarNames fdec.svar.vname with Not_found -> fdec.svar.vname in
14141416
(* Go in there and rename everything as needed *)

0 commit comments

Comments
 (0)