cprover
Loading...
Searching...
No Matches
Code Contracts Software Architecture

Table of Contents

Back to contracts-dev

Architecture Overview

The code implementing contracts-dev-spec is found in Dynamic Frame Condition Checking (DFCC)

We go over each class and explain how it works in relation to others.

The dfcct class is the main entry point into the transformation.

The method dfcct::transform_goto_model first separates the functions of the goto model in different groups (functions to instrument, pure contract symbols from which to generate code, functions to check against contracts, functions to replace with contracts) and applies the transformation to the whole goto model, by scheduling the translation passes described in contracts-dev-spec :

  1. contracts-dev-spec-codegen is applied to all contracts to check or replace;
  2. contracts-dev-spec-dfcc is applied to all library or user-defined goto functions;
  3. contracts-dev-spec-harness is applied to the harness function;
  4. contracts-dev-spec-contract-checking is applied to the function to be checked against a contract;
  5. contracts-dev-spec-contract-replacement is applied to each function to be replaced by a contract;

Each of these translation passes is implemented in a specific class:

Class Specification
dfcc_instrumentt Implements contracts-dev-spec-dfcc for goto_functiont, goto_programt, or subsequences of instructions of goto_programt
dfcc_is_fresht Implements contracts-dev-spec-is-fresh
dfcc_pointer_in_ranget Implements contracts-dev-spec-pointer-in-range
dfcc_pointer_equalst Implements contracts-dev-spec-pointer-equals
dfcc_lift_memory_predicatest Implements contracts-dev-spec-memory-predicates-rewriting
dfcc_is_freeablet Implements contracts-dev-spec-is-freeable
dfcc_obeys_contractt Implements contracts-dev-spec-obeys-contract
dfcc_spec_functionst Implements contracts-dev-spec-spec-rewriting
dfcc_wrapper_programt Implements contracts-dev-spec-contract-checking for contracts
Implements contracts-dev-spec-contract-replacement for contracts
dfcc_contract_handlert Implements contracts-dev-spec-codegen for contracts
Implements the interface dfcc_contract_handlert for contract by delegating operations to dfcc_wrapper_programt
dfcc_swap_and_wrapt Implements contracts-dev-spec-contract-checking by delegating basic operations to dfcc_contract_handlert
Implements contracts-dev-spec-contract-replacement by delegating basic operations to dfcc_contract_handlert
Implements contracts-dev-spec-contract-checking-rec by delegating basic operations to dfcc_contract_handlert

The following classes contain utility methods:

  • dfcc_utilst : Provides basic utility methods to the other classes such as locating a function symbol, adding a parameter to a function symbol, cloning or renaming a function symbol, creating fresh symbols, inlining a function body, etc.
  • dfcc_libraryt : Provides a C++ interface to access C library functions defined in cprover_contracts.c. Using this class it is possible to load the library symbols and post-process them with loop unrolling or inlining, etc.