|
| 1 | +/*******************************************************************\ |
| 2 | +
|
| 3 | +Module: Invariant helper utilities |
| 4 | +
|
| 5 | +Author: Chris Smowton, [email protected] |
| 6 | +
|
| 7 | +\*******************************************************************/ |
| 8 | + |
| 9 | +#ifndef CPROVER_UTIL_INVARIANT_TYPES_H |
| 10 | +#define CPROVER_UTIL_INVARIANT_TYPES_H |
| 11 | + |
| 12 | +#include "invariant.h" |
| 13 | + |
| 14 | +#include <util/irep.h> |
| 15 | + |
| 16 | +#include <string> |
| 17 | + |
| 18 | +/// Produces a plain string error description from an irep and some |
| 19 | +/// explanatory text. If `problem_node` is nil, returns `description`. |
| 20 | +/// \param problem_node: irep to pretty-print |
| 21 | +/// \param description: descriptive text to prepend |
| 22 | +/// \return error message |
| 23 | +std::string pretty_print_invariant_with_irep( |
| 24 | + const irept &problem_node, |
| 25 | + const std::string &description); |
| 26 | + |
| 27 | +/// Equivalent to |
| 28 | +/// `INVARIANT_STRUCTURED(CONDITION, invariant_failedt, |
| 29 | +/// pretty_print_invariant_with_irep(IREP, DESCRIPTION))` |
| 30 | +#define INVARIANT_WITH_IREP(CONDITION, DESCRIPTION, IREP) \ |
| 31 | + INVARIANT_STRUCTURED( \ |
| 32 | + CONDITION, \ |
| 33 | + invariant_failedt, \ |
| 34 | + pretty_print_invariant_with_irep((IREP), (DESCRIPTION))) |
| 35 | + |
| 36 | +/// See `INVARIANT_WITH_IREP` |
| 37 | +#define PRECONDITION_WITH_IREP(CONDITION, DESCRIPTION, IREP) \ |
| 38 | + INVARIANT_WITH_IREP((CONDITION), (DESCRIPTION), (IREP)) |
| 39 | +#define POSTCONDITION_WITH_IREP(CONDITION, DESCRIPTION, IREP) \ |
| 40 | + INVARIANT_WITH_IREP((CONDITION), (DESCRIPTION), (IREP)) |
| 41 | +#define CHECK_RETURN_WITH_IREP(CONDITION, DESCRIPTION, IREP) \ |
| 42 | + INVARIANT_WITH_IREP((CONDITION), (DESCRIPTION), (IREP)) |
| 43 | +#define UNREACHABLE_WITH_IREP(CONDITION, DESCRIPTION, IREP) \ |
| 44 | + INVARIANT_WITH_IREP((CONDITION), (DESCRIPTION), (IREP)) |
| 45 | +#define DATA_INVARIANT_WITH_IREP(CONDITION, DESCRIPTION, IREP) \ |
| 46 | + INVARIANT_WITH_IREP((CONDITION), (DESCRIPTION), (IREP)) |
| 47 | + |
| 48 | +#endif |
0 commit comments