Skip to content

Commit c08bbca

Browse files
Daniel Kroeningtautschnig
Daniel Kroening
authored andcommitted
Remove type_eq
With the earlier removal of symbol_type its functionality is exactly the same as directly using operator== on types.
1 parent ca54005 commit c08bbca

10 files changed

+30
-103
lines changed

src/goto-instrument/goto_program2code.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Author: Daniel Kroening, [email protected]
2020
#include <util/find_symbols.h>
2121
#include <util/prefix.h>
2222
#include <util/simplify_expr.h>
23-
#include <util/type_eq.h>
2423

2524
void goto_program2codet::operator()()
2625
{
@@ -1876,7 +1875,7 @@ void goto_program2codet::cleanup_expr(exprt &expr, bool no_typecast)
18761875
if(!has_prefix(id2string(it->second.base_name), "nondet_"))
18771876
continue;
18781877
const code_typet &code_type=to_code_type(it->second.type);
1879-
if(!type_eq(code_type.return_type(), expr.type(), ns))
1878+
if(code_type.return_type() != expr.type())
18801879
continue;
18811880
if(!code_type.parameters().empty())
18821881
continue;

src/goto-programs/remove_function_pointers.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Author: Daniel Kroening, [email protected]
2222
#include <util/replace_expr.h>
2323
#include <util/source_location.h>
2424
#include <util/std_expr.h>
25-
#include <util/type_eq.h>
2625

2726
#include <analyses/does_remove_const.h>
2827

@@ -134,7 +133,7 @@ bool remove_function_pointerst::arg_is_type_compatible(
134133
const typet &call_type,
135134
const typet &function_type)
136135
{
137-
if(type_eq(call_type, function_type, ns))
136+
if(call_type == function_type)
138137
return true;
139138

140139
// any integer-vs-enum-vs-pointer is ok
@@ -166,7 +165,7 @@ bool remove_function_pointerst::is_type_compatible(
166165
if(!return_value_used)
167166
{
168167
}
169-
else if(type_eq(call_type.return_type(), empty_typet(), ns))
168+
else if(call_type.return_type() == empty_typet())
170169
{
171170
// ok
172171
}
@@ -221,8 +220,7 @@ void remove_function_pointerst::fix_argument_types(
221220
{
222221
if(i<call_arguments.size())
223222
{
224-
if(!type_eq(call_arguments[i].type(),
225-
function_parameters[i].type(), ns))
223+
if(call_arguments[i].type() != function_parameters[i].type())
226224
{
227225
call_arguments[i] =
228226
typecast_exprt(call_arguments[i], function_parameters[i].type());
@@ -243,9 +241,7 @@ void remove_function_pointerst::fix_return_type(
243241
const code_typet &code_type = to_code_type(function_call.function().type());
244242

245243
// type already ok?
246-
if(type_eq(
247-
function_call.lhs().type(),
248-
code_type.return_type(), ns))
244+
if(function_call.lhs().type() == code_type.return_type())
249245
return;
250246

251247
const symbolt &function_symbol =

src/goto-programs/remove_virtual_functions.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Author: Daniel Kroening, [email protected]
1313
#include <algorithm>
1414

1515
#include <util/prefix.h>
16-
#include <util/type_eq.h>
1716

1817
#include "class_identifier.h"
1918
#include "goto_model.h"
@@ -131,7 +130,7 @@ static void create_static_function_call(
131130
{
132131
const typet &need_type = callee_parameters[i].type();
133132

134-
if(!type_eq(call_args[i].type(), need_type, ns))
133+
if(call_args[i].type() != need_type)
135134
{
136135
// If this wasn't language agnostic code we'd also like to check
137136
// compatibility-- for example, Java overrides may have differing generic

src/goto-programs/string_abstraction.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ Author: Daniel Kroening, [email protected]
1919
#include <util/expr_util.h>
2020
#include <util/pointer_predicates.h>
2121
#include <util/string_constant.h>
22-
#include <util/type_eq.h>
2322

2423
#include "pointer_arithmetic.h"
2524

@@ -36,13 +35,14 @@ bool string_abstractiont::build_wrap(
3635
// #define build_wrap(a,b,c) build(a,b,c)
3736
// to avoid it
3837
const typet &a_t=build_abstraction_type(object.type());
39-
/*assert(type_eq(dest.type(), a_t, ns) ||
38+
/*assert(dest.type() == a_t ||
4039
(dest.type().id()==ID_array && a_t.id()==ID_pointer &&
41-
type_eq(dest.type().subtype(), a_t.subtype(), ns)));
40+
dest.type().subtype() == a_t.subtype()));
4241
*/
43-
if(!type_eq(dest.type(), a_t, ns) &&
44-
!(dest.type().id()==ID_array && a_t.id()==ID_pointer &&
45-
type_eq(dest.type().subtype(), a_t.subtype(), ns)))
42+
if(
43+
dest.type() != a_t &&
44+
!(dest.type().id() == ID_array && a_t.id() == ID_pointer &&
45+
dest.type().subtype() == a_t.subtype()))
4646
{
4747
warning() << "warning: inconsistent abstract type for "
4848
<< object.pretty() << eom;
@@ -54,8 +54,7 @@ bool string_abstractiont::build_wrap(
5454

5555
bool string_abstractiont::is_ptr_string_struct(const typet &type) const
5656
{
57-
return type.id()==ID_pointer &&
58-
type_eq(type.subtype(), string_struct, ns);
57+
return type.id() == ID_pointer && type.subtype() == string_struct;
5958
}
6059

6160
static inline bool is_ptr_argument(const typet &type)
@@ -323,8 +322,9 @@ exprt string_abstractiont::make_val_or_dummy_rec(goto_programt &dest,
323322
else
324323
return address_of_exprt(sym_expr);
325324
}
326-
else if(eff_type.id()==ID_union ||
327-
(eff_type.id()==ID_struct && !type_eq(eff_type, string_struct, ns)))
325+
else if(
326+
eff_type.id() == ID_union ||
327+
(eff_type.id() == ID_struct && eff_type != string_struct))
328328
{
329329
const struct_union_typet &su_source=to_struct_union_type(source_type);
330330
const struct_union_typet::componentst &s_components=
@@ -406,8 +406,9 @@ symbol_exprt string_abstractiont::add_dummy_symbol_and_value(
406406
decl->code.add_source_location()=ref_instr->source_location;
407407

408408
// set the value - may be nil
409-
if(source_type.id()==ID_array && is_char_type(source_type.subtype()) &&
410-
type_eq(type, string_struct, ns))
409+
if(
410+
source_type.id() == ID_array && is_char_type(source_type.subtype()) &&
411+
type == string_struct)
411412
{
412413
new_symbol.value = struct_exprt(
413414
{build_unknown(whatt::IS_ZERO, false),
@@ -553,7 +554,7 @@ void string_abstractiont::abstract_function_call(
553554
abstract_type.id()==ID_pointer)
554555
{
555556
INVARIANT(
556-
type_eq(str_args.back().type().subtype(), abstract_type.subtype(), ns),
557+
str_args.back().type().subtype() == abstract_type.subtype(),
557558
"argument array type differs from formal parameter pointer type");
558559

559560
index_exprt idx(str_args.back(), from_integer(0, index_type()));
@@ -743,10 +744,9 @@ bool string_abstractiont::build(const exprt &object, exprt &dest, bool write)
743744
if(build(to_typecast_expr(object).op(), dest, write))
744745
return true;
745746

746-
return !(type_eq(dest.type(), abstract_type, ns) ||
747-
(dest.type().id()==ID_array &&
748-
abstract_type.id()==ID_pointer &&
749-
type_eq(dest.type().subtype(), abstract_type.subtype(), ns)));
747+
return dest.type() != abstract_type ||
748+
(dest.type().id() == ID_array && abstract_type.id() == ID_pointer &&
749+
dest.type().subtype() == abstract_type.subtype());
750750
}
751751

752752
if(object.id()==ID_string_constant)
@@ -1200,7 +1200,7 @@ goto_programt::targett string_abstractiont::value_assignments(
12001200
if(rhs.id()==ID_if)
12011201
return value_assignments_if(dest, target, lhs, to_if_expr(rhs));
12021202

1203-
PRECONDITION(type_eq(lhs.type(), rhs.type(), ns));
1203+
PRECONDITION(lhs.type() == rhs.type());
12041204

12051205
if(lhs.type().id()==ID_array)
12061206
{
@@ -1318,7 +1318,7 @@ exprt string_abstractiont::member(const exprt &a, whatt what)
13181318
return a;
13191319

13201320
PRECONDITION_WITH_DIAGNOSTICS(
1321-
type_eq(a.type(), string_struct, ns) || is_ptr_string_struct(a.type()),
1321+
a.type() == string_struct || is_ptr_string_struct(a.type()),
13221322
"either the expression is not a string or it is not a pointer to one");
13231323

13241324
exprt struct_op=

src/util/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ SRC = allocate_objects.cpp \
9191
threeval.cpp \
9292
timestamper.cpp \
9393
type.cpp \
94-
type_eq.cpp \
9594
typecheck.cpp \
9695
ui_message.cpp \
9796
unicode.cpp \

src/util/allocate_objects.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Author: Daniel Kroening, [email protected]
1313
#include "fresh_symbol.h"
1414
#include "pointer_offset_size.h"
1515
#include "string_constant.h"
16-
#include "type_eq.h"
1716

1817
/// Allocates a new object, either by creating a local variable with automatic
1918
/// lifetime, a global variable with static lifetime, or by dynamically
@@ -183,10 +182,8 @@ exprt allocate_objectst::allocate_dynamic_object(
183182
assign.add_source_location() = source_location;
184183
output_code.add(assign);
185184

186-
exprt malloc_symbol_expr =
187-
!type_eq(malloc_sym.symbol_expr().type(), target_expr.type(), ns)
188-
? (exprt)typecast_exprt(malloc_sym.symbol_expr(), target_expr.type())
189-
: malloc_sym.symbol_expr();
185+
exprt malloc_symbol_expr = typecast_exprt::conditional_cast(
186+
malloc_sym.symbol_expr(), target_expr.type());
190187

191188
code_assignt code(target_expr, malloc_symbol_expr);
192189
code.add_source_location() = source_location;

src/util/simplify_expr.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Author: Daniel Kroening, [email protected]
2929
#include "string_constant.h"
3030
#include "string_expr.h"
3131
#include "symbol.h"
32-
#include "type_eq.h"
3332

3433
// #define DEBUGX
3534

@@ -317,7 +316,7 @@ bool simplify_exprt::simplify_typecast(exprt &expr)
317316
}
318317

319318
// eliminate redundant typecasts
320-
if(type_eq(expr.type(), expr.op0().type(), ns))
319+
if(expr.type() == expr.op0().type())
321320
{
322321
exprt tmp;
323322
tmp.swap(expr.op0());

src/util/simplify_expr_struct.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Author: Daniel Kroening, [email protected]
1515
#include "namespace.h"
1616
#include "pointer_offset_size.h"
1717
#include "std_expr.h"
18-
#include "type_eq.h"
1918

2019
bool simplify_exprt::simplify_member(exprt &expr)
2120
{
@@ -207,7 +206,7 @@ bool simplify_exprt::simplify_member(exprt &expr)
207206
else if(op.id()==ID_union && op_type.id()==ID_union)
208207
{
209208
// trivial?
210-
if(type_eq(to_union_expr(op).op().type(), expr.type(), ns))
209+
if(to_union_expr(op).op().type() == expr.type())
211210
{
212211
exprt tmp=to_union_expr(op).op();
213212
expr.swap(tmp);
@@ -271,7 +270,7 @@ bool simplify_exprt::simplify_member(exprt &expr)
271270
equivalent_member.has_value() &&
272271
equivalent_member.value().id() != ID_byte_extract_little_endian &&
273272
equivalent_member.value().id() != ID_byte_extract_big_endian &&
274-
type_eq(equivalent_member.value().type(), expr.type(), ns))
273+
equivalent_member.value().type() == expr.type())
275274
{
276275
expr = equivalent_member.value();
277276
simplify_rec(expr);

src/util/type_eq.cpp

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/util/type_eq.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)