Skip to content

Commit 76cbf3e

Browse files
committed
move solver_hardness.* from solvers/ to goto-symex/
This class is inherently linked to goto-programs and goto-symex, and introduces a surprising dependency on these corresponding includes into the solver classes. This commit moves these classes into the goto-symex directory, removing the dependency by introducing a base class for the callback.
1 parent 9b72a5c commit 76cbf3e

30 files changed

+102
-129
lines changed

src/goto-checker/multi_path_symex_checker.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Author: Daniel Kroening, Peter Schrammel
1515

1616
#include <util/ui_message.h>
1717

18-
#include <solvers/hardness_collector.h>
18+
#include <goto-symex/solver_hardness.h>
1919

2020
#include "bmc_util.h"
2121
#include "counterexample_beautification.h"

src/goto-checker/solver_factory.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ Author: Daniel Kroening, Peter Schrammel
3636
#include <solvers/smt2_incremental/smt_solver_process.h>
3737
#include <solvers/strings/string_refinement.h>
3838

39+
#include <goto-symex/solver_hardness.h>
40+
3941
solver_factoryt::solver_factoryt(
4042
const optionst &_options,
4143
const namespacet &_ns,
@@ -190,11 +192,10 @@ make_satcheck_prop(message_handlert &message_handler, const optionst &options)
190192
if(
191193
auto hardness_collector = dynamic_cast<hardness_collectort *>(&*satcheck))
192194
{
193-
hardness_collector->enable_hardness_collection();
194-
hardness_collector->with_solver_hardness(
195-
[&options](solver_hardnesst &hardness) {
196-
hardness.set_outfile(options.get_option("write-solver-stats-to"));
197-
});
195+
std::unique_ptr<solver_hardnesst> solver_hardness =
196+
util_make_unique<solver_hardnesst>();
197+
solver_hardness->set_outfile(options.get_option("write-solver-stats-to"));
198+
hardness_collector->solver_hardness = std::move(solver_hardness);
198199
}
199200
else
200201
{

src/goto-symex/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ SRC = auto_objects.cpp \
1717
show_program.cpp \
1818
show_vcc.cpp \
1919
slice.cpp \
20+
solver_hardness.cpp \
2021
ssa_step.cpp \
2122
symex_assign.cpp \
2223
symex_atomic_section.cpp \
Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ Author: Diffblue Ltd.
99
#ifndef CPROVER_SOLVERS_SOLVER_HARDNESS_H
1010
#define CPROVER_SOLVERS_SOLVER_HARDNESS_H
1111

12-
#include <solvers/prop/literal.h>
12+
#include <solvers/hardness_collector.h>
13+
#include <solvers/prop/prop_conv_solver.h>
1314

1415
#include <fstream>
1516
#include <string>
@@ -38,7 +39,7 @@ Author: Diffblue Ltd.
3839
/// derived class of \ref cnft for SAT solving). For this purpose the object
3940
/// lives in the \ref solver_factoryt::solvert and pointers are passed to both
4041
/// \ref decision_proceduret and \ref propt.
41-
struct solver_hardnesst
42+
struct solver_hardnesst : public clause_hardness_collectort
4243
{
4344
// From SAT solver we collect the number of clauses, the number of literals
4445
// and the number of distinct variables that were used in all clauses.
@@ -160,4 +161,26 @@ struct hash<solver_hardnesst::hardness_ssa_keyt>
160161
};
161162
} // namespace std
162163

164+
static inline void with_solver_hardness(
165+
decision_proceduret &maybe_hardness_collector,
166+
std::function<void(solver_hardnesst &hardness)> handler)
167+
{
168+
// FIXME I am wondering if there is a way to do this that is a bit less
169+
// dynamically typed.
170+
if(
171+
auto prop_conv_solver =
172+
dynamic_cast<prop_conv_solvert *>(&maybe_hardness_collector))
173+
{
174+
if(auto hardness_collector = prop_conv_solver->get_hardness_collector())
175+
{
176+
if(hardness_collector->solver_hardness)
177+
{
178+
auto &solver_hardness = static_cast<solver_hardnesst &>(
179+
*(hardness_collector->solver_hardness));
180+
handler(solver_hardness);
181+
}
182+
}
183+
}
184+
}
185+
163186
#endif // CPROVER_SOLVERS_SOLVER_HARDNESS_H

src/goto-symex/symex_target_equation.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ Author: Daniel Kroening, kroening@kroening.com
1616

1717
#include <util/std_expr.h>
1818

19-
#include <solvers/decision_procedure.h>
20-
#include <solvers/hardness_collector.h>
21-
19+
#include "solver_hardness.h"
2220
#include "ssa_step.h"
2321

24-
static hardness_collectort::handlert
22+
static std::function<void(solver_hardnesst &)>
2523
hardness_register_ssa(std::size_t step_index, const SSA_stept &step)
2624
{
2725
return [step_index, &step](solver_hardnesst &hardness) {

src/solvers/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ SRC = $(BOOLEFORCE_SRC) \
8080
$(SQUOLEM2_SRC) \
8181
$(CADICAL_SRC) \
8282
decision_procedure.cpp \
83-
solver_hardness.cpp \
8483
flattening/arrays.cpp \
8584
flattening/boolbv.cpp \
8685
flattening/boolbv_abs.cpp \

src/solvers/flattening/arrays.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ Author: Daniel Kroening, kroening@kroening.com
2020

2121
#include "equality.h"
2222

23+
class array_comprehension_exprt;
24+
class array_exprt;
2325
class array_of_exprt;
2426
class equal_exprt;
2527
class if_exprt;

src/solvers/flattening/boolbv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class floatbv_typecast_exprt;
3737
class ieee_float_op_exprt;
3838
class member_exprt;
3939
class replication_exprt;
40+
class union_typet;
4041

4142
class boolbvt:public arrayst
4243
{

src/solvers/flattening/boolbv_get.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Author: Daniel Kroening, kroening@kroening.com
1010

1111
#include <util/arith_tools.h>
1212
#include <util/c_types.h>
13+
#include <util/namespace.h>
1314
#include <util/simplify_expr.h>
1415
#include <util/std_expr.h>
1516
#include <util/threeval.h>

0 commit comments

Comments
 (0)