cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
validate_expressions.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Validate expressions
4
5
Author: Daniel Poetzl
6
7
\*******************************************************************/
8
9
#include "
validate_expressions.h
"
10
#include "
validate_helpers.h
"
11
12
#ifdef REPORT_UNIMPLEMENTED_EXPRESSION_CHECKS
13
#include <iostream>
14
#endif
15
16
#include "
bitvector_expr.h
"
// IWYU pragma: keep
17
#include "
pointer_expr.h
"
// IWYU pragma: keep
18
#include "
ssa_expr.h
"
19
20
#define CALL_ON_EXPR(expr_type) \
21
C<exprt, expr_type>()(expr, std::forward<Args>(args)...)
22
23
template
<
template
<
typename
,
typename
>
class
C,
typename
... Args>
24
void
call_on_expr
(
const
exprt
&expr, Args &&... args)
25
{
26
if
(expr.
id
() == ID_equal)
27
{
28
CALL_ON_EXPR
(
equal_exprt
);
29
}
30
else
if
(expr.
id
() == ID_plus)
31
{
32
CALL_ON_EXPR
(
plus_exprt
);
33
}
34
else
if
(
is_ssa_expr
(expr))
35
{
36
CALL_ON_EXPR
(
ssa_exprt
);
37
}
38
else
if
(expr.
id
() == ID_member)
39
{
40
CALL_ON_EXPR
(
member_exprt
);
41
}
42
else
if
(expr.
id
() == ID_dereference)
43
{
44
CALL_ON_EXPR
(
dereference_exprt
);
45
}
46
else
if
(expr.
is_constant
())
47
{
48
CALL_ON_EXPR
(
constant_exprt
);
49
}
50
else
if
(expr.
id
() == ID_if)
51
{
52
CALL_ON_EXPR
(
if_exprt
);
53
}
54
else
if
(expr.
id
() == ID_update)
55
{
56
CALL_ON_EXPR
(
update_exprt
);
57
}
58
else
if
(expr.
id
() == ID_overflow_unary_minus)
59
{
60
CALL_ON_EXPR
(
unary_minus_overflow_exprt
);
61
}
62
else
if
(expr.
id
() == ID_count_leading_zeros)
63
{
64
CALL_ON_EXPR
(
count_leading_zeros_exprt
);
65
}
66
else
67
{
68
#ifdef REPORT_UNIMPLEMENTED_EXPRESSION_CHECKS
69
std::cerr <<
"Unimplemented well-formedness check for expression with id: "
70
<< expr.
id_string
() std::endl;
71
#endif
72
73
CALL_ON_EXPR
(
exprt
);
74
}
75
}
76
85
void
check_expr
(
const
exprt
&expr,
const
validation_modet
vm)
86
{
87
call_on_expr<call_checkt>
(expr, vm);
88
}
89
98
void
validate_expr
(
99
const
exprt
&expr,
100
const
namespacet
&ns,
101
const
validation_modet
vm)
102
{
103
call_on_expr<call_validatet>
(expr, ns, vm);
104
}
105
114
void
validate_full_expr
(
115
const
exprt
&expr,
116
const
namespacet
&ns,
117
const
validation_modet
vm)
118
{
119
call_on_expr<call_validate_fullt>
(expr, ns, vm);
120
}
bitvector_expr.h
API to expression classes for bitvectors.
constant_exprt
A constant literal expression.
Definition
std_expr.h:2997
count_leading_zeros_exprt
The count leading zeros (counting the number of zero bits starting from the most-significant bit) exp...
Definition
bitvector_expr.h:1325
dereference_exprt
Operator to dereference a pointer.
Definition
pointer_expr.h:834
equal_exprt
Equality.
Definition
std_expr.h:1329
exprt
Base class for all expressions.
Definition
expr.h:57
exprt::is_constant
bool is_constant() const
Return whether the expression is a constant.
Definition
expr.h:213
if_exprt
The trinary if-then-else operator.
Definition
std_expr.h:2416
irept::id_string
const std::string & id_string() const
Definition
irep.h:391
irept::id
const irep_idt & id() const
Definition
irep.h:388
member_exprt
Extract member of struct or union.
Definition
std_expr.h:2856
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition
namespace.h:91
plus_exprt
The plus expression Associativity is not specified.
Definition
std_expr.h:996
ssa_exprt
Expression providing an SSA-renamed symbol of expressions.
Definition
ssa_expr.h:17
unary_minus_overflow_exprt
A Boolean expression returning true, iff negation would result in an overflow when applied to the (si...
Definition
bitvector_expr.h:1260
update_exprt
Operator to update elements in structs and arrays.
Definition
std_expr.h:2669
pointer_expr.h
API to expression classes for Pointers.
ssa_expr.h
is_ssa_expr
bool is_ssa_expr(const exprt &expr)
Definition
ssa_expr.h:125
check_expr
void check_expr(const exprt &expr, const validation_modet vm)
Check that the given expression is well-formed (shallow checks only, i.e., subexpressions and its typ...
Definition
validate_expressions.cpp:85
validate_full_expr
void validate_full_expr(const exprt &expr, const namespacet &ns, const validation_modet vm)
Check that the given expression is well-formed (full check, including checks of all subexpressions an...
Definition
validate_expressions.cpp:114
validate_expr
void validate_expr(const exprt &expr, const namespacet &ns, const validation_modet vm)
Check that the given expression is well-formed, assuming that its subexpression and type have already...
Definition
validate_expressions.cpp:98
call_on_expr
void call_on_expr(const exprt &expr, Args &&... args)
Definition
validate_expressions.cpp:24
CALL_ON_EXPR
#define CALL_ON_EXPR(expr_type)
Definition
validate_expressions.cpp:20
validate_expressions.h
validate_helpers.h
validation_modet
validation_modet
Definition
validation_mode.h:13
util
validate_expressions.cpp
Generated by
1.17.0