Skip to content

Commit 3eeb73d

Browse files
Merge pull request #676 from allredj/testgen-string-refine-option
String refine option
2 parents a11a70b + 9d2a115 commit 3eeb73d

File tree

8 files changed

+67
-8
lines changed

8 files changed

+67
-8
lines changed

src/cbmc/cbmc_parse_options.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Author: Daniel Kroening, [email protected]
2020
#include <ansi-c/c_preprocess.h>
2121

2222
#include <goto-programs/goto_convert_functions.h>
23+
#include <goto-programs/string_refine_preprocess.h>
2324
#include <goto-programs/remove_function_pointers.h>
2425
#include <goto-programs/remove_virtual_functions.h>
2526
#include <goto-programs/remove_instanceof.h>
@@ -310,6 +311,11 @@ void cbmc_parse_optionst::get_command_line_options(optionst &options)
310311
options.set_option("refine-arithmetic", true);
311312
}
312313

314+
if(cmdline.isset("refine-strings"))
315+
{
316+
options.set_option("refine-strings", true);
317+
}
318+
313319
if(cmdline.isset("max-node-refinement"))
314320
options.set_option(
315321
"max-node-refinement",
@@ -904,6 +910,14 @@ bool cbmc_parse_optionst::process_goto_program(
904910
status() << "Partial Inlining" << eom;
905911
goto_partial_inline(goto_functions, ns, ui_message_handler);
906912

913+
914+
if(cmdline.isset("refine-strings"))
915+
{
916+
status() << "Preprocessing for string refinement" << eom;
917+
string_refine_preprocesst(
918+
symbol_table, goto_functions, ui_message_handler);
919+
}
920+
907921
// remove returns, gcc vectors, complex
908922
remove_returns(symbol_table, goto_functions);
909923
remove_vector(symbol_table, goto_functions);
@@ -1191,6 +1205,7 @@ void cbmc_parse_optionst::help()
11911205
" --yices use Yices\n"
11921206
" --z3 use Z3\n"
11931207
" --refine use refinement procedure (experimental)\n"
1208+
" --refine-strings use string refinement (experimental)\n"
11941209
" --outfile filename output formula to given file\n"
11951210
" --arrays-uf-never never turn arrays into uninterpreted functions\n" // NOLINT(*)
11961211
" --arrays-uf-always always turn arrays into uninterpreted functions\n" // NOLINT(*)

src/cbmc/cbmc_parse_options.h

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class optionst;
3737
"(no-sat-preprocessor)" \
3838
"(no-pretty-names)(beautify)" \
3939
"(dimacs)(refine)(max-node-refinement):(refine-arrays)(refine-arithmetic)"\
40+
"(refine-strings)" \
4041
"(aig)(16)(32)(64)(LP64)(ILP64)(LLP64)(ILP32)(LP32)" \
4142
"(little-endian)(big-endian)" \
4243
"(show-goto-functions)(show-loops)" \

src/cbmc/cbmc_solvers.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Author: Daniel Kroening, [email protected]
1414

1515
#include <solvers/sat/satcheck.h>
1616
#include <solvers/refinement/bv_refinement.h>
17+
#include <solvers/refinement/string_refinement.h>
1718
#include <solvers/smt1/smt1_dec.h>
1819
#include <solvers/smt2/smt2_dec.h>
1920
#include <solvers/cvc/cvc_dec.h>
@@ -213,6 +214,29 @@ cbmc_solverst::solvert* cbmc_solverst::get_bv_refinement()
213214

214215
/*******************************************************************\
215216
217+
Function: cbmc_solverst::get_string_refinement
218+
219+
Outputs: a solver for cbmc
220+
221+
Purpose: the string refinement adds to the bit vector refinement
222+
specifications for functions from the Java string library
223+
224+
\*******************************************************************/
225+
226+
cbmc_solverst::solvert* cbmc_solverst::get_string_refinement()
227+
{
228+
propt *prop;
229+
prop=new satcheck_no_simplifiert();
230+
prop->set_message_handler(get_message_handler());
231+
232+
string_refinementt *string_refinement=new string_refinementt(
233+
ns, *prop, MAX_NB_REFINEMENT);
234+
string_refinement->set_ui(ui);
235+
return new solvert(string_refinement, prop);
236+
}
237+
238+
/*******************************************************************\
239+
216240
Function: cbmc_solverst::get_smt1
217241
218242
Inputs:

src/cbmc/cbmc_solvers.h

+8-5
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,17 @@ class cbmc_solverst:public messaget
111111
solvert *solver;
112112

113113
if(options.get_bool_option("dimacs"))
114-
solver = get_dimacs();
114+
solver=get_dimacs();
115115
else if(options.get_bool_option("refine"))
116-
solver = get_bv_refinement();
116+
solver=get_bv_refinement();
117+
else if(options.get_bool_option("refine-strings"))
118+
solver=get_string_refinement();
117119
else if(options.get_bool_option("smt1"))
118-
solver = get_smt1(get_smt1_solver_type());
120+
solver=get_smt1(get_smt1_solver_type());
119121
else if(options.get_bool_option("smt2"))
120-
solver = get_smt2(get_smt2_solver_type());
122+
solver=get_smt2(get_smt2_solver_type());
121123
else
122-
solver = get_default();
124+
solver=get_default();
123125

124126
return std::unique_ptr<solvert>(solver);
125127
}
@@ -141,6 +143,7 @@ class cbmc_solverst:public messaget
141143
solvert *get_default();
142144
solvert *get_dimacs();
143145
solvert *get_bv_refinement();
146+
solvert *get_string_refinement();
144147
solvert *get_smt1(smt1_dect::solvert solver);
145148
solvert *get_smt2(smt2_dect::solvert solver);
146149

src/goto-programs/Makefile

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ SRC = goto_convert.cpp goto_convert_function_call.cpp \
2424
remove_instanceof.cpp \
2525
class_identifier.cpp \
2626
system_library_symbols.cpp \
27-
27+
string_refine_preprocess.cpp \
28+
# Empty last line
2829

2930
INCLUDES= -I ..
3031

src/java_bytecode/java_bytecode_language.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void java_bytecode_languaget::get_language_options(const cmdlinet &cmd)
4444
{
4545
disable_runtime_checks=cmd.isset("disable-runtime-check");
4646
assume_inputs_non_null=cmd.isset("java-assume-inputs-non-null");
47-
string_refinement_enabled=cmd.isset("string-refine");
47+
string_refinement_enabled=cmd.isset("refine-strings");
4848
if(cmd.isset("java-max-input-array-length"))
4949
max_nondet_array_length=
5050
std::stoi(cmd.get_value("java-max-input-array-length"));

src/solvers/Makefile

+11
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,17 @@ SRC = $(CHAFF_SRC) $(BOOLEFORCE_SRC) $(MINISAT_SRC) $(MINISAT2_SRC) \
118118
floatbv/float_utils.cpp floatbv/float_bv.cpp \
119119
refinement/bv_refinement_loop.cpp refinement/refine_arithmetic.cpp \
120120
refinement/refine_arrays.cpp \
121+
refinement/string_refinement.cpp \
122+
refinement/string_constraint_generator_code_points.cpp \
123+
refinement/string_constraint_generator_comparison.cpp \
124+
refinement/string_constraint_generator_concat.cpp \
125+
refinement/string_constraint_generator_constants.cpp \
126+
refinement/string_constraint_generator_indexof.cpp \
127+
refinement/string_constraint_generator_insert.cpp \
128+
refinement/string_constraint_generator_main.cpp \
129+
refinement/string_constraint_generator_testing.cpp \
130+
refinement/string_constraint_generator_transformation.cpp \
131+
refinement/string_constraint_generator_valueof.cpp \
121132
miniBDD/miniBDD.cpp
122133

123134
INCLUDES += -I .. \

src/util/Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ SRC = arith_tools.cpp base_type.cpp cmdline.cpp config.cpp symbol_table.cpp \
2323
memory_info.cpp pipe_stream.cpp irep_hash.cpp endianness_map.cpp \
2424
ssa_expr.cpp json_irep.cpp json_expr.cpp \
2525
fresh_symbol.cpp \
26-
format_number_range.cpp string_utils.cpp nondet_ifthenelse.cpp
26+
format_number_range.cpp \
27+
nondet_ifthenelse.cpp \
28+
string_utils.cpp \
29+
refined_string_type.cpp \
30+
#Empty last line
2731

2832
INCLUDES= -I ..
2933

0 commit comments

Comments
 (0)