Skip to content

Conversation

@kroening
Copy link
Collaborator

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.

@kroening kroening mentioned this pull request Jul 19, 2017
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()));
Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Collaborator

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.

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()));
Copy link
Collaborator

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...);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

address_of.type().subtype()=object.type();
address_of.copy_to_operands(object);
exprt address_of=
address_of_exprt(object, pointer_type(object.type()));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

Copy link
Collaborator Author

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());
Copy link
Collaborator

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

Copy link
Collaborator Author

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()));
Copy link
Collaborator

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...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


address_of_exprt address_of_expr=
address_of_exprt(make_auto_object(type.subtype()));
address_of_exprt(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use constructor, not assignment

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


#include <util/namespace.h>
#include <util/std_expr.h>
#include <util/c_types.h>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit picking as above

#include <util/arith_tools.h>
#include <util/ieee_float.h>
#include <util/simplify_expr.h>
#include <util/c_types.h>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit picking as above

#include <util/base_type.h>
#include <util/string2int.h>
#include <util/invariant.h>
#include <util/c_types.h>
Copy link
Collaborator

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):
Copy link
Collaborator

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now using it more.

@kroening kroening force-pushed the pointer-cleanup branch 2 times, most recently from 894a5b3 to c73ee7a Compare July 20, 2017 09:54
Copy link
Collaborator

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

Copy link
Collaborator

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

Copy link
Collaborator

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

Copy link
Collaborator

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(...

Copy link
Collaborator Author

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.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index_exprt index(...

@tautschnig tautschnig merged commit f8b8f9e into master Jul 20, 2017
@tautschnig tautschnig deleted the pointer-cleanup branch July 20, 2017 18:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants