3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-10 02:50:55 +00:00

Refactor find_probe() to use std::optional (#8334)

* Initial plan

* Refactor find_probe() to use std::optional

- Updated tactic_manager.h: Changed return type to std::optional<probe_info*>
- Updated tactic_manager.cpp: Modified implementation to return std::nullopt or probe pointer
- Updated api_tactic.cpp: Changed 2 call sites to use optional checks and dereference
- Updated tactic_cmds.cpp: Changed 1 call site to use optional check and dereference
- Build verified successfully
- Probe functionality tested with Python bindings

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
Copilot 2026-01-25 15:13:36 -08:00 committed by GitHub
parent 2ac78b6def
commit 49817bc259
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 14 additions and 13 deletions

View file

@ -91,12 +91,12 @@ extern "C" {
Z3_TRY;
LOG_Z3_mk_probe(c, name);
RESET_ERROR_CODE();
probe_info * p = mk_c(c)->find_probe(symbol(name));
if (p == nullptr) {
auto p = mk_c(c)->find_probe(symbol(name));
if (!p) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
RETURN_Z3(nullptr);
}
probe * new_p = p->get();
probe * new_p = (*p)->get();
RETURN_PROBE(new_p);
Z3_CATCH_RETURN(nullptr);
}
@ -404,12 +404,12 @@ extern "C" {
Z3_TRY;
LOG_Z3_probe_get_descr(c, name);
RESET_ERROR_CODE();
probe_info * p = mk_c(c)->find_probe(symbol(name));
if (p == nullptr) {
auto p = mk_c(c)->find_probe(symbol(name));
if (!p) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
return "";
}
return p->get_descr();
return (*p)->get_descr();
Z3_CATCH_RETURN("");
}