Skip to content

Commit 9f2e80d

Browse files
committed
Add a postcondition cprover builtin
1 parent 103b2dc commit 9f2e80d

File tree

5 files changed

+12
-1
lines changed

5 files changed

+12
-1
lines changed

src/ansi-c/cprover_builtin_headers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ void __CPROVER_assume(__CPROVER_bool assumption);
22
void __VERIFIER_assume(__CPROVER_bool assumption);
33
void __CPROVER_assert(__CPROVER_bool assertion, const char *description);
44
void __CPROVER_precondition(__CPROVER_bool precondition, const char *description);
5+
void __CPROVER_postcondition(__CPROVER_bool assertion, const char *description);
56
void __CPROVER_havoc_object(void *);
67
__CPROVER_bool __CPROVER_equal();
78
__CPROVER_bool __CPROVER_same_object(const void *, const void *);

src/ansi-c/library/cprover.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ extern const void *__CPROVER_memory_leak;
2020
void __CPROVER_assume(__CPROVER_bool assumption) __attribute__((__noreturn__));
2121
void __CPROVER_assert(__CPROVER_bool assertion, const char *description);
2222
void __CPROVER_precondition(__CPROVER_bool assertion, const char *description);
23+
void __CPROVER_postcondition(__CPROVER_bool assertion, const char *description);
2324

2425
__CPROVER_bool __CPROVER_is_zero_string(const void *);
2526
__CPROVER_size_t __CPROVER_zero_string_length(const void *);

src/cpp/library/cprover.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ extern const void *__CPROVER_memory_leak;
2121
void __CPROVER_assume(__CPROVER_bool assumption) __attribute__((__noreturn__));
2222
void __CPROVER_assert(__CPROVER_bool assertion, const char *description);
2323
void __CPROVER_precondition(__CPROVER_bool assertion, const char *description);
24+
void __CPROVER_postcondition(__CPROVER_bool assertion, const char *description);
2425

2526
// NOLINTNEXTLINE(build/deprecated)
2627
void __CPROVER_input(const char *description, ...);

src/goto-programs/builtin_functions.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,8 @@ void goto_convertt::do_function_call_symbol(
742742
}
743743
}
744744
else if(identifier==CPROVER_PREFIX "assert" ||
745-
identifier==CPROVER_PREFIX "precondition")
745+
identifier==CPROVER_PREFIX "precondition" ||
746+
identifier==CPROVER_PREFIX "postcondition")
746747
{
747748
if(arguments.size()!=2)
748749
{
@@ -754,6 +755,8 @@ void goto_convertt::do_function_call_symbol(
754755

755756
bool is_precondition=
756757
identifier==CPROVER_PREFIX "precondition";
758+
bool is_postcondition=
759+
identifier==CPROVER_PREFIX "postcondition";
757760

758761
const irep_idt description=
759762
get_string_constant(arguments[1]);
@@ -767,6 +770,10 @@ void goto_convertt::do_function_call_symbol(
767770
{
768771
t->source_location.set_property_class(ID_precondition);
769772
}
773+
else if(is_postcondition)
774+
{
775+
t->source_location.set_property_class(ID_postcondition);
776+
}
770777
else
771778
{
772779
t->source_location.set(

src/util/irep_ids.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ IREP_ID_ONE(assume)
8989
IREP_ID_ONE(assert)
9090
IREP_ID_ONE(assertion)
9191
IREP_ID_ONE(precondition)
92+
IREP_ID_ONE(postcondition)
9293
IREP_ID_ONE(precondition_instance)
9394
IREP_ID_ONE(goto)
9495
IREP_ID_ONE(gcc_computed_goto)

0 commit comments

Comments
 (0)