Skip to content

Commit e055075

Browse files
committed
attempt to remove base_type_eq in linker
1 parent ae165e1 commit e055075

File tree

1 file changed

+34
-18
lines changed

1 file changed

+34
-18
lines changed

src/linking/linking.cpp

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@ Author: Daniel Kroening, [email protected]
2727

2828
#include "linking_class.h"
2929

30+
bool my_base_type_eq(
31+
const typet &type1,
32+
const typet &type2,
33+
const namespacet &)
34+
{
35+
return type1 == type2;
36+
}
37+
38+
bool my_base_type_eq(
39+
const exprt &expr1,
40+
const exprt &expr2,
41+
const namespacet &ns)
42+
{
43+
return my_base_type_eq(expr1.type(), expr2.type(), ns);
44+
}
45+
3046
bool casting_replace_symbolt::replace_symbol_expr(symbol_exprt &s) const
3147
{
3248
expr_mapt::const_iterator it = expr_map.find(s.get_identifier());
@@ -150,7 +166,7 @@ void linkingt::detailed_conflict_report_rec(
150166
t1.id()==ID_array)
151167
{
152168
if(
153-
depth > 0 && !base_type_eq(
169+
depth > 0 && !my_base_type_eq(
154170
to_type_with_subtype(t1).subtype(),
155171
to_type_with_subtype(t2).subtype(),
156172
ns))
@@ -202,7 +218,7 @@ void linkingt::detailed_conflict_report_rec(
202218
msg+=id2string(components2[i].get_name())+')';
203219
break;
204220
}
205-
else if(!base_type_eq(subtype1, subtype2, ns))
221+
else if(!my_base_type_eq(subtype1, subtype2, ns))
206222
{
207223
typedef std::unordered_set<typet, irep_hash> type_sett;
208224
type_sett parent_types;
@@ -332,7 +348,7 @@ void linkingt::detailed_conflict_report_rec(
332348
msg+=std::to_string(parameters1.size())+'/';
333349
msg+=std::to_string(parameters2.size())+')';
334350
}
335-
else if(!base_type_eq(return_type1, return_type2, ns))
351+
else if(!my_base_type_eq(return_type1, return_type2, ns))
336352
{
337353
conflict_path=
338354
index_exprt(conflict_path,
@@ -356,7 +372,7 @@ void linkingt::detailed_conflict_report_rec(
356372
const typet &subtype1=parameters1[i].type();
357373
const typet &subtype2=parameters2[i].type();
358374

359-
if(!base_type_eq(subtype1, subtype2, ns))
375+
if(!my_base_type_eq(subtype1, subtype2, ns))
360376
{
361377
conflict_path=
362378
index_exprt(conflict_path,
@@ -475,7 +491,7 @@ void linkingt::duplicate_code_symbol(
475491
symbolt &new_symbol)
476492
{
477493
// Both are functions.
478-
if(!base_type_eq(old_symbol.type, new_symbol.type, ns))
494+
if(!my_base_type_eq(old_symbol.type, new_symbol.type, ns))
479495
{
480496
const code_typet &old_t=to_code_type(old_symbol.type);
481497
const code_typet &new_t=to_code_type(new_symbol.type);
@@ -486,7 +502,7 @@ void linkingt::duplicate_code_symbol(
486502
// casts we need to fail hard
487503
if(old_symbol.type.get_bool(ID_C_incomplete) && old_symbol.value.is_nil())
488504
{
489-
if(base_type_eq(old_t.return_type(), new_t.return_type(), ns))
505+
if(my_base_type_eq(old_t.return_type(), new_t.return_type(), ns))
490506
link_warning(
491507
old_symbol,
492508
new_symbol,
@@ -504,7 +520,7 @@ void linkingt::duplicate_code_symbol(
504520
else if(
505521
new_symbol.type.get_bool(ID_C_incomplete) && new_symbol.value.is_nil())
506522
{
507-
if(base_type_eq(old_t.return_type(), new_t.return_type(), ns))
523+
if(my_base_type_eq(old_t.return_type(), new_t.return_type(), ns))
508524
link_warning(
509525
old_symbol,
510526
new_symbol,
@@ -516,7 +532,7 @@ void linkingt::duplicate_code_symbol(
516532
"implicit function declaration");
517533
}
518534
// handle (incomplete) function prototypes
519-
else if(base_type_eq(old_t.return_type(), new_t.return_type(), ns) &&
535+
else if(my_base_type_eq(old_t.return_type(), new_t.return_type(), ns) &&
520536
((old_t.parameters().empty() &&
521537
old_t.has_ellipsis() &&
522538
old_symbol.value.is_nil()) ||
@@ -572,7 +588,7 @@ void linkingt::duplicate_code_symbol(
572588
}
573589
// conflicting declarations without a definition, matching return
574590
// types
575-
else if(base_type_eq(old_t.return_type(), new_t.return_type(), ns) &&
591+
else if(my_base_type_eq(old_t.return_type(), new_t.return_type(), ns) &&
576592
old_symbol.value.is_nil() &&
577593
new_symbol.value.is_nil())
578594
{
@@ -613,7 +629,7 @@ void linkingt::duplicate_code_symbol(
613629
typedef std::deque<std::pair<typet, typet> > conflictst;
614630
conflictst conflicts;
615631

616-
if(!base_type_eq(old_t.return_type(), new_t.return_type(), ns))
632+
if(!my_base_type_eq(old_t.return_type(), new_t.return_type(), ns))
617633
conflicts.push_back(
618634
std::make_pair(old_t.return_type(), new_t.return_type()));
619635

@@ -625,7 +641,7 @@ void linkingt::duplicate_code_symbol(
625641
n_it!=new_t.parameters().end();
626642
++o_it, ++n_it)
627643
{
628-
if(!base_type_eq(o_it->type(), n_it->type(), ns))
644+
if(!my_base_type_eq(o_it->type(), n_it->type(), ns))
629645
conflicts.push_back(
630646
std::make_pair(o_it->type(), n_it->type()));
631647
}
@@ -718,7 +734,7 @@ void linkingt::duplicate_code_symbol(
718734

719735
bool found=false;
720736
for(const auto &c : union_type.components())
721-
if(base_type_eq(c.type(), src_type, ns))
737+
if(my_base_type_eq(c.type(), src_type, ns))
722738
{
723739
found=true;
724740
if(warn_msg.empty())
@@ -793,7 +809,7 @@ void linkingt::duplicate_code_symbol(
793809
{
794810
// ok, silently ignore
795811
}
796-
else if(base_type_eq(old_symbol.type, new_symbol.type, ns))
812+
else if(my_base_type_eq(old_symbol.type, new_symbol.type, ns))
797813
{
798814
// keep the one in old_symbol -- libraries come last!
799815
debug().source_location = new_symbol.location;
@@ -816,7 +832,7 @@ bool linkingt::adjust_object_type_rec(
816832
const typet &t2,
817833
adjust_type_infot &info)
818834
{
819-
if(base_type_eq(t1, t2, ns))
835+
if(my_base_type_eq(t1, t2, ns))
820836
return false;
821837

822838
if(
@@ -1025,7 +1041,7 @@ void linkingt::duplicate_object_symbol(
10251041
// both are variables
10261042
bool set_to_new = false;
10271043

1028-
if(!base_type_eq(old_symbol.type, new_symbol.type, ns))
1044+
if(!my_base_type_eq(old_symbol.type, new_symbol.type, ns))
10291045
{
10301046
bool failed=
10311047
adjust_object_type(old_symbol, new_symbol, set_to_new);
@@ -1081,7 +1097,7 @@ void linkingt::duplicate_object_symbol(
10811097
simplify(tmp_old, ns);
10821098
simplify(tmp_new, ns);
10831099

1084-
if(base_type_eq(tmp_old, tmp_new, ns))
1100+
if(my_base_type_eq(tmp_old, tmp_new, ns))
10851101
{
10861102
// ok, the same
10871103
}
@@ -1211,7 +1227,7 @@ void linkingt::duplicate_type_symbol(
12111227

12121228
if(
12131229
old_symbol.type.id() == ID_array && new_symbol.type.id() == ID_array &&
1214-
base_type_eq(
1230+
my_base_type_eq(
12151231
to_array_type(old_symbol.type).element_type(),
12161232
to_array_type(new_symbol.type).element_type(),
12171233
ns))
@@ -1286,7 +1302,7 @@ bool linkingt::needs_renaming_type(
12861302

12871303
if(
12881304
old_symbol.type.id() == ID_array && new_symbol.type.id() == ID_array &&
1289-
base_type_eq(
1305+
my_base_type_eq(
12901306
to_array_type(old_symbol.type).element_type(),
12911307
to_array_type(new_symbol.type).element_type(),
12921308
ns))

0 commit comments

Comments
 (0)