|
1338 | 1338 |
|
1339 | 1339 | let processOneGlobal (g : global) : unit = |
1340 | 1340 | (* 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 = |
1342 | 1342 | if vi.vreferenced then vi (* Already done *) |
1343 | 1343 | else if not (externallyVisible vi) then |
1344 | 1344 | (* rename static and not-external inline functions no matter if merge_inlines is enabled or not, |
|
1363 | 1363 | vi'.vreferenced <- true; |
1364 | 1364 | (* Mark it as done already *) |
1365 | 1365 | vi'.vaddrof <- vi.vaddrof || vi'.vaddrof; |
| 1366 | + if isadef then |
| 1367 | + vi'.vdecl <- vi.vdecl; |
1366 | 1368 | vi' |
1367 | 1369 | in |
1368 | 1370 | try |
1369 | 1371 | match g with |
1370 | 1372 | | GVarDecl (vi, l) as g -> |
1371 | 1373 | currentLoc := l; |
1372 | 1374 | incr currentDeclIdx; |
1373 | | - let vi' = processVarinfo vi l in |
| 1375 | + let vi' = processVarinfo ~isadef:false vi l in |
1374 | 1376 | if vi != vi' then (* Drop this declaration *) () |
1375 | 1377 | else if H.mem emittedVarDecls vi'.vname then |
1376 | 1378 | (* No need to keep it *) |
|
1382 | 1384 | | GVar (vi, init, l) -> |
1383 | 1385 | currentLoc := l; |
1384 | 1386 | incr currentDeclIdx; |
1385 | | - let vi' = processVarinfo vi l in |
| 1387 | + let vi' = processVarinfo ~isadef:(init.init <> None) vi l in |
1386 | 1388 | (* We must keep this definition even if we reuse this varinfo, because maybe the previous one was a declaration *) |
1387 | 1389 | H.add emittedVarDecls vi.vname true; |
1388 | 1390 | if mergeGlobals then |
|
1408 | 1410 | currentLoc := l; |
1409 | 1411 | incr currentDeclIdx; |
1410 | 1412 | (* We apply the renaming *) |
1411 | | - fdec.svar <- processVarinfo fdec.svar l; |
| 1413 | + fdec.svar <- processVarinfo ~isadef:true fdec.svar l; |
1412 | 1414 | (* Get the original name. *) |
1413 | 1415 | let origname = try H.find originalVarNames fdec.svar.vname with Not_found -> fdec.svar.vname in |
1414 | 1416 | (* Go in there and rename everything as needed *) |
|
0 commit comments