Skip to content

Commit 2b34b4e

Browse files
romainbrenguiertautschnig
authored andcommitted
Adding the string refinement option to the CBMC solvers
We add the option `--string-refine` which can be used to activate the string solver, in order to deal precisely with string functions.
1 parent 1eee909 commit 2b34b4e

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

src/cbmc/cbmc_parse_options.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Author: Daniel Kroening, [email protected]
2424
#include <ansi-c/c_preprocess.h>
2525

2626
#include <goto-programs/goto_convert_functions.h>
27+
#include <goto-programs/string_refine_preprocess.h>
2728
#include <goto-programs/remove_function_pointers.h>
2829
#include <goto-programs/remove_virtual_functions.h>
2930
#include <goto-programs/remove_instanceof.h>
@@ -288,6 +289,11 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
288289
options.set_option("refine-arithmetic", true);
289290
}
290291

292+
if(cmdline.isset("string-refine"))
293+
{
294+
options.set_option("string-refine", true);
295+
}
296+
291297
if(cmdline.isset("max-node-refinement"))
292298
options.set_option(
293299
"max-node-refinement",
@@ -811,6 +817,14 @@ bool cbmc_parse_optionst::process_goto_program(
811817
status() << "Partial Inlining" << eom;
812818
goto_partial_inline(goto_functions, ns, ui_message_handler);
813819

820+
821+
if(cmdline.isset("string-refine"))
822+
{
823+
status() << "Preprocessing for string refinement" << eom;
824+
string_refine_preprocesst(
825+
symbol_table, goto_functions, ui_message_handler);
826+
}
827+
814828
// remove returns, gcc vectors, complex
815829
remove_returns(symbol_table, goto_functions);
816830
remove_vector(symbol_table, goto_functions);
@@ -1070,6 +1084,7 @@ void cbmc_parse_optionst::help()
10701084
" --yices use Yices\n"
10711085
" --z3 use Z3\n"
10721086
" --refine use refinement procedure (experimental)\n"
1087+
" --string-refine use string refinement (experimental)\n"
10731088
" --outfile filename output formula to given file\n"
10741089
" --arrays-uf-never never turn arrays into uninterpreted functions\n" // NOLINT(*)
10751090
" --arrays-uf-always always turn arrays into uninterpreted functions\n" // NOLINT(*)

src/cbmc/cbmc_parse_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class optionst;
4141
"(no-sat-preprocessor)" \
4242
"(no-pretty-names)(beautify)" \
4343
"(dimacs)(refine)(max-node-refinement):(refine-arrays)(refine-arithmetic)"\
44+
"(string-refine)" \
4445
"(aig)(16)(32)(64)(LP64)(ILP64)(LLP64)(ILP32)(LP32)" \
4546
"(little-endian)(big-endian)" \
4647
"(show-goto-functions)(show-loops)" \

src/cbmc/cbmc_solvers.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Author: Daniel Kroening, [email protected]
1717

1818
#include <solvers/sat/satcheck.h>
1919
#include <solvers/refinement/bv_refinement.h>
20+
#include <solvers/refinement/string_refinement.h>
2021
#include <solvers/smt1/smt1_dec.h>
2122
#include <solvers/smt2/smt2_dec.h>
2223
#include <solvers/cvc/cvc_dec.h>

src/cbmc/cbmc_solvers.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,17 @@ class cbmc_solverst:public messaget
108108
solvert *solver;
109109

110110
if(options.get_bool_option("dimacs"))
111-
solver = get_dimacs();
111+
solver=get_dimacs();
112112
else if(options.get_bool_option("refine"))
113-
solver = get_bv_refinement();
113+
solver=get_bv_refinement();
114+
else if(options.get_bool_option("string-refine"))
115+
solver=get_string_refinement();
114116
else if(options.get_bool_option("smt1"))
115-
solver = get_smt1(get_smt1_solver_type());
117+
solver=get_smt1(get_smt1_solver_type());
116118
else if(options.get_bool_option("smt2"))
117-
solver = get_smt2(get_smt2_solver_type());
119+
solver=get_smt2(get_smt2_solver_type());
118120
else
119-
solver = get_default();
121+
solver=get_default();
120122

121123
return std::unique_ptr<solvert>(solver);
122124
}
@@ -138,6 +140,7 @@ class cbmc_solverst:public messaget
138140
solvert *get_default();
139141
solvert *get_dimacs();
140142
solvert *get_bv_refinement();
143+
solvert *get_string_refinement();
141144
solvert *get_smt1(smt1_dect::solvert solver);
142145
solvert *get_smt2(smt2_dect::solvert solver);
143146

0 commit comments

Comments
 (0)