Skip to content

Solver factory: make_satcheck_prop does not require dynamic_cast #8410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions src/goto-checker/solver_factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,27 +188,35 @@
}

template <typename SatcheckT>
static std::unique_ptr<SatcheckT>
static typename std::enable_if<
!std::is_base_of<hardness_collectort, SatcheckT>::value,

Check warning on line 192 in src/goto-checker/solver_factory.cpp

View check run for this annotation

Codecov / codecov/patch

src/goto-checker/solver_factory.cpp#L192

Added line #L192 was not covered by tests
std::unique_ptr<SatcheckT>>::type
make_satcheck_prop(message_handlert &message_handler, const optionst &options)
{
auto satcheck = std::make_unique<SatcheckT>(message_handler);
if(options.is_set("write-solver-stats-to"))
{
if(
auto hardness_collector = dynamic_cast<hardness_collectort *>(&*satcheck))
{
std::unique_ptr<solver_hardnesst> solver_hardness =
std::make_unique<solver_hardnesst>();
solver_hardness->set_outfile(options.get_option("write-solver-stats-to"));
hardness_collector->solver_hardness = std::move(solver_hardness);
}
else
{
messaget log(message_handler);
log.warning()
<< "Configured solver does not support --write-solver-stats-to. "
<< "Solver stats will not be written." << messaget::eom;
}
messaget log(message_handler);
log.warning()

Check warning on line 200 in src/goto-checker/solver_factory.cpp

View check run for this annotation

Codecov / codecov/patch

src/goto-checker/solver_factory.cpp#L200

Added line #L200 was not covered by tests
<< "Configured solver does not support --write-solver-stats-to. "
<< "Solver stats will not be written." << messaget::eom;

Check warning on line 202 in src/goto-checker/solver_factory.cpp

View check run for this annotation

Codecov / codecov/patch

src/goto-checker/solver_factory.cpp#L202

Added line #L202 was not covered by tests
}
return satcheck;
}

template <typename SatcheckT>

Check warning on line 207 in src/goto-checker/solver_factory.cpp

View check run for this annotation

Codecov / codecov/patch

src/goto-checker/solver_factory.cpp#L207

Added line #L207 was not covered by tests
static typename std::enable_if<
std::is_base_of<hardness_collectort, SatcheckT>::value,
std::unique_ptr<SatcheckT>>::type

Check warning on line 210 in src/goto-checker/solver_factory.cpp

View check run for this annotation

Codecov / codecov/patch

src/goto-checker/solver_factory.cpp#L209-L210

Added lines #L209 - L210 were not covered by tests
make_satcheck_prop(message_handlert &message_handler, const optionst &options)
{
auto satcheck = std::make_unique<SatcheckT>(message_handler);
if(options.is_set("write-solver-stats-to"))
{
std::unique_ptr<solver_hardnesst> solver_hardness =
std::make_unique<solver_hardnesst>();

Check warning on line 217 in src/goto-checker/solver_factory.cpp

View check run for this annotation

Codecov / codecov/patch

src/goto-checker/solver_factory.cpp#L217

Added line #L217 was not covered by tests
solver_hardness->set_outfile(options.get_option("write-solver-stats-to"));
satcheck->solver_hardness = std::move(solver_hardness);
}
return satcheck;
}
Expand Down
Loading