Skip to content

Commit 908e599

Browse files
committed
Unwind vsd customisation from simplify_exprt, move to simplify_vsd_exprt
1 parent fa56f20 commit 908e599

File tree

4 files changed

+223
-194
lines changed

4 files changed

+223
-194
lines changed

src/analyses/variable-sensitivity/abstract_environment.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <analyses/variable-sensitivity/abstract_object_statistics.h>
1111
#include <analyses/variable-sensitivity/variable_sensitivity_object_factory.h>
1212
#include <util/expr_util.h>
13+
#include <util/mathematical_types.h>
1314
#include <util/simplify_expr.h>
1415
#include <util/simplify_expr_class.h>
1516

@@ -851,7 +852,27 @@ class simplify_vsd_exprt : public simplify_exprt
851852
public:
852853
explicit simplify_vsd_exprt(const namespacet &_ns) : simplify_exprt(_ns)
853854
{
854-
vsd_pointers = true;
855+
}
856+
857+
NODISCARD resultt<> simplify_node(exprt expr) override
858+
{
859+
if(expr.id() == ID_plus)
860+
return vsd_simplify_plus(to_plus_expr(expr));
861+
return simplify_exprt::simplify_node(expr);
862+
}
863+
864+
private:
865+
resultt<> vsd_simplify_plus(const plus_exprt &expr)
866+
{
867+
// (T*)p+a - don't simplify any further
868+
if(
869+
expr.type().id() == ID_pointer && expr.operands().size() == 2 &&
870+
is_number(expr.op1().type()))
871+
{
872+
return unchanged(expr);
873+
}
874+
875+
return simplify_exprt::simplify_plus(expr);
855876
}
856877
};
857878

src/analyses/variable-sensitivity/context_abstract_object.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ abstract_object_pointert context_abstract_objectt::expression_transform(
8787
const namespacet &ns) const
8888
{
8989
PRECONDITION(expr.operands().size() == operands.size());
90+
9091
std::vector<abstract_object_pointert> child_operands;
9192

9293
std::transform(

src/util/simplify_expr_class.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,11 @@ class with_exprt;
7373
class simplify_exprt
7474
{
7575
public:
76-
explicit simplify_exprt(const namespacet &_ns)
77-
: do_simplify_if(true),
78-
ns(_ns),
79-
vsd_pointers(false)
76+
explicit simplify_exprt(const namespacet &_ns):
77+
do_simplify_if(true),
78+
ns(_ns)
8079
#ifdef DEBUG_ON_DEMAND
81-
,
82-
debug_on(false)
80+
, debug_on(false)
8381
#endif
8482
{
8583
#ifdef DEBUG_ON_DEMAND
@@ -248,8 +246,6 @@ class simplify_exprt
248246

249247
protected:
250248
const namespacet &ns;
251-
bool vsd_pointers;
252-
253249
#ifdef DEBUG_ON_DEMAND
254250
bool debug_on;
255251
#endif

0 commit comments

Comments
 (0)