Skip to content

Commit b00794c

Browse files
authored
Merge pull request #4058 from diffblue/type-equality-c-cpp
remove base_type_eq and type_eq: C/C++ edition
2 parents 4cb4bc9 + 4775ed3 commit b00794c

File tree

4 files changed

+13
-18
lines changed

4 files changed

+13
-18
lines changed

src/ansi-c/c_typecast.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Author: Daniel Kroening, [email protected]
1313
#include <cassert>
1414

1515
#include <util/arith_tools.h>
16-
#include <util/base_type.h>
1716
#include <util/c_types.h>
1817
#include <util/config.h>
1918
#include <util/expr_util.h>
@@ -551,7 +550,7 @@ void c_typecastt::implicit_typecast_followed(
551550
// very generous:
552551
// between any two function pointers it's ok
553552
}
554-
else if(base_type_eq(src_sub, dest_sub, ns))
553+
else if(src_sub == dest_sub)
555554
{
556555
// ok
557556
}
@@ -565,9 +564,9 @@ void c_typecastt::implicit_typecast_followed(
565564
// Also generous: between any to scalar types it's ok.
566565
// We should probably check the size.
567566
}
568-
else if(src_sub.id()==ID_array &&
569-
dest_sub.id()==ID_array &&
570-
base_type_eq(src_sub.subtype(), dest_sub.subtype(), ns))
567+
else if(
568+
src_sub.id() == ID_array && dest_sub.id() == ID_array &&
569+
src_sub.subtype() == dest_sub.subtype())
571570
{
572571
// we ignore the size of the top-level array
573572
// in the case of pointers to arrays

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ Author: Daniel Kroening, [email protected]
1414
#include <cassert>
1515

1616
#include <util/arith_tools.h>
17-
#include <util/base_type.h>
1817
#include <util/c_types.h>
1918
#include <util/config.h>
2019
#include <util/cprover_prefix.h>
@@ -1064,9 +1063,9 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr)
10641063

10651064
const typet expr_type=follow(expr.type());
10661065

1067-
if(expr_type.id()==ID_union &&
1068-
!base_type_eq(expr_type, op.type(), *this) &&
1069-
op.id()!=ID_initializer_list)
1066+
if(
1067+
expr_type.id() == ID_union && expr_type != op.type() &&
1068+
op.id() != ID_initializer_list)
10701069
{
10711070
// This is a GCC extension. It's either a 'temporary union',
10721071
// where the argument is one of the member types.
@@ -1080,7 +1079,7 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr)
10801079
// we need to find a member with the right type
10811080
for(const auto &c : to_union_type(expr_type).components())
10821081
{
1083-
if(base_type_eq(c.type(), op.type(), *this))
1082+
if(c.type() == op.type())
10841083
{
10851084
// found! build union constructor
10861085
union_exprt union_expr(c.get_name(), op, expr.type());
@@ -1131,7 +1130,7 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr)
11311130
const typet op_type = op.type();
11321131

11331132
// cast to same type?
1134-
if(base_type_eq(expr_type, op_type, *this))
1133+
if(expr_type == op_type)
11351134
return; // it's ok
11361135

11371136
// vectors?
@@ -2516,8 +2515,7 @@ exprt c_typecheck_baset::do_special_functions(
25162515
expr.arguments().front(), expr.arguments().back());
25172516
equality_expr.add_source_location()=source_location;
25182517

2519-
if(!base_type_eq(equality_expr.lhs().type(),
2520-
equality_expr.rhs().type(), *this))
2518+
if(equality_expr.lhs().type() != equality_expr.rhs().type())
25212519
{
25222520
error().source_location = f_op.source_location();
25232521
error() << "equal expects two operands of same type" << eom;

src/ansi-c/c_typecheck_initializer.cpp

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

2423
#include "anonymous_member.h"
2524

src/cpp/cpp_typecheck_expr.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ Author: Daniel Kroening, [email protected]
1616
#endif
1717

1818
#include <util/arith_tools.h>
19-
#include <util/base_type.h>
2019
#include <util/c_types.h>
2120
#include <util/config.h>
2221
#include <util/expr_initializer.h>
@@ -2373,9 +2372,9 @@ void cpp_typecheckt::typecheck_method_application(
23732372
if(expr.arguments().size()==func_type.parameters().size())
23742373
{
23752374
// this might be set up for base-class initialisation
2376-
if(!base_type_eq(expr.arguments().front().type(),
2377-
func_type.parameters().front().type(),
2378-
*this))
2375+
if(
2376+
expr.arguments().front().type() !=
2377+
func_type.parameters().front().type())
23792378
{
23802379
implicit_typecast(expr.arguments().front(), this_type);
23812380
assert(is_reference(expr.arguments().front().type()));

0 commit comments

Comments
 (0)