3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-07-15 11:35:42 +00:00
z3/src/opt
davedets 69cd7e0c4c
Fixes necessary to compile z3 included in clang-tidy via FetchContents. (#9768)
The page
https://github.com/Z3Prover/z3/blob/master/README-CMake.md#adding-z3-as-a-dependency-to-a-cmake-project
advises using the CMake FetchContent feature to include z3 as source
into other CMake project. I'm trying to do this to use Z3 within a
ClangTidy checker. This is one of a series of PR's aimed at getting Z3
to compile cleanly when included this way.

This initial PR fixes all the errors, allowing the compilation to
succeed. Subsequent diffs will address warnings.

I tested only the CMake compilation, on a Mac.

*Missing Z3_THROWs*

Update z3++.h to use Z3_THROW in a couple of places. Clang compiles with
exceptions disabled so we get messages like:

```
/Users/daviddetlefs/llvm-project/build_dbg/_deps/z3-src/src/api/c++/z3++.h:4928:17: error: cannot use 'throw' with exceptions disabled4928 |                 throw exception("rcf_num objects from different contexts");
```

NOTE TO REVIEWERS: I'm not complete clear on the usage conventions for
Z3_THROW. With exception disabled, it seems like the throwing function
will just continue. If there's somethign else that should be done, like
setting some error state, please let me know.

*CMake component name collision*

There was an error at the CMake level, a name collision (on "opt").
Apparently CMake components are named using a flat namespace, so it's
easy to see how this could occur. It seems to me that the right global
way to fix this would be to encourage people to use some form of
"qualified name" convention in naming their component. The fix I chose
was a local version of this, changing the Z3 component name to z3_opt.
(It didn't seem feasible to make the change in clang.)

NOTE TO REVIEWERS: If you think this is OK, please let me know if

a) You'd like me to also change the name of the opt directory, to keep
thecomponent-name == directory-name invariant, and

b) You'd like me to make this z3_ change more globally, to future-proof
(somewhat) against similar component name collisions.
2026-06-08 19:44:01 -07:00
..
CMakeLists.txt Fixes necessary to compile z3 included in clang-tidy via FetchContents. (#9768) 2026-06-08 19:44:01 -07:00
maxcore.cpp Refactor mk_and/mk_or call sites to use vector overloads (#8286) 2026-01-22 13:21:22 -08:00
maxcore.h update wcnf front-end and add new wcnf strategy 2026-01-01 17:50:42 -08:00
maxlex.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
maxlex.h separate pre-processing, add callback parameter to push/pop in python API 2022-04-11 17:05:59 +02:00
maxsmt.cpp update wcnf front-end and add new wcnf strategy 2026-01-01 17:50:42 -08:00
maxsmt.h Fix unused parameter warnings in empty override functions by omitting parameter names (#8174) 2026-01-12 21:27:33 -08:00
opt_cmds.cpp Fix unused parameter warnings in empty override functions by omitting parameter names (#8174) 2026-01-12 21:27:33 -08:00
opt_cmds.h booyah 2020-07-04 15:56:30 -07:00
opt_context.cpp refactor solver to include settable stats 2026-06-07 14:17:38 -07:00
opt_context.h refactor solver to include settable stats 2026-06-07 14:17:38 -07:00
opt_cores.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
opt_cores.h add option to "rotate" cores during core finding 2022-05-01 15:26:56 -07:00
opt_lns.cpp refine maxresw option 2026-01-02 16:23:51 -08:00
opt_lns.h Use = default for virtual constructors. 2022-08-05 18:11:46 +03:00
opt_mux.h separate pre-processing, add callback parameter to push/pop in python API 2022-04-11 17:05:59 +02:00
opt_params.pyg update wcnf front-end and add new wcnf strategy 2026-01-01 17:50:42 -08:00
opt_pareto.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
opt_pareto.h Use = default for virtual constructors. 2022-08-05 18:11:46 +03:00
opt_parse.cpp Refactor mk_and/mk_or call sites to use vector overloads (#8286) 2026-01-22 13:21:22 -08:00
opt_parse.h booyah 2020-07-04 15:56:30 -07:00
opt_preprocess.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
opt_preprocess.h core opt 2022-05-21 10:27:37 -04:00
opt_sls_solver.h refactor solver to include settable stats 2026-06-07 14:17:38 -07:00
opt_solver.cpp refactor solver to include settable stats 2026-06-07 14:17:38 -07:00
opt_solver.h refactor solver to include settable stats 2026-06-07 14:17:38 -07:00
optsmt.cpp fix box mode: reset bounds before each objective 2026-03-19 17:07:21 -10:00
optsmt.h fix #9030: box mode objectives are now optimized independently 2026-03-19 17:07:21 -10:00
pb_sls.cpp Centralize and document TRACE tags using X-macros (#7657) 2025-05-28 14:31:25 +01:00
pb_sls.h booyah 2020-07-04 15:56:30 -07:00
sortmax.cpp Refactor mk_and and mk_app to use std::span API (#8285) 2026-01-22 16:58:38 -08:00
totalizer.cpp totalizer 2022-06-30 19:49:19 -07:00
totalizer.h totalizer 2022-06-30 19:49:19 -07:00
wmax.cpp Add [[nodiscard]] to AST factory functions and modernize iterator loops (#8143) 2026-01-11 09:58:25 -08:00
wmax.h re-enable pre-process 2022-04-13 11:24:24 +02:00