Skip to content

Port of changes to test-gen-support to master (3) #1125

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
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c712ced
Get symbol of member expression
dcattaruzza Oct 25, 2016
9713c6a
Auxiliary function to check if the ssa has enough data to build an id…
dcattaruzza Oct 25, 2016
c6f1acd
Bitwise operators for mpinteger
dcattaruzza Oct 25, 2016
f4a468d
Auxiliary function to retrieve tail of trace and added dead command t…
dcattaruzza Oct 25, 2016
8d2615e
Fix arithmetic shift operators
smowton Jan 13, 2017
994e216
Added a new class for handling the internals
Jan 16, 2017
b0dba3e
Adding more symbols that should be excluded
Jan 16, 2017
3f8242e
Autocomplete script for bash
forejtv Jan 20, 2017
b28c418
Support for Java assume
cristina-david Feb 9, 2017
c5c017f
Regression tests for Java assume
cristina-david Feb 9, 2017
6385921
Remove assume as coverage target
cristina-david Sep 20, 2016
6a192f0
output covered lines as CSV in show_properties
Feb 1, 2017
2ae6b60
compress list of lines into line ranges
Feb 13, 2017
242c609
add regression test for coverage lines
Feb 15, 2017
ecd864a
fix problem with missing comma / range fix for reaching end
Feb 17, 2017
1cdbff4
Updated dump-C to use the new class
Jan 16, 2017
b1348d0
update interpreter
Mar 2, 2017
aa3a90f
Preprocessing of goto programs for string refinement
romainbrenguier Dec 31, 2016
0b41e8a
Moving is_java_string_type functions to string_preprocess
romainbrenguier Feb 17, 2017
95f0b6c
Moving refined_string_type to util
romainbrenguier Feb 24, 2017
d1d3251
Removed distinction between c string type and refined string type
romainbrenguier Feb 27, 2017
6278614
Removed mention of c string type
romainbrenguier Feb 27, 2017
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
1,402 changes: 1,402 additions & 0 deletions src/goto-programs/string_refine_preprocess.cpp

Large diffs are not rendered by default.

225 changes: 225 additions & 0 deletions src/goto-programs/string_refine_preprocess.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,225 @@
/*******************************************************************\

Module: Preprocess a goto-programs so that calls to the java String
library are recognized by the PASS algorithm

Author: Romain Brenguier

Date: September 2016

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

#ifndef CPROVER_GOTO_PROGRAMS_STRING_REFINE_PREPROCESS_H
#define CPROVER_GOTO_PROGRAMS_STRING_REFINE_PREPROCESS_H

#include <goto-programs/goto_model.h>
#include <util/ui_message.h>

class string_refine_preprocesst:public messaget
{
public:
string_refine_preprocesst(
symbol_tablet &, goto_functionst &, message_handlert &);

private:
namespacet ns;
symbol_tablet & symbol_table;
goto_functionst & goto_functions;

typedef std::unordered_map<irep_idt, irep_idt, irep_id_hash> id_mapt;
typedef std::unordered_map<exprt, exprt, irep_hash> expr_mapt;

// String builders maps the different names of a same StringBuilder object
// to a unique expression.
expr_mapt string_builders;

// Map name of Java string functions to there equivalent in the solver
id_mapt side_effect_functions;
id_mapt string_functions;
id_mapt c_string_functions;
id_mapt string_function_calls;
id_mapt string_of_char_array_functions;
id_mapt string_of_char_array_function_calls;
id_mapt side_effect_char_array_functions;

std::unordered_map<irep_idt, std::string, irep_id_hash> signatures;
expr_mapt hidden_strings;
expr_mapt java_to_cprover_strings;

// unique id for each newly created symbols
int next_symbol_id;

void initialize_string_function_table();

static bool is_java_string_pointer_type(const typet &type);

static bool is_java_string_type(const typet &type);

static bool is_java_string_builder_type(const typet &type);

static bool is_java_string_builder_pointer_type(const typet &type);

static bool is_java_char_sequence_type(const typet &type);

symbol_exprt fresh_array(
const typet &type, const source_locationt &location);
symbol_exprt fresh_string(
const typet &type, const source_locationt &location);

// get the data member of a java string
static exprt get_data(const exprt &string, const typet &data_type)
{
return member_exprt(string, "data", data_type);
}

// get the length member of a java string
exprt get_length(const exprt &string, const typet &length_type)
{
return member_exprt(string, "length", length_type);
}

// type of pointers to string
pointer_typet jls_ptr;
exprt replace_string(const exprt &in);
exprt replace_string_in_assign(const exprt &in);

void insert_assignments(
goto_programt &goto_program,
goto_programt::targett &target,
irep_idt function,
source_locationt location,
const std::list<code_assignt> &va);

exprt replace_string_pointer(const exprt &in);

// Replace string builders by expression of the mapping and make
// assignments for strings as string_exprt
exprt::operandst process_arguments(
goto_programt &goto_program,
goto_programt::targett &target,
const exprt::operandst &arguments,
const source_locationt &location,
const std::string &signature="");

// Signature of the named function if it is defined in the signature map,
// empty string otherwise
std::string function_signature(const irep_idt &function_id);

void declare_function(irep_idt function_name, const typet &type);

void get_data_and_length_type_of_string(
const exprt &expr, typet &data_type, typet &length_type);

function_application_exprt build_function_application(
const irep_idt &function_name,
const typet &type,
const source_locationt &location,
const exprt::operandst &arguments);

void make_normal_assign(
goto_programt &goto_program,
goto_programt::targett target,
const exprt &lhs,
const code_typet &function_type,
const irep_idt &function_name,
const exprt::operandst &arguments,
const source_locationt &location,
const std::string &signature="");

void make_string_assign(
goto_programt &goto_program,
goto_programt::targett &target,
const exprt &lhs,
const code_typet &function_type,
const irep_idt &function_name,
const exprt::operandst &arguments,
const source_locationt &location,
const std::string &signature);

void make_assign(
goto_programt &goto_program,
goto_programt::targett &target,
const exprt &lhs,
const code_typet &function_type,
const irep_idt &function_name,
const exprt::operandst &arg,
const source_locationt &loc,
const std::string &sig);

exprt make_cprover_string_assign(
goto_programt &goto_program,
goto_programt::targett &target,
const exprt &rhs,
const source_locationt &location);

void make_string_copy(
goto_programt &goto_program,
goto_programt::targett &target,
const exprt &lhs,
const exprt &argument,
const source_locationt &location);

void make_string_function(
goto_programt &goto_program,
goto_programt::targett &target,
const irep_idt &function_name,
const std::string &signature,
bool assign_first_arg=false,
bool skip_first_arg=false);

void make_string_function(
goto_programt &goto_program,
goto_programt::targett &target,
const exprt &lhs,
const code_typet &function_type,
const irep_idt &function_name,
const exprt::operandst &arguments,
const source_locationt &location,
const std::string &signature);

void make_string_function_call(
goto_programt &goto_program,
goto_programt::targett &target,
const irep_idt &function_name,
const std::string &signature);

void make_string_function_side_effect(
goto_programt &goto_program,
goto_programt::targett &target,
const irep_idt &function_name,
const std::string &signature);

void make_to_char_array_function(
goto_programt &goto_program, goto_programt::targett &);

exprt make_cprover_char_array_assign(
goto_programt &goto_program,
goto_programt::targett &target,
const exprt &rhs,
const source_locationt &location);

void make_char_array_function(
goto_programt &goto_program,
goto_programt::targett &target,
const irep_idt &function_name,
const std::string &signature,
std::size_t index,
bool assign_first_arg=false,
bool skip_first_arg=false);

void make_char_array_function_call(
goto_programt &goto_program,
goto_programt::targett &target,
const irep_idt &function_name,
const std::string &signature);

void make_char_array_side_effect(
goto_programt &goto_program,
goto_programt::targett &target,
const irep_idt &function_name,
const std::string &signature);

void replace_string_calls(goto_functionst::function_mapt::iterator f_it);
};

#endif
103 changes: 0 additions & 103 deletions src/solvers/refinement/refined_string_type.cpp

This file was deleted.

2 changes: 1 addition & 1 deletion src/solvers/refinement/string_constraint.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Author: Romain Brenguier, [email protected]

#include <langapi/language_ui.h>
#include <solvers/refinement/bv_refinement.h>
#include <solvers/refinement/refined_string_type.h>
#include <util/refined_string_type.h>

class string_constraintt: public exprt
{
Expand Down
2 changes: 1 addition & 1 deletion src/solvers/refinement/string_constraint_generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Author: Romain Brenguier, [email protected]
#define CPROVER_SOLVERS_REFINEMENT_STRING_CONSTRAINT_GENERATOR_H

#include <util/string_expr.h>
#include <solvers/refinement/refined_string_type.h>
#include <util/refined_string_type.h>
#include <solvers/refinement/string_constraint.h>

class string_constraint_generatort
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ string_exprt string_constraint_generatort::add_axioms_from_literal(
else
{
// Java string constant
assert(refined_string_typet::is_unrefined_string_type(arg.type()));
assert(arg.id()==ID_symbol);
const exprt &s=arg.op0();

// It seems the value of the string is lost,
Expand Down
20 changes: 12 additions & 8 deletions src/solvers/refinement/string_constraint_generator_indexof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,16 @@ exprt string_constraint_generatort::add_axioms_for_index_of(
else
assert(false);

if(refined_string_typet::is_java_string_pointer_type(c.type()))
if(c.type().id()==ID_unsignedbv)
{
return add_axioms_for_index_of(
str, typecast_exprt(c, ref_type.get_char_type()), from_index);
}
else
{
string_exprt sub=add_axioms_for_string_expr(c);
return add_axioms_for_index_of_string(str, sub, from_index);
}
else
return add_axioms_for_index_of(
str, typecast_exprt(c, ref_type.get_char_type()), from_index);
}

exprt string_constraint_generatort::add_axioms_for_last_index_of(
Expand Down Expand Up @@ -248,12 +250,14 @@ exprt string_constraint_generatort::add_axioms_for_last_index_of(
else
assert(false);

if(refined_string_typet::is_java_string_pointer_type(c.type()))
if(c.type().id()==ID_unsignedbv)
{
return add_axioms_for_last_index_of(
str, typecast_exprt(c, ref_type.get_char_type()), from_index);
}
else
{
string_exprt sub=add_axioms_for_string_expr(c);
return add_axioms_for_last_index_of_string(str, sub, from_index);
}
else
return add_axioms_for_last_index_of(
str, typecast_exprt(c, ref_type.get_char_type()), from_index);
}
Loading