Skip to content

Commit 9c12e0f

Browse files
committed
Enable goto-model validation for ternary and bitvector expressions
The code was almost there, but was never triggered.
1 parent 9624d5d commit 9c12e0f

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

src/util/std_expr.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ class ternary_exprt : public expr_protectedt
7979
expr.operands().size() == 3,
8080
"ternary expression must have three operands");
8181
}
82+
83+
static void validate(
84+
const exprt &expr,
85+
const namespacet &,
86+
const validation_modet vm = validation_modet::INVARIANT)
87+
{
88+
check(expr, vm);
89+
}
8290
};
8391

8492
/// \brief Cast an exprt to a \ref ternary_exprt
@@ -2294,6 +2302,21 @@ class if_exprt : public ternary_exprt
22942302
{
22952303
return op2();
22962304
}
2305+
2306+
static void check(
2307+
const exprt &expr,
2308+
const validation_modet vm = validation_modet::INVARIANT)
2309+
{
2310+
ternary_exprt::check(expr, vm);
2311+
}
2312+
2313+
static void validate(
2314+
const exprt &expr,
2315+
const namespacet &ns,
2316+
const validation_modet vm = validation_modet::INVARIANT)
2317+
{
2318+
ternary_exprt::validate(expr, ns, vm);
2319+
}
22972320
};
22982321

22992322
template <>
@@ -2563,6 +2586,21 @@ class update_exprt : public ternary_exprt
25632586
{
25642587
return op2();
25652588
}
2589+
2590+
static void check(
2591+
const exprt &expr,
2592+
const validation_modet vm = validation_modet::INVARIANT)
2593+
{
2594+
ternary_exprt::check(expr, vm);
2595+
}
2596+
2597+
static void validate(
2598+
const exprt &expr,
2599+
const namespacet &ns,
2600+
const validation_modet vm = validation_modet::INVARIANT)
2601+
{
2602+
ternary_exprt::validate(expr, ns, vm);
2603+
}
25662604
};
25672605

25682606
template <>

src/util/validate_expressions.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Author: Daniel Poetzl
1313
#include <iostream>
1414
#endif
1515

16+
#include "bitvector_expr.h"
1617
#include "pointer_expr.h"
1718
#include "ssa_expr.h"
1819

@@ -46,6 +47,22 @@ void call_on_expr(const exprt &expr, Args &&... args)
4647
{
4748
CALL_ON_EXPR(constant_exprt);
4849
}
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+
}
4966
else
5067
{
5168
#ifdef REPORT_UNIMPLEMENTED_EXPRESSION_CHECKS

0 commit comments

Comments
 (0)