Skip to content

Commit 84bd584

Browse files
author
Daniel Kroening
committed
C front-end now supports __CPROVER_OBJECT_SIZE
1 parent 141503e commit 84bd584

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2164,6 +2164,21 @@ exprt c_typecheck_baset::do_special_functions(
21642164

21652165
return typecast_exprt::conditional_cast(pointer_offset_expr, expr.type());
21662166
}
2167+
else if(identifier == CPROVER_PREFIX "OBJECT_SIZE")
2168+
{
2169+
if(expr.arguments().size() != 1)
2170+
{
2171+
err_location(f_op);
2172+
error() << "object_size expects one operand" << eom;
2173+
throw 0;
2174+
}
2175+
2176+
unary_exprt object_size_expr(
2177+
ID_object_size, expr.arguments()[0], size_type());
2178+
object_size_expr.add_source_location() = source_location;
2179+
2180+
return object_size_expr;
2181+
}
21672182
else if(identifier==CPROVER_PREFIX "POINTER_OBJECT")
21682183
{
21692184
if(expr.arguments().size()!=1)

src/ansi-c/cprover_builtin_headers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ void CBMC_trace(int lvl, const char *event, ...);
3737
// pointers
3838
__CPROVER_size_t __CPROVER_POINTER_OBJECT(const void *);
3939
__CPROVER_ssize_t __CPROVER_POINTER_OFFSET(const void *);
40+
__CPROVER_size_t __CPROVER_OBJECT_SIZE(const void *);
4041
__CPROVER_bool __CPROVER_DYNAMIC_OBJECT(const void *);
4142
void __CPROVER_allocated_memory(__CPROVER_size_t address, __CPROVER_size_t extent);
4243

0 commit comments

Comments
 (0)