From 3ae967137fc715ff4ae5109895771fd1ca0724e4 Mon Sep 17 00:00:00 2001 From: "Hoang M. Le" Date: Wed, 15 Mar 2017 13:21:44 +0100 Subject: replace handleMetaSMT() with klee::createMetaSMTSolver() and move it into MetaSMTSolver.cpp so that the backend headers only need to be included once there --- lib/Solver/CoreSolver.cpp | 48 +------------------------------------------- lib/Solver/MetaSMTSolver.cpp | 33 ++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 47 deletions(-) (limited to 'lib/Solver') diff --git a/lib/Solver/CoreSolver.cpp b/lib/Solver/CoreSolver.cpp index d36a3219..72b82807 100644 --- a/lib/Solver/CoreSolver.cpp +++ b/lib/Solver/CoreSolver.cpp @@ -14,52 +14,6 @@ #include "llvm/Support/raw_ostream.h" #include -#ifdef ENABLE_METASMT - -#include -#include -#include - -#define Expr VCExpr -#define Type VCType -#define STP STP_Backend -#include -#undef Expr -#undef Type -#undef STP - -using namespace klee; -using namespace metaSMT; -using namespace metaSMT::solver; - -static klee::Solver *handleMetaSMT() { - Solver *coreSolver = NULL; - std::string backend; - switch (MetaSMTBackend) { - case METASMT_BACKEND_STP: - backend = "STP"; - coreSolver = new MetaSMTSolver >( - UseForkedCoreSolver, CoreSolverOptimizeDivides); - break; - case METASMT_BACKEND_Z3: - backend = "Z3"; - coreSolver = new MetaSMTSolver >( - UseForkedCoreSolver, CoreSolverOptimizeDivides); - break; - case METASMT_BACKEND_BOOLECTOR: - backend = "Boolector"; - coreSolver = new MetaSMTSolver >( - UseForkedCoreSolver, CoreSolverOptimizeDivides); - break; - default: - llvm_unreachable("Unrecognised MetaSMT backend"); - break; - }; - klee_message("Starting MetaSMTSolver(%s)", backend.c_str()); - return coreSolver; -} -#endif /* ENABLE_METASMT */ - namespace klee { Solver *createCoreSolver(CoreSolverType cst) { @@ -75,7 +29,7 @@ Solver *createCoreSolver(CoreSolverType cst) { case METASMT_SOLVER: #ifdef ENABLE_METASMT klee_message("Using MetaSMT solver backend"); - return handleMetaSMT(); + return createMetaSMTSolver(); #else klee_message("Not compiled with MetaSMT support"); return NULL; diff --git a/lib/Solver/MetaSMTSolver.cpp b/lib/Solver/MetaSMTSolver.cpp index a453de40..3b3eaf35 100644 --- a/lib/Solver/MetaSMTSolver.cpp +++ b/lib/Solver/MetaSMTSolver.cpp @@ -17,6 +17,8 @@ #include "klee/util/Assignment.h" #include "klee/util/ExprUtil.h" +#include "llvm/Support/ErrorHandling.h" + #include #include #include @@ -405,5 +407,36 @@ void MetaSMTSolver::setCoreSolverTimeout(double timeout) { template class MetaSMTSolver >; template class MetaSMTSolver >; template class MetaSMTSolver >; + +Solver *createMetaSMTSolver() { + using metaSMT::DirectSolver_Context; + using namespace metaSMT::solver; + + Solver *coreSolver = NULL; + std::string backend; + switch (MetaSMTBackend) { + case METASMT_BACKEND_STP: + backend = "STP"; + coreSolver = new MetaSMTSolver >( + UseForkedCoreSolver, CoreSolverOptimizeDivides); + break; + case METASMT_BACKEND_Z3: + backend = "Z3"; + coreSolver = new MetaSMTSolver >( + UseForkedCoreSolver, CoreSolverOptimizeDivides); + break; + case METASMT_BACKEND_BOOLECTOR: + backend = "Boolector"; + coreSolver = new MetaSMTSolver >( + UseForkedCoreSolver, CoreSolverOptimizeDivides); + break; + default: + llvm_unreachable("Unrecognised MetaSMT backend"); + break; + }; + klee_message("Starting MetaSMTSolver(%s)", backend.c_str()); + return coreSolver; +} + } #endif // ENABLE_METASMT -- cgit 1.4.1