Skip to content

remove base_type_eq and type_eq: C/C++ edition #4058

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/ansi-c/c_typecast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Author: Daniel Kroening, [email protected]
#include <cassert>

#include <util/arith_tools.h>
#include <util/base_type.h>
#include <util/c_types.h>
#include <util/config.h>
#include <util/expr_util.h>
Expand Down Expand Up @@ -551,7 +550,7 @@ void c_typecastt::implicit_typecast_followed(
// very generous:
// between any two function pointers it's ok
}
else if(base_type_eq(src_sub, dest_sub, ns))
else if(src_sub == dest_sub)
{
// ok
}
Expand All @@ -565,9 +564,9 @@ void c_typecastt::implicit_typecast_followed(
// Also generous: between any to scalar types it's ok.
// We should probably check the size.
}
else if(src_sub.id()==ID_array &&
dest_sub.id()==ID_array &&
base_type_eq(src_sub.subtype(), dest_sub.subtype(), ns))
else if(
src_sub.id() == ID_array && dest_sub.id() == ID_array &&
src_sub.subtype() == dest_sub.subtype())
{
// we ignore the size of the top-level array
// in the case of pointers to arrays
Expand Down
14 changes: 6 additions & 8 deletions src/ansi-c/c_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Author: Daniel Kroening, [email protected]
#include <cassert>

#include <util/arith_tools.h>
#include <util/base_type.h>
#include <util/c_types.h>
#include <util/config.h>
#include <util/cprover_prefix.h>
Expand Down Expand Up @@ -1064,9 +1063,9 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr)

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

if(expr_type.id()==ID_union &&
!base_type_eq(expr_type, op.type(), *this) &&
op.id()!=ID_initializer_list)
if(
expr_type.id() == ID_union && expr_type != op.type() &&
op.id() != ID_initializer_list)
{
// This is a GCC extension. It's either a 'temporary union',
// where the argument is one of the member types.
Expand All @@ -1080,7 +1079,7 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr)
// we need to find a member with the right type
for(const auto &c : to_union_type(expr_type).components())
{
if(base_type_eq(c.type(), op.type(), *this))
if(c.type() == op.type())
{
// found! build union constructor
union_exprt union_expr(c.get_name(), op, expr.type());
Expand Down Expand Up @@ -1131,7 +1130,7 @@ void c_typecheck_baset::typecheck_expr_typecast(exprt &expr)
const typet op_type = op.type();

// cast to same type?
if(base_type_eq(expr_type, op_type, *this))
if(expr_type == op_type)
return; // it's ok

// vectors?
Expand Down Expand Up @@ -2516,8 +2515,7 @@ exprt c_typecheck_baset::do_special_functions(
expr.arguments().front(), expr.arguments().back());
equality_expr.add_source_location()=source_location;

if(!base_type_eq(equality_expr.lhs().type(),
equality_expr.rhs().type(), *this))
if(equality_expr.lhs().type() != equality_expr.rhs().type())
{
error().source_location = f_op.source_location();
error() << "equal expects two operands of same type" << eom;
Expand Down
1 change: 0 additions & 1 deletion src/ansi-c/c_typecheck_initializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Author: Daniel Kroening, [email protected]
#include <util/simplify_expr.h>
#include <util/std_types.h>
#include <util/string_constant.h>
#include <util/type_eq.h>

#include "anonymous_member.h"

Expand Down
7 changes: 3 additions & 4 deletions src/cpp/cpp_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Author: Daniel Kroening, [email protected]
#endif

#include <util/arith_tools.h>
#include <util/base_type.h>
#include <util/c_types.h>
#include <util/config.h>
#include <util/expr_initializer.h>
Expand Down Expand Up @@ -2373,9 +2372,9 @@ void cpp_typecheckt::typecheck_method_application(
if(expr.arguments().size()==func_type.parameters().size())
{
// this might be set up for base-class initialisation
if(!base_type_eq(expr.arguments().front().type(),
func_type.parameters().front().type(),
*this))
if(
expr.arguments().front().type() !=
func_type.parameters().front().type())
{
implicit_typecast(expr.arguments().front(), this_type);
assert(is_reference(expr.arguments().front().type()));
Expand Down