goblint / cil

C Intermediate Language
https://goblint.github.io/cil/
Other
133 stars 20 forks source link

Fix `Pretty` not resetting all global state between calls #133

Closed sim642 closed 1 year ago

sim642 commented 1 year ago

This fixes the long-standing oddity where Goblint prints warnings like

[Info][Imprecise] Invalidating expressions: AddrOf(Var(tmp,
                                     NoOffset)) (tests/regression/04-mutex/13-failed_locking.c:20:7-20:34)

despite using Pretty.sprint ~width:max_int, which should avoid such random line breaks.

The specific problem was that Pretty.breakAllMode was not being reset between different Pretty calls, so when it became active, following pretty-printing had such odd line breaks.

There were two more global variables in Pretty which were not being reset: topAlignAbsCol and aligns. Now all global variables in Pretty are reset and restored properly.