-
Notifications
You must be signed in to change notification settings - Fork 273
Use constructors with fewer parameters if possible, for dereference_exprt and plus_exprt #4524
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1623,7 +1623,7 @@ code_blockt java_bytecode_convert_methodt::convert_instructions( | |
|
||
const typecast_exprt pointer(op[0], java_array_type(statement[0])); | ||
|
||
dereference_exprt array(pointer, pointer.type().subtype()); | ||
dereference_exprt array{pointer}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should actually use either |
||
PRECONDITION(pointer.type().subtype().id() == ID_struct_tag); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have no idea why this |
||
array.set(ID_java_member_access, true); | ||
|
||
|
@@ -2832,17 +2832,16 @@ exprt java_bytecode_convert_methodt::convert_aload( | |
const char &type_char = statement[0]; | ||
const typecast_exprt pointer(op[0], java_array_type(type_char)); | ||
|
||
dereference_exprt deref(pointer, pointer.type().subtype()); | ||
dereference_exprt deref{pointer}; | ||
deref.set(ID_java_member_access, true); | ||
|
||
const member_exprt data_ptr( | ||
deref, "data", pointer_type(java_type_from_char(type_char))); | ||
|
||
plus_exprt data_plus_offset(data_ptr, op[1], data_ptr.type()); | ||
plus_exprt data_plus_offset{data_ptr, op[1]}; | ||
// tag it so it's easy to identify during instrumentation | ||
data_plus_offset.set(ID_java_array_access, true); | ||
const typet &element_type = data_ptr.type().subtype(); | ||
const dereference_exprt element(data_plus_offset, element_type); | ||
const dereference_exprt element{data_plus_offset}; | ||
return java_bytecode_promotion(element); | ||
} | ||
|
||
|
@@ -2881,17 +2880,16 @@ code_blockt java_bytecode_convert_methodt::convert_astore( | |
const char type_char = statement[0]; | ||
const typecast_exprt pointer(op[0], java_array_type(type_char)); | ||
|
||
dereference_exprt deref(pointer, pointer.type().subtype()); | ||
dereference_exprt deref{pointer}; | ||
deref.set(ID_java_member_access, true); | ||
|
||
const member_exprt data_ptr( | ||
deref, "data", pointer_type(java_type_from_char(type_char))); | ||
|
||
plus_exprt data_plus_offset(data_ptr, op[1], data_ptr.type()); | ||
plus_exprt data_plus_offset{data_ptr, op[1]}; | ||
// tag it so it's easy to identify during instrumentation | ||
data_plus_offset.set(ID_java_array_access, true); | ||
const typet &element_type = data_ptr.type().subtype(); | ||
const dereference_exprt element(data_plus_offset, element_type); | ||
const dereference_exprt element{data_plus_offset}; | ||
|
||
code_blockt block; | ||
block.add_source_location() = location; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1102,8 +1102,7 @@ void java_object_factoryt::array_primitive_init_code( | |
|
||
// *array_data_init = NONDET(TYPE [max_length_expr]); | ||
side_effect_expr_nondett nondet_data(array_type, location); | ||
const dereference_exprt data_pointer_deref( | ||
tmp_finite_array_pointer, array_type); | ||
const dereference_exprt data_pointer_deref{tmp_finite_array_pointer}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
assignments.add(code_assignt(data_pointer_deref, std::move(nondet_data))); | ||
assignments.statements().back().add_source_location() = location; | ||
|
||
|
@@ -1201,9 +1200,8 @@ void java_object_factoryt::array_loop_init_code( | |
assignments.add(std::move(max_test)); | ||
} | ||
|
||
const dereference_exprt arraycellref( | ||
plus_exprt(array_init_symexpr, counter_expr, array_init_symexpr.type()), | ||
array_init_symexpr.type().subtype()); | ||
const dereference_exprt arraycellref{ | ||
plus_exprt{array_init_symexpr, counter_expr}}; | ||
|
||
bool new_item_is_primitive = arraycellref.type().id() != ID_pointer; | ||
|
||
|
@@ -1303,7 +1301,7 @@ void java_object_factoryt::gen_nondet_array_init( | |
is_valid_java_array(struct_type), | ||
"Java struct array does not conform to expectations"); | ||
|
||
dereference_exprt deref_expr(expr, expr.type().subtype()); | ||
dereference_exprt deref_expr(expr); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Braces (as introduced in all the other places) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I knew I would forget them somewhere! |
||
const auto &comps = struct_type.components(); | ||
const member_exprt length_expr(deref_expr, "length", comps[1].type()); | ||
exprt init_array_expr = member_exprt(deref_expr, "data", comps[2].type()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,9 +21,7 @@ Author: Daniel Kroening, [email protected] | |
/// \return dereferenced pointer | ||
static exprt clean_deref(const exprt &ptr) | ||
{ | ||
return ptr.id()==ID_address_of | ||
? ptr.op0() | ||
: dereference_exprt(ptr, ptr.type().subtype()); | ||
return ptr.id() == ID_address_of ? ptr.op0() : dereference_exprt{ptr}; | ||
} | ||
|
||
/// \par parameters: pointer | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -964,7 +964,7 @@ bool string_abstractiont::build_symbol(const symbol_exprt &sym, exprt &dest) | |
dest=str_symbol.symbol_expr(); | ||
if(current_args.find(symbol.name)!=current_args.end() && | ||
!is_ptr_argument(abstract_type)) | ||
dest=dereference_exprt(dest, dest.type().subtype()); | ||
dest = dereference_exprt{dest}; | ||
|
||
return false; | ||
} | ||
|
@@ -1218,10 +1218,9 @@ goto_programt::targett string_abstractiont::value_assignments( | |
index_exprt(lhs, from_integer(i, a_size.type())), | ||
index_exprt(rhs, from_integer(i, a_size.type()))); | ||
} | ||
else if(lhs.type().id()==ID_pointer) | ||
return value_assignments(dest, target, | ||
dereference_exprt(lhs, lhs.type().subtype()), | ||
dereference_exprt(rhs, rhs.type().subtype())); | ||
else if(lhs.type().id() == ID_pointer) | ||
return value_assignments( | ||
dest, target, dereference_exprt{lhs}, dereference_exprt{rhs}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add braces as this is (always was) a multi-line statement in the body of an |
||
else if(lhs.type()==string_struct) | ||
return value_assignments_string_struct(dest, target, lhs, rhs); | ||
else if(lhs.type().id()==ID_struct || lhs.type().id()==ID_union) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in order to confirm that this is correct I had to read some more code, and the same is happening below: apologies that I'll come up with (almost) unrelated requests for fixes. For this one:
local_symexpr
is declared as a const reference, but.symbol_expr
returns by value, so that's a reference to a temporary. Can you please remove the reference fromlocal_symexpr
?