Skip to content

Commit d457b14

Browse files
committed
remove base_type_eq
base_type_eq has been deprecated since 2019; a previous attempt to remove it (#4056) has failed.
1 parent c00319e commit d457b14

File tree

3 files changed

+33
-46
lines changed

3 files changed

+33
-46
lines changed

src/analyses/does_remove_const.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Author: Diffblue Ltd.
1313

1414
#include <goto-programs/goto_program.h>
1515

16-
#include <util/base_type.h>
1716
#include <util/pointer_expr.h>
1817
#include <util/std_code.h>
1918

@@ -69,11 +68,11 @@ bool does_remove_constt::does_expr_lose_const(const exprt &expr) const
6968
{
7069
const typet &root_type=expr.type();
7170

72-
// Look in each child that has the same base type as the root
71+
// Look in each child that has the same type as the root
7372
for(const exprt &op : expr.operands())
7473
{
7574
const typet &op_type=op.type();
76-
if(base_type_eq(op_type, root_type, ns))
75+
if(op_type == root_type)
7776
{
7877
// Is this child more const-qualified than the root
7978
if(!does_type_preserve_const_correctness(&root_type, &op_type))

src/goto-programs/goto_program.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

1616
#include <iomanip>
1717

18-
#include <util/base_type.h>
1918
#include <util/expr_iterator.h>
2019
#include <util/find_symbols.h>
2120
#include <util/format_expr.h>
@@ -808,7 +807,7 @@ void goto_programt::instructiont::validate(
808807
if(!ns.lookup(goto_id, table_symbol))
809808
{
810809
bool symbol_expr_type_matches_symbol_table =
811-
base_type_eq(goto_symbol_expr.type(), table_symbol->type, ns);
810+
goto_symbol_expr.type() == table_symbol->type;
812811

813812
if(
814813
!symbol_expr_type_matches_symbol_table &&
@@ -831,7 +830,7 @@ void goto_programt::instructiont::validate(
831830
table_symbol_type.return_type();
832831

833832
symbol_expr_type_matches_symbol_table =
834-
base_type_eq(goto_symbol_expr_type, table_symbol_type, ns);
833+
goto_symbol_expr_type == table_symbol_type;
835834
}
836835
}
837836

src/linking/linking.cpp

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

17-
#include <util/base_type.h>
1817
#include <util/c_types.h>
1918
#include <util/find_symbols.h>
2019
#include <util/mathematical_types.h>
@@ -150,10 +149,8 @@ void linkingt::detailed_conflict_report_rec(
150149
t1.id()==ID_array)
151150
{
152151
if(
153-
depth > 0 && !base_type_eq(
154-
to_type_with_subtype(t1).subtype(),
155-
to_type_with_subtype(t2).subtype(),
156-
ns))
152+
depth > 0 &&
153+
to_type_with_subtype(t1).subtype() != to_type_with_subtype(t2).subtype())
157154
{
158155
if(conflict_path.type().id() == ID_pointer)
159156
conflict_path = dereference_exprt(conflict_path);
@@ -202,7 +199,7 @@ void linkingt::detailed_conflict_report_rec(
202199
msg+=id2string(components2[i].get_name())+')';
203200
break;
204201
}
205-
else if(!base_type_eq(subtype1, subtype2, ns))
202+
else if(subtype1 != subtype2)
206203
{
207204
typedef std::unordered_set<typet, irep_hash> type_sett;
208205
type_sett parent_types;
@@ -332,7 +329,7 @@ void linkingt::detailed_conflict_report_rec(
332329
msg+=std::to_string(parameters1.size())+'/';
333330
msg+=std::to_string(parameters2.size())+')';
334331
}
335-
else if(!base_type_eq(return_type1, return_type2, ns))
332+
else if(return_type1 != return_type2)
336333
{
337334
conflict_path=
338335
index_exprt(conflict_path,
@@ -356,7 +353,7 @@ void linkingt::detailed_conflict_report_rec(
356353
const typet &subtype1=parameters1[i].type();
357354
const typet &subtype2=parameters2[i].type();
358355

359-
if(!base_type_eq(subtype1, subtype2, ns))
356+
if(subtype1 != subtype2)
360357
{
361358
conflict_path=
362359
index_exprt(conflict_path,
@@ -475,7 +472,7 @@ void linkingt::duplicate_code_symbol(
475472
symbolt &new_symbol)
476473
{
477474
// Both are functions.
478-
if(!base_type_eq(old_symbol.type, new_symbol.type, ns))
475+
if(old_symbol.type != new_symbol.type)
479476
{
480477
const code_typet &old_t=to_code_type(old_symbol.type);
481478
const code_typet &new_t=to_code_type(new_symbol.type);
@@ -486,11 +483,8 @@ void linkingt::duplicate_code_symbol(
486483
// casts we need to fail hard
487484
if(old_symbol.type.get_bool(ID_C_incomplete) && old_symbol.value.is_nil())
488485
{
489-
if(base_type_eq(old_t.return_type(), new_t.return_type(), ns))
490-
link_warning(
491-
old_symbol,
492-
new_symbol,
493-
"implicit function declaration");
486+
if(old_t.return_type() == new_t.return_type())
487+
link_warning(old_symbol, new_symbol, "implicit function declaration");
494488
else
495489
link_error(
496490
old_symbol,
@@ -504,7 +498,7 @@ void linkingt::duplicate_code_symbol(
504498
else if(
505499
new_symbol.type.get_bool(ID_C_incomplete) && new_symbol.value.is_nil())
506500
{
507-
if(base_type_eq(old_t.return_type(), new_t.return_type(), ns))
501+
if(old_t.return_type() == new_t.return_type())
508502
link_warning(
509503
old_symbol,
510504
new_symbol,
@@ -516,13 +510,12 @@ void linkingt::duplicate_code_symbol(
516510
"implicit function declaration");
517511
}
518512
// handle (incomplete) function prototypes
519-
else if(base_type_eq(old_t.return_type(), new_t.return_type(), ns) &&
520-
((old_t.parameters().empty() &&
521-
old_t.has_ellipsis() &&
522-
old_symbol.value.is_nil()) ||
523-
(new_t.parameters().empty() &&
524-
new_t.has_ellipsis() &&
525-
new_symbol.value.is_nil())))
513+
else if(
514+
old_t.return_type() == new_t.return_type() &&
515+
((old_t.parameters().empty() && old_t.has_ellipsis() &&
516+
old_symbol.value.is_nil()) ||
517+
(new_t.parameters().empty() && new_t.has_ellipsis() &&
518+
new_symbol.value.is_nil())))
526519
{
527520
if(old_t.parameters().empty() &&
528521
old_t.has_ellipsis() &&
@@ -572,9 +565,9 @@ void linkingt::duplicate_code_symbol(
572565
}
573566
// conflicting declarations without a definition, matching return
574567
// types
575-
else if(base_type_eq(old_t.return_type(), new_t.return_type(), ns) &&
576-
old_symbol.value.is_nil() &&
577-
new_symbol.value.is_nil())
568+
else if(
569+
old_t.return_type() == new_t.return_type() && old_symbol.value.is_nil() &&
570+
new_symbol.value.is_nil())
578571
{
579572
link_warning(
580573
old_symbol,
@@ -613,7 +606,7 @@ void linkingt::duplicate_code_symbol(
613606
typedef std::deque<std::pair<typet, typet> > conflictst;
614607
conflictst conflicts;
615608

616-
if(!base_type_eq(old_t.return_type(), new_t.return_type(), ns))
609+
if(old_t.return_type() != new_t.return_type())
617610
conflicts.push_back(
618611
std::make_pair(old_t.return_type(), new_t.return_type()));
619612

@@ -625,7 +618,7 @@ void linkingt::duplicate_code_symbol(
625618
n_it!=new_t.parameters().end();
626619
++o_it, ++n_it)
627620
{
628-
if(!base_type_eq(o_it->type(), n_it->type(), ns))
621+
if(o_it->type() != n_it->type())
629622
conflicts.push_back(
630623
std::make_pair(o_it->type(), n_it->type()));
631624
}
@@ -718,7 +711,7 @@ void linkingt::duplicate_code_symbol(
718711

719712
bool found=false;
720713
for(const auto &c : union_type.components())
721-
if(base_type_eq(c.type(), src_type, ns))
714+
if(c.type() == src_type)
722715
{
723716
found=true;
724717
if(warn_msg.empty())
@@ -793,7 +786,7 @@ void linkingt::duplicate_code_symbol(
793786
{
794787
// ok, silently ignore
795788
}
796-
else if(base_type_eq(old_symbol.type, new_symbol.type, ns))
789+
else if(old_symbol.type == new_symbol.type)
797790
{
798791
// keep the one in old_symbol -- libraries come last!
799792
debug().source_location = new_symbol.location;
@@ -816,7 +809,7 @@ bool linkingt::adjust_object_type_rec(
816809
const typet &t2,
817810
adjust_type_infot &info)
818811
{
819-
if(base_type_eq(t1, t2, ns))
812+
if(t1 == t2)
820813
return false;
821814

822815
if(
@@ -1025,7 +1018,7 @@ void linkingt::duplicate_object_symbol(
10251018
// both are variables
10261019
bool set_to_new = false;
10271020

1028-
if(!base_type_eq(old_symbol.type, new_symbol.type, ns))
1021+
if(old_symbol.type != new_symbol.type)
10291022
{
10301023
bool failed=
10311024
adjust_object_type(old_symbol, new_symbol, set_to_new);
@@ -1081,7 +1074,7 @@ void linkingt::duplicate_object_symbol(
10811074
simplify(tmp_old, ns);
10821075
simplify(tmp_new, ns);
10831076

1084-
if(base_type_eq(tmp_old, tmp_new, ns))
1077+
if(tmp_old == tmp_new)
10851078
{
10861079
// ok, the same
10871080
}
@@ -1211,10 +1204,8 @@ void linkingt::duplicate_type_symbol(
12111204

12121205
if(
12131206
old_symbol.type.id() == ID_array && new_symbol.type.id() == ID_array &&
1214-
base_type_eq(
1215-
to_array_type(old_symbol.type).element_type(),
1216-
to_array_type(new_symbol.type).element_type(),
1217-
ns))
1207+
to_array_type(old_symbol.type).element_type() ==
1208+
to_array_type(new_symbol.type).element_type())
12181209
{
12191210
if(to_array_type(old_symbol.type).size().is_nil() &&
12201211
to_array_type(new_symbol.type).size().is_not_nil())
@@ -1286,10 +1277,8 @@ bool linkingt::needs_renaming_type(
12861277

12871278
if(
12881279
old_symbol.type.id() == ID_array && new_symbol.type.id() == ID_array &&
1289-
base_type_eq(
1290-
to_array_type(old_symbol.type).element_type(),
1291-
to_array_type(new_symbol.type).element_type(),
1292-
ns))
1280+
to_array_type(old_symbol.type).element_type() ==
1281+
to_array_type(new_symbol.type).element_type())
12931282
{
12941283
if(to_array_type(old_symbol.type).size().is_nil() &&
12951284
to_array_type(new_symbol.type).size().is_not_nil())

0 commit comments

Comments
 (0)