STPSolverImpl::STPSolverImpl(bool _useForkedSTP, bool _optimizeDivides) : vc(vc_createValidityChecker()), builder(new STPBuilder(vc, _optimizeDivides)), timeout(0.0), useForkedSTP(_useForkedSTP), runStatusCode(SOLVER_RUN_STATUS_FAILURE) { assert(vc && "unable to create validity checker"); assert(builder && "unable to create STPBuilder"); // In newer versions of STP, a memory management mechanism has been // introduced that automatically invalidates certain C interface // pointers at vc_Destroy time. This caused double-free errors // due to the ExprHandle destructor also attempting to invalidate // the pointers using vc_DeleteExpr. By setting EXPRDELETE to 0 // we restore the old behaviour. vc_setInterfaceFlags(vc, EXPRDELETE, 0); make_division_total(vc); vc_registerErrorHandler(::stp_error_handler); if (useForkedSTP) { assert(shared_memory_id == 0 && "shared memory id already allocated"); shared_memory_id = shmget(IPC_PRIVATE, shared_memory_size, IPC_CREAT | 0700); if (shared_memory_id < 0) llvm::report_fatal_error("unable to allocate shared memory region"); shared_memory_ptr = (unsigned char *)shmat(shared_memory_id, NULL, 0); if (shared_memory_ptr == (void *)-1) llvm::report_fatal_error("unable to attach shared memory region"); shmctl(shared_memory_id, IPC_RMID, NULL); } }
void go (enum ifaceflag_t f) { VC vc; vc = vc_createValidityChecker (); vc_setInterfaceFlags(vc, f, 0); //vc_setFlags(vc,'s',0); // CVC_FILE is a macro that expands to a file path vc_parseExpr(vc, CVC_FILE); Expr a = vc_varExpr(vc, "a", vc_bvType(vc, 8)); Expr ct_0 = vc_bvConstExprFromInt(vc, 8, 0); Expr a_eq_0 = vc_eqExpr(vc, a, ct_0); int query = vc_query(vc, a_eq_0); vc_Destroy (vc); ASSERT_TRUE(false && "FIXME: Actually test something"); }