File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -2113,10 +2113,10 @@ exprt c_typecheck_baset::do_special_functions(
2113
2113
}
2114
2114
else if (identifier == CPROVER_PREFIX " points_to_valid_memory" )
2115
2115
{
2116
- if (expr.arguments ().size () != 2 )
2116
+ if (expr.arguments ().size () != 2 && expr. arguments (). size () != 1 )
2117
2117
{
2118
2118
error ().source_location = f_op.source_location ();
2119
- error () << " points_to_valid_memory expects two operands" << eom;
2119
+ error () << " points_to_valid_memory expects one or two operands" << eom;
2120
2120
throw 0 ;
2121
2121
}
2122
2122
if (!is_lvalue (expr.arguments ().front ()))
@@ -2142,6 +2142,24 @@ exprt c_typecheck_baset::do_special_functions(
2142
2142
same_object_expr =
2143
2143
points_to_valid_memory (expr.arguments ()[0 ], expr.arguments ()[1 ]);
2144
2144
}
2145
+ else if (expr.arguments ().size () == 1 )
2146
+ {
2147
+ PRECONDITION (expr.arguments ()[0 ].type ().id () == ID_pointer);
2148
+
2149
+ const typet &base_type = expr.arguments ()[0 ].type ().subtype ();
2150
+ auto expr_size = size_of_expr (base_type, *this );
2151
+ if (!expr_size)
2152
+ {
2153
+ error ().source_location = expr.source_location ();
2154
+ error () << " cannot determine size of pointed-to memory region" << eom;
2155
+ throw 0 ;
2156
+ }
2157
+
2158
+ expr_size->add (ID_C_c_sizeof_type) = base_type;
2159
+
2160
+ same_object_expr =
2161
+ points_to_valid_memory (expr.arguments ()[0 ], *expr_size);
2162
+ }
2145
2163
else
2146
2164
{
2147
2165
UNREACHABLE;
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ void __CPROVER_havoc_object(void *);
6
6
__CPROVER_bool __CPROVER_equal ();
7
7
__CPROVER_bool __CPROVER_same_object (const void * , const void * );
8
8
__CPROVER_bool __CPROVER_invalid_pointer (const void * );
9
- __CPROVER_bool __CPROVER_points_to_valid_memory (const void * , __CPROVER_size_t );
9
+ __CPROVER_bool __CPROVER_points_to_valid_memory (const void * , ... );
10
10
__CPROVER_bool __CPROVER_is_zero_string (const void * );
11
11
__CPROVER_size_t __CPROVER_zero_string_length (const void * );
12
12
__CPROVER_size_t __CPROVER_buffer_size (const void * );
You can’t perform that action at this time.
0 commit comments