Skip to content

Commit fc6120c

Browse files
klaasOwen
authored andcommitted
Disambiguates two exprts with the same ID.
This commit resolves an issue where ID_dynamic_object was used to label two semantically distinct exprts. One, with a single operand, was a boolean expression meaning that the operand is a pointer to a dynamic object. This has been renamed to ID_is_dynamic_object. The second, with two operands, is an exprt representing a dynamic object itself. This has stayed ID_dynamic_object. Disambiguating which meaning was intended in each case was relatively easy, as uses of these exprts frequently come with assertions about the number of operands, and so this was used to inform which instances of ID_dynamic_object should be changed and which should be left the same.
1 parent 4a277c4 commit fc6120c

File tree

12 files changed

+59
-26
lines changed

12 files changed

+59
-26
lines changed

regression/goto-instrument/slice19/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
KNOWNBUG
1+
CORE
22
main.c
33
--full-slice
44
^EXIT=0$

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2165,11 +2165,10 @@ exprt c_typecheck_baset::do_special_functions(
21652165
throw 0;
21662166
}
21672167

2168-
exprt dynamic_object_expr=exprt(ID_dynamic_object, expr.type());
2169-
dynamic_object_expr.operands()=expr.arguments();
2170-
dynamic_object_expr.add_source_location()=source_location;
2168+
exprt is_dynamic_object_expr = is_dynamic_object_exprt(expr.arguments()[0]);
2169+
is_dynamic_object_expr.add_source_location() = source_location;
21712170

2172-
return dynamic_object_expr;
2171+
return is_dynamic_object_expr;
21732172
}
21742173
else if(identifier==CPROVER_PREFIX "POINTER_OFFSET")
21752174
{

src/ansi-c/expr2c.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3486,8 +3486,8 @@ std::string expr2ct::convert_with_precedence(
34863486
return convert_function(
34873487
src, CPROVER_PREFIX "invalid_pointer", precedence = 16);
34883488

3489-
else if(src.id()==ID_dynamic_object)
3490-
return convert_function(src, "DYNAMIC_OBJECT", precedence=16);
3489+
else if(src.id() == ID_is_dynamic_object)
3490+
return convert_function(src, "IS_DYNAMIC_OBJECT", precedence = 16);
34913491

34923492
else if(src.id()=="is_zero_string")
34933493
return convert_function(src, "IS_ZERO_STRING", precedence=16);

src/solvers/flattening/bv_pointers.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ literalt bv_pointerst::convert_rest(const exprt &expr)
4545
}
4646
}
4747
}
48-
else if(expr.id()==ID_dynamic_object)
48+
else if(expr.id() == ID_is_dynamic_object)
4949
{
5050
if(operands.size()==1 &&
5151
operands[0].type().id()==ID_pointer)
@@ -728,7 +728,7 @@ void bv_pointerst::add_addr(const exprt &expr, bvt &bv)
728728
void bv_pointerst::do_postponed(
729729
const postponedt &postponed)
730730
{
731-
if(postponed.expr.id() == ID_dynamic_object)
731+
if(postponed.expr.id() == ID_is_dynamic_object)
732732
{
733733
const pointer_logict::objectst &objects=
734734
pointer_logic.objects;

src/solvers/smt2/smt2_conv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,7 @@ void smt2_convt::convert_expr(const exprt &expr)
13161316
if(ext>0)
13171317
out << ")"; // zero_extend
13181318
}
1319-
else if(expr.id() == ID_dynamic_object)
1319+
else if(expr.id() == ID_is_dynamic_object)
13201320
{
13211321
convert_is_dynamic_object(expr);
13221322
}

src/util/irep_ids.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,7 @@ IREP_ID_TWO(overflow_minus, overflow--)
446446
IREP_ID_TWO(overflow_mult, overflow-*)
447447
IREP_ID_TWO(overflow_unary_minus, overflow-unary-)
448448
IREP_ID_ONE(object_descriptor)
449+
IREP_ID_ONE(is_dynamic_object)
449450
IREP_ID_ONE(dynamic_object)
450451
IREP_ID_TWO(C_dynamic, #dynamic)
451452
IREP_ID_ONE(object_size)

src/util/pointer_predicates.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ exprt dynamic_size(const namespacet &ns)
7070

7171
exprt dynamic_object(const exprt &pointer)
7272
{
73-
exprt dynamic_expr(ID_dynamic_object, bool_typet());
73+
exprt dynamic_expr(ID_is_dynamic_object, bool_typet());
7474
dynamic_expr.copy_to_operands(pointer);
7575
return dynamic_expr;
7676
}

src/util/simplify_expr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2403,9 +2403,9 @@ bool simplify_exprt::simplify_node(exprt &expr)
24032403
result=simplify_byte_extract(to_byte_extract_expr(expr)) && result;
24042404
else if(expr.id()==ID_pointer_object)
24052405
result=simplify_pointer_object(expr) && result;
2406-
else if(expr.id() == ID_dynamic_object)
2406+
else if(expr.id() == ID_is_dynamic_object)
24072407
{
2408-
result = simplify_dynamic_object(expr) && result;
2408+
result = simplify_is_dynamic_object(expr) && result;
24092409
}
24102410
else if(expr.id()==ID_invalid_pointer)
24112411
result=simplify_invalid_pointer(expr) && result;

src/util/simplify_expr_class.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class simplify_exprt
9696
bool simplify_pointer_object(exprt &expr);
9797
bool simplify_object_size(exprt &expr);
9898
bool simplify_dynamic_size(exprt &expr);
99-
bool simplify_dynamic_object(exprt &expr);
99+
bool simplify_is_dynamic_object(exprt &expr);
100100
bool simplify_invalid_pointer(exprt &expr);
101101
bool simplify_same_object(exprt &expr);
102102
bool simplify_good_pointer(exprt &expr);

src/util/simplify_expr_int.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,7 +1686,7 @@ bool simplify_exprt::simplify_inequality_constant(exprt &expr)
16861686
{
16871687
if(
16881688
expr.op0().op0().id() == ID_symbol ||
1689-
expr.op0().op0().id() == ID_dynamic_object ||
1689+
expr.op0().op0().id() == ID_is_dynamic_object ||
16901690
expr.op0().op0().id() == ID_member ||
16911691
expr.op0().op0().id() == ID_index ||
16921692
expr.op0().op0().id() == ID_string_constant)
@@ -1701,11 +1701,12 @@ bool simplify_exprt::simplify_inequality_constant(exprt &expr)
17011701
expr.op0().op0().id()==ID_address_of &&
17021702
expr.op0().op0().operands().size()==1)
17031703
{
1704-
if(expr.op0().op0().op0().id()==ID_symbol ||
1705-
expr.op0().op0().op0().id()==ID_dynamic_object ||
1706-
expr.op0().op0().op0().id()==ID_member ||
1707-
expr.op0().op0().op0().id()==ID_index ||
1708-
expr.op0().op0().op0().id()==ID_string_constant)
1704+
if(
1705+
expr.op0().op0().op0().id() == ID_symbol ||
1706+
expr.op0().op0().op0().id() == ID_is_dynamic_object ||
1707+
expr.op0().op0().op0().id() == ID_member ||
1708+
expr.op0().op0().op0().id() == ID_index ||
1709+
expr.op0().op0().op0().id() == ID_string_constant)
17091710
{
17101711
expr=false_exprt();
17111712
return false;

0 commit comments

Comments
 (0)