-
Notifications
You must be signed in to change notification settings - Fork 273
Pointer cleanup #1154
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
Pointer cleanup #1154
Conversation
src/ansi-c/ansi_c_entry_point.cpp
Outdated
@@ -327,8 +327,7 @@ bool ansi_c_entry_point( | |||
zero_string.type().set(ID_size, "infinity"); | |||
exprt index(ID_index, char_type()); | |||
index.copy_to_operands(zero_string, from_integer(0, uint_type())); | |||
exprt address_of("address_of", pointer_typet()); | |||
address_of.type().subtype()=char_type(); | |||
exprt address_of("address_of", pointer_type(char_type())); |
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.
Please use address_of_exprt
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.
done
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.
Happy to approve once pushed.
src/cpp/cpp_constructor.cpp
Outdated
address_of.type().subtype()=object_tc.type(); | ||
address_of.copy_to_operands(object_tc); | ||
exprt address_of= | ||
address_of_exprt(object_tc, pointer_type(object_tc.type())); |
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.
address_of_exprt address_of(object_tc...);
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.
Done
src/cpp/cpp_destructor.cpp
Outdated
address_of.type().subtype()=object.type(); | ||
address_of.copy_to_operands(object); | ||
exprt address_of= | ||
address_of_exprt(object, pointer_type(object.type())); |
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.
See above
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.
Done
index_exprt index( | ||
expr, | ||
from_integer(0, index_type()), | ||
expr.type().subtype()); |
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.
The third argument is not necessary
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.
Done
expr_pfrom, pto, expr_ptmp, tmp_rank)) | ||
// try derived-to-base conversion | ||
exprt expr_pfrom= | ||
address_of_exprt(expr, pointer_type(expr.type())); |
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.
addres_of_exprt expr_pfrom...
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.
Done
src/goto-symex/auto_objects.cpp
Outdated
@@ -67,7 +67,9 @@ void goto_symext::initialize_auto_object( | |||
// could be NULL nondeterministically | |||
|
|||
address_of_exprt address_of_expr= | |||
address_of_exprt(make_auto_object(type.subtype())); | |||
address_of_exprt( |
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.
Use constructor, not assignment
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.
done
@@ -22,6 +22,7 @@ Author: Daniel Kroening, [email protected] | |||
|
|||
#include <util/namespace.h> | |||
#include <util/std_expr.h> | |||
#include <util/c_types.h> |
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.
Nit picking as above
@@ -22,6 +22,7 @@ Author: Daniel Kroening, [email protected] | |||
#include <util/arith_tools.h> | |||
#include <util/ieee_float.h> | |||
#include <util/simplify_expr.h> | |||
#include <util/c_types.h> |
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.
Nit picking as above
src/solvers/smt2/smt2_conv.cpp
Outdated
@@ -23,6 +23,7 @@ Author: Daniel Kroening, [email protected] | |||
#include <util/base_type.h> | |||
#include <util/string2int.h> | |||
#include <util/invariant.h> | |||
#include <util/c_types.h> |
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.
Nit picking as above
|
||
\*******************************************************************/ | ||
|
||
address_of_exprt::address_of_exprt(const exprt &_op): |
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.
Is this actually being used? Most (all?) calls above appear to use a two-argument constructor
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.
Now using it more.
894a5b3
to
c73ee7a
Compare
src/ansi-c/ansi_c_entry_point.cpp
Outdated
|
||
if(argv_symbol.type.subtype()!=address_of.type()) | ||
address_of.make_typecast(argv_symbol.type.subtype()); | ||
|
||
// assign argv[*] to the address of a string-object | ||
exprt array_of("array_of", argv_symbol.type); | ||
array_of.copy_to_operands(address_of); | ||
exprt array_of=array_of_exprt(address_of, argv_symbol.type); |
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.
Could use array_of_exprt array_of(...
here
src/ansi-c/ansi_c_entry_point.cpp
Outdated
|
||
exprt index_expr(ID_index, arg1.type().subtype()); | ||
exprt index_expr(ID_index, pointer_type.subtype()); |
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.
index_exprt index_expr(...)
and the lines below should be eliminated
src/ansi-c/ansi_c_entry_point.cpp
Outdated
|
||
exprt index_expr(ID_index, arg2.type().subtype()); | ||
exprt index_expr(ID_index, pointer_type.subtype()); |
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.
index_exprt index_expr(...
and again code below to be eliminated
@@ -1715,10 +1698,9 @@ bool cpp_typecheckt::const_typecast( | |||
if(new_expr.type()!=type.subtype()) | |||
return false; | |||
|
|||
exprt address_of(ID_address_of, type); | |||
address_of.copy_to_operands(expr); | |||
exprt address_of=address_of_exprt(expr, to_pointer_type(type)); |
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.
Might be a candidate for address_of_exprt address_of(...
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.
Unfortunately not, as this might turn into a dereference expression.
@@ -825,14 +825,12 @@ void string_instrumentationt::do_strerror( | |||
} | |||
|
|||
// return a pointer to some magic buffer | |||
exprt index=exprt(ID_index, char_type()); | |||
index.copy_to_operands( | |||
exprt index=index_exprt( |
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.
index_exprt index(...
c73ee7a
to
9dd44d6
Compare
9dd44d6
to
db71221
Compare
This is in preparation for giving pointers a width (much like integers), using constructors and a service function to produce pointer and reference types whenever appropriate.
Split off PR #970.