Skip to content

String refine option #429

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

Closed
Closed
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions src/cbmc/cbmc_parse_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Author: Daniel Kroening, [email protected]
#include <ansi-c/c_preprocess.h>

#include <goto-programs/goto_convert_functions.h>
#include <goto-programs/string_refine_preprocess.h>
#include <goto-programs/remove_function_pointers.h>
#include <goto-programs/remove_virtual_functions.h>
#include <goto-programs/remove_instanceof.h>
Expand Down Expand Up @@ -310,6 +311,11 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
options.set_option("refine-arithmetic", true);
}

if(cmdline.isset("refine-strings"))
{
options.set_option("refine-strings", true);
}

if(cmdline.isset("max-node-refinement"))
options.set_option(
"max-node-refinement",
Expand Down Expand Up @@ -904,6 +910,14 @@ bool cbmc_parse_optionst::process_goto_program(
status() << "Partial Inlining" << eom;
goto_partial_inline(goto_functions, ns, ui_message_handler);


if(cmdline.isset("refine-strings"))
{
status() << "Preprocessing for string refinement" << eom;
string_refine_preprocesst(
symbol_table, goto_functions, ui_message_handler);
}

// remove returns, gcc vectors, complex
remove_returns(symbol_table, goto_functions);
remove_vector(symbol_table, goto_functions);
Expand Down Expand Up @@ -1191,6 +1205,7 @@ void cbmc_parse_optionst::help()
" --yices use Yices\n"
" --z3 use Z3\n"
" --refine use refinement procedure (experimental)\n"
" --refine-strings use string refinement (experimental)\n"
" --outfile filename output formula to given file\n"
" --arrays-uf-never never turn arrays into uninterpreted functions\n" // NOLINT(*)
" --arrays-uf-always always turn arrays into uninterpreted functions\n" // NOLINT(*)
Expand Down
1 change: 1 addition & 0 deletions src/cbmc/cbmc_parse_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class optionst;
"(no-sat-preprocessor)" \
"(no-pretty-names)(beautify)" \
"(dimacs)(refine)(max-node-refinement):(refine-arrays)(refine-arithmetic)"\
"(refine-strings)" \
"(aig)(16)(32)(64)(LP64)(ILP64)(LLP64)(ILP32)(LP32)" \
"(little-endian)(big-endian)" \
"(show-goto-functions)(show-loops)" \
Expand Down
24 changes: 24 additions & 0 deletions src/cbmc/cbmc_solvers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Author: Daniel Kroening, [email protected]

#include <solvers/sat/satcheck.h>
#include <solvers/refinement/bv_refinement.h>
#include <solvers/refinement/string_refinement.h>
#include <solvers/smt1/smt1_dec.h>
#include <solvers/smt2/smt2_dec.h>
#include <solvers/cvc/cvc_dec.h>
Expand Down Expand Up @@ -213,6 +214,29 @@ cbmc_solverst::solvert* cbmc_solverst::get_bv_refinement()

/*******************************************************************\

Function: cbmc_solverst::get_string_refinement

Outputs: a solver for cbmc

Purpose: the string refinement adds to the bit vector refinement
specifications for functions from the Java string library

\*******************************************************************/

cbmc_solverst::solvert* cbmc_solverst::get_string_refinement()
{
propt *prop;
prop=new satcheck_no_simplifiert();
prop->set_message_handler(get_message_handler());

string_refinementt *string_refinement=new string_refinementt(
ns, *prop, MAX_NB_REFINEMENT);
string_refinement->set_ui(ui);
return new solvert(string_refinement, prop);
}

/*******************************************************************\

Function: cbmc_solverst::get_smt1

Inputs:
Expand Down
13 changes: 8 additions & 5 deletions src/cbmc/cbmc_solvers.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,17 @@ class cbmc_solverst:public messaget
solvert *solver;

if(options.get_bool_option("dimacs"))
solver = get_dimacs();
solver=get_dimacs();
else if(options.get_bool_option("refine"))
solver = get_bv_refinement();
solver=get_bv_refinement();
else if(options.get_bool_option("refine-strings"))
solver=get_string_refinement();
else if(options.get_bool_option("smt1"))
solver = get_smt1(get_smt1_solver_type());
solver=get_smt1(get_smt1_solver_type());
else if(options.get_bool_option("smt2"))
solver = get_smt2(get_smt2_solver_type());
solver=get_smt2(get_smt2_solver_type());
else
solver = get_default();
solver=get_default();

return std::unique_ptr<solvert>(solver);
}
Expand All @@ -141,6 +143,7 @@ class cbmc_solverst:public messaget
solvert *get_default();
solvert *get_dimacs();
solvert *get_bv_refinement();
solvert *get_string_refinement();
solvert *get_smt1(smt1_dect::solvert solver);
solvert *get_smt2(smt2_dect::solvert solver);

Expand Down
3 changes: 2 additions & 1 deletion src/goto-programs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ SRC = goto_convert.cpp goto_convert_function_call.cpp \
slice_global_inits.cpp goto_inline_class.cpp class_identifier.cpp \
show_goto_functions_json.cpp \
show_goto_functions_xml.cpp \
remove_static_init_loops.cpp remove_instanceof.cpp
remove_static_init_loops.cpp remove_instanceof.cpp \
string_refine_preprocess.cpp

INCLUDES= -I ..

Expand Down
Loading