Skip to content

Conversation

sim642
Copy link
Member

@sim642 sim642 commented Jul 25, 2025

All global state is replaced by a record which is passed around. The global state was there just due to laziness:

(* We use references to avoid the need to pass data around all the time *)

The record is fresh for each call to Pretty, so there should be no races between domains or with signal handlers.
This also simplifies the handling of nested calls to Pretty, which have previously been buggy: PR #133.

The only global state I kept is countNewLines, although nothing actually uses it. It's made Atomic.t (which also exists on OCaml 4 for compatibility, without domain_shims or anything). But we could also just remove it.

As far as I can immediately tell, there should be no regressions from this: all CIL and Goblint tests pass. The latter cram tests have output entirely based on Pretty (including transformation tests pretty-printing C code) and nothing changed.

TODO

  • Remove domain_shims dependency?

Copy link
Member

@michael-schwarz michael-schwarz left a comment

Choose a reason for hiding this comment

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

Great job! I substantially overestimated how complicated getting rid of the state is!

@michael-schwarz
Copy link
Member

Anything still blocking the merge? Would be good to get this also into Goblint soon.

@arkocal
Copy link

arkocal commented Jul 29, 2025

I would like to run this with the parallel solver (planned for today)

@michael-schwarz michael-schwarz merged commit 4b8b06e into develop Jul 30, 2025
28 checks passed
@michael-schwarz michael-schwarz deleted the pretty-state2 branch July 30, 2025 14:27
sim642 added a commit to sim642/opam-repository that referenced this pull request Sep 2, 2025
CHANGES:

* Add `_Float16` type support (goblint/cil#190, goblint/cil#193).
* Add C23 `alignof` and `alignas` support (goblint/cil#189, goblint/cil#191).
* Add initializer support for anonymous struct in union (goblint/cil#176, goblint/cil#184).
* Fix enumerator printing (goblint/cil#185).
* Remove global state from `Pretty` (goblint/cil#187).
* Remove OCaml <4.12 support (goblint/cil#180, goblint/cil#181).
* Use `gnu11` standard in most tests (goblint/cil#188, goblint/cil#192).
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