Skip to content

Commit 28de886

Browse files
Joel Allredromainbrenguier
authored andcommitted
Linting corrections on /goto-programs/
1 parent 4e3f0dc commit 28de886

File tree

1 file changed

+42
-68
lines changed

1 file changed

+42
-68
lines changed

src/goto-programs/string_refine_preprocess.cpp

Lines changed: 42 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,7 @@ void string_refine_preprocesst::get_data_and_length_type_of_string(
326326
{
327327
assert(is_java_string_type(expr.type()) ||
328328
is_java_string_builder_type(expr.type()) ||
329-
is_java_char_sequence_type(expr.type())
330-
);
329+
is_java_char_sequence_type(expr.type()));
331330
typet object_type=ns.follow(expr.type());
332331
assert(object_type.id()==ID_struct);
333332
const struct_typet &struct_type=to_struct_type(object_type);
@@ -361,56 +360,42 @@ exprt string_refine_preprocesst::make_cprover_string_assign(
361360
{
362361
if(implements_java_char_sequence(rhs.type()))
363362
{
364-
#if 0
365-
auto pair=java_to_cprover_strings.insert(
366-
std::make_pair(rhs, nil_exprt()));
363+
// We do the following assignments:
364+
// 1 cprover_string_length= *(rhs->length)
365+
// 2 cprover_string_array = *(rhs->data)
366+
// 3 cprover_string = { cprover_string_length; cprover_string_array }
367+
368+
dereference_exprt deref(rhs, rhs.type().subtype());
369+
typet data_type, length_type;
370+
get_data_and_length_type_of_string(deref, data_type, length_type);
371+
std::list<code_assignt> assignments;
367372

368-
if(pair.second)
369-
{
370-
#endif
371-
// We do the following assignments:
372-
// 1 cprover_string_length= *(rhs->length)
373-
// 2 cprover_string_array = *(rhs->data)
374-
// 3 cprover_string = { cprover_string_length; cprover_string_array }
375-
376-
dereference_exprt deref(rhs, rhs.type().subtype());
377-
typet data_type, length_type;
378-
get_data_and_length_type_of_string(deref, data_type, length_type);
379-
std::list<code_assignt> assignments;
380-
381-
// 1) cprover_string_length= *(rhs->length)
382-
symbol_exprt length_lhs=new_symbol(
383-
"cprover_string_length", length_type);
384-
385-
member_exprt deref_length(deref, "length", length_type);
386-
assignments.emplace_back(length_lhs, deref_length);
387-
388-
// 2) cprover_string_array = *(rhs->data)
389-
symbol_exprt array_lhs=new_symbol(
390-
"cprover_string_array", data_type.subtype());
391-
member_exprt data(deref, "data", data_type);
392-
dereference_exprt deref_data(data, data_type.subtype());
393-
assignments.emplace_back(array_lhs, deref_data);
394-
395-
// 3) cprover_string = { cprover_string_length; cprover_string_array }
396-
// This assignment is useful for finding witnessing strings for counter
397-
// examples
398-
refined_string_typet ref_type(length_type, java_char_type());
399-
string_exprt new_rhs(length_lhs, array_lhs, ref_type);
400-
401-
symbol_exprt lhs=new_symbol("cprover_string", new_rhs.type());
402-
assignments.emplace_back(lhs, new_rhs);
403-
404-
insert_assignments(goto_program, i_it, assignments);
405-
i_it=goto_program.insert_after(i_it);
406-
return new_rhs;
407-
408-
#if 0
409-
//pair.first->second=lhs;
410-
pair.first->second=new_rhs;
411-
}
412-
return pair.first->second;
413-
#endif
373+
// 1) cprover_string_length= *(rhs->length)
374+
symbol_exprt length_lhs=new_symbol(
375+
"cprover_string_length", length_type);
376+
377+
member_exprt deref_length(deref, "length", length_type);
378+
assignments.emplace_back(length_lhs, deref_length);
379+
380+
// 2) cprover_string_array = *(rhs->data)
381+
symbol_exprt array_lhs=new_symbol(
382+
"cprover_string_array", data_type.subtype());
383+
member_exprt data(deref, "data", data_type);
384+
dereference_exprt deref_data(data, data_type.subtype());
385+
assignments.emplace_back(array_lhs, deref_data);
386+
387+
// 3) cprover_string = { cprover_string_length; cprover_string_array }
388+
// This assignment is useful for finding witnessing strings for counter
389+
// examples
390+
refined_string_typet ref_type(length_type, java_char_type());
391+
string_exprt new_rhs(length_lhs, array_lhs, ref_type);
392+
393+
symbol_exprt lhs=new_symbol("cprover_string", new_rhs.type());
394+
assignments.emplace_back(lhs, new_rhs);
395+
396+
insert_assignments(goto_program, i_it, assignments);
397+
i_it=goto_program.insert_after(i_it);
398+
return new_rhs;
414399
}
415400
else if(rhs.id()==ID_typecast &&
416401
implements_java_char_sequence(rhs.op0().type()))
@@ -560,10 +545,8 @@ void string_refine_preprocesst::make_string_assign(
560545
// Adding a string expr in the map
561546
refined_string_typet ref_type(length_type, data_type.subtype().subtype());
562547
string_exprt str(tmp_length, tmp_array, ref_type);
563-
symbol_exprt cprover_string_sym=new_tmp_symbol("tmp_cprover_string", ref_type);
564-
#if 0
565-
java_to_cprover_strings[lhs]=cprover_string_sym;
566-
#endif
548+
symbol_exprt cprover_string_sym=new_tmp_symbol("tmp_cprover_string",
549+
ref_type);
567550

568551
std::list<code_assignt> assigns;
569552
assigns.emplace_back(lhs, malloc_expr);
@@ -838,7 +821,7 @@ void string_refine_preprocesst::make_string_function_side_effect(
838821
const std::string &signature)
839822
{
840823
const code_function_callt &function_call=to_code_function_call(i_it->code);
841-
code_assignt assign(function_call.lhs(),function_call.arguments()[0]);
824+
code_assignt assign(function_call.lhs(), function_call.arguments()[0]);
842825
make_string_function(
843826
goto_program, i_it, function_name, signature, true, false);
844827
if(assign.lhs().is_not_nil())
@@ -944,7 +927,7 @@ exprt string_refine_preprocesst::make_cprover_char_array_assign(
944927
const source_locationt &location)
945928
{
946929
typet type=ns.follow(rhs.type());
947-
assert(type.id()==ID_struct &&
930+
assert(type.id()==ID_struct &&
948931
to_struct_type(type).get_tag()=="java::array[char]");
949932

950933
// We do the following assignments:
@@ -1029,7 +1012,8 @@ void string_refine_preprocesst::make_char_array_function(
10291012
if(function_name==ID_cprover_string_copy_func)
10301013
{
10311014
assert(is_java_char_array_pointer_type(args[start_index].type()));
1032-
dereference_exprt char_array(args[start_index], args[start_index].type().subtype());
1015+
dereference_exprt char_array(args[start_index],
1016+
args[start_index].type().subtype());
10331017
exprt string=make_cprover_char_array_assign(
10341018
goto_program, i_it, char_array, location);
10351019

@@ -1259,15 +1243,6 @@ void string_refine_preprocesst::replace_string_calls(
12591243
if(uncasted.id()==ID_typecast)
12601244
uncasted=to_typecast_expr(uncasted).op0();
12611245

1262-
#if 0
1263-
if(implements_java_char_sequence(uncasted.type()))
1264-
{
1265-
auto it=java_to_cprover_strings.find(uncasted);
1266-
if(it!=java_to_cprover_strings.end())
1267-
java_to_cprover_strings.insert(std::make_pair(assignment.lhs(), it->second));
1268-
}
1269-
#endif
1270-
12711246
if(new_rhs.id()==ID_function_application)
12721247
{
12731248
function_application_exprt f=to_function_application_expr(new_rhs);
@@ -1554,7 +1529,6 @@ void string_refine_preprocesst::initialize_string_function_table()
15541529
signatures["java::java.lang.StringBuilder.insert:(ILjava/lang/String;)"
15551530
"Ljava/lang/StringBuilder;"]="SISS";
15561531
signatures["java::java.lang.String.intern:()Ljava/lang/String;"]="SV";
1557-
15581532
}
15591533

15601534
/*******************************************************************\

0 commit comments

Comments
 (0)