Add support for throws clauses in ACSL function contracts - #69
Open
hugo-saci wants to merge 10 commits into
Open
Add support for throws clauses in ACSL function contracts#69hugo-saci wants to merge 10 commits into
hugo-saci wants to merge 10 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add support for
throwsclauses in ACSL function contracts.This is based on the grammar of a throws-clause from ACSL++ (figure 2.28):
throwspred;throws{C-type-name (, C-type-name )*}pred;The ACSL-parser has been extended to support the syntax above in function contracts.
The
FunctionContractis encoded differently inACSLTransator.scala, accounting forthrowsclauses. This encoding is based on the global exception variables that are generated inCCAstExceptionTransformer.scala.Information from the TriCera preprocessor (tri-pp) is used to determine if the throws clauses should be accounted for. If the program does not contain exceptions, throws clauses are ignored (a warning is given if throws clauses exist) and the
FunctionContractis encoded as previously done.Not supported
In ACSL++, and
\exceptionterm is defined to be a pointer to the exception object. This has NOT been implemented.Mathematical description
For programs that contain exceptions, here is how the contract is encoded. Given non-exceptional precondition$P$ , locations $L$ , and postcondition $Q$ , the exceptional contract is defined by $\hat{P}, \hat{L}, \hat{Q}$ .
Given throws clauses:
$P_1$
$\vdots$
$P_m$
$T^1_1, \dots, T^1_{t_1}$ $P_1'$
$\vdots$
$T^k_1, \dots, T^k_{t_k}$ $P'_k$
throws;throws;throws{};throws{};and the following:
__exception_flag)__exception_type)__exception_value)Here is how the exceptional contract is defined:
where