CONTRATCS: force success for necessary pointer predicates #8574
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Force success for pointer predicates that must necessarily hold if they ever get invoked in an assumption context. This ensures that the value sets of pointers as as small as possible after assuming a requires or an ensures clause and solves a performance issue with z3. All predicates in the
cprover_contracts.c
library now have an extra inputmay_fail
controlling the failure behaviour, DFCC instrumentation sets themay_fail
parameter to true or false using a recursive downwards propagation algorithm that takes into account the shortcutting behaviour of==>
,&&
and||
. This applies to all predicates (pointer_equals, is_fresh, pointer_in_range and obeys_contract for function pointers).The test that regressed due to #8562 now passes again.
Example
Is tagged as follows :
In order for the the requires clause to hold when assumed, the
is_fresh
predicates in the RHS of implicationsmust not fail if they ever get invoked, those left of disjunctions may fail
Example
Will be tagged
The top conjuncts may not fail for the whole expression to hold, and the last element of the disjunction may not fail if it ever gets invoked after all other leftmost disjuncts may have failed.