Skip to content

Commit b9b4ad6

Browse files
committed
Remove base_type_eq
We consistently use tag types, and two expressions are now base_type_eq if, and only if, they have types that compare equal.
1 parent 5112622 commit b9b4ad6

File tree

10 files changed

+42
-397
lines changed

10 files changed

+42
-397
lines changed

scripts/expected_doxygen_warnings.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ warning: Included by graph for 'expr_util.h' not generated, too many nodes (60),
9292
warning: Included by graph for 'invariant.h' not generated, too many nodes (187), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
9393
warning: Included by graph for 'irep.h' not generated, too many nodes (62), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
9494
warning: Included by graph for 'message.h' not generated, too many nodes (116), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
95-
warning: Included by graph for 'namespace.h' not generated, too many nodes (111), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
95+
warning: Included by graph for 'namespace.h' not generated, too many nodes (110), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
9696
warning: Included by graph for 'prefix.h' not generated, too many nodes (86), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
9797
warning: Included by graph for 'simplify_expr.h' not generated, too many nodes (76), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
9898
warning: Included by graph for 'std_code.h' not generated, too many nodes (78), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
9999
warning: Included by graph for 'std_expr.h' not generated, too many nodes (246), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
100-
warning: Included by graph for 'std_types.h' not generated, too many nodes (124), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
100+
warning: Included by graph for 'std_types.h' not generated, too many nodes (123), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.
101101
warning: Included by graph for 'symbol_table.h' not generated, too many nodes (95), threshold is 60. Consider increasing DOT_GRAPH_MAX_NODES.

src/analyses/does_remove_const.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Author: Diffblue Ltd.
1515
#include <util/type.h>
1616
#include <util/expr.h>
1717
#include <util/std_code.h>
18-
#include <util/base_type.h>
1918

2019
/// A naive analysis to look for casts that remove const-ness from pointers.
2120
/// \param goto_program: the goto program to check
@@ -74,7 +73,7 @@ bool does_remove_constt::does_expr_lose_const(const exprt &expr) const
7473
for(const exprt &op : expr.operands())
7574
{
7675
const typet &op_type=op.type();
77-
if(base_type_eq(op_type, root_type, ns))
76+
if(op_type == root_type)
7877
{
7978
// Is this child more const-qualified than the root
8079
if(!does_type_preserve_const_correctness(&root_type, &op_type))

src/goto-instrument/replace_calls.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Author: Daniel Poetzl
1515

1616
#include <goto-programs/remove_returns.h>
1717

18-
#include <util/base_type.h>
1918
#include <util/exception_utils.h>
2019
#include <util/invariant.h>
2120
#include <util/irep.h>
@@ -165,12 +164,13 @@ void replace_callst::check_replacement_map(
165164
auto it1 = goto_functions.function_map.find(p.first);
166165
if(it1 != goto_functions.function_map.end())
167166
{
168-
if(!base_type_eq(
169-
ns.lookup(it1->first).type, ns.lookup(it2->first).type, ns))
167+
if(ns.lookup(it1->first).type != ns.lookup(it2->first).type)
168+
{
170169
throw invalid_command_line_argument_exceptiont(
171170
"functions " + id2string(p.first) + " and " + id2string(p.second) +
172171
" are not type-compatible",
173172
"--replace-calls");
173+
}
174174
}
175175
}
176176
}

src/goto-instrument/value_set_fi_fp_removal.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Author: Daniel Kroening, [email protected]
1313

1414
#include <pointer-analysis/value_set_analysis_fi.h>
1515

16-
#include <util/base_type.h>
1716
#include <util/c_types.h>
1817
#include <util/expanding_vector.h>
1918
#include <util/fresh_symbol.h>

src/goto-programs/goto_program.cpp

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

17-
#include <util/base_type.h>
1817
#include <util/expr_iterator.h>
1918
#include <util/find_symbols.h>
2019
#include <util/invariant.h>
@@ -740,7 +739,7 @@ void goto_programt::instructiont::validate(
740739
if(!ns.lookup(goto_id, table_symbol))
741740
{
742741
bool symbol_expr_type_matches_symbol_table =
743-
base_type_eq(goto_symbol_expr.type(), table_symbol->type, ns);
742+
goto_symbol_expr.type() == table_symbol->type;
744743

745744
if(
746745
!symbol_expr_type_matches_symbol_table &&
@@ -763,7 +762,7 @@ void goto_programt::instructiont::validate(
763762
table_symbol_type.return_type();
764763

765764
symbol_expr_type_matches_symbol_table =
766-
base_type_eq(goto_symbol_expr_type, table_symbol_type, ns);
765+
goto_symbol_expr_type == table_symbol_type;
767766
}
768767
}
769768

src/goto-programs/link_goto_model.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Author: Michael Tautschnig, Daniel Kroening
1313

1414
#include <unordered_set>
1515

16-
#include <util/base_type.h>
1716
#include <util/symbol.h>
1817
#include <util/rename_symbol.h>
1918

@@ -123,15 +122,14 @@ static bool link_functions(
123122
INVARIANT(symbol.value.id() == ID_symbol, "must have symbol");
124123
const irep_idt &id = to_symbol_expr(symbol.value).get_identifier();
125124

126-
#if 0
127-
if(!base_type_eq(symbol.type, ns.lookup(id).type, ns))
125+
#if 0
126+
if(symbol.type != ns.lookup(id).type)
128127
{
129128
std::cerr << symbol << '\n';
130129
std::cerr << ns.lookup(id) << '\n';
131130
}
132-
INVARIANT(base_type_eq(symbol.type, ns.lookup(id).type, ns),
133-
"type matches");
134-
#endif
131+
INVARIANT(symbol.type == ns.lookup(id).type, "type matches");
132+
#endif
135133

136134
macro_application.insert_expr(symbol.name, id);
137135
}

src/linking/linking.cpp

Lines changed: 30 additions & 36 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/find_symbols.h>
1918
#include <util/mathematical_types.h>
2019
#include <util/pointer_offset_size.h>
@@ -139,8 +138,7 @@ void linkingt::detailed_conflict_report_rec(
139138
else if(t1.id()==ID_pointer ||
140139
t1.id()==ID_array)
141140
{
142-
if(depth>0 &&
143-
!base_type_eq(t1.subtype(), t2.subtype(), ns))
141+
if(depth > 0 && t1.subtype() != t2.subtype())
144142
{
145143
if(conflict_path.type().id() == ID_pointer)
146144
conflict_path = dereference_exprt(conflict_path);
@@ -189,7 +187,7 @@ void linkingt::detailed_conflict_report_rec(
189187
msg+=id2string(components2[i].get_name())+')';
190188
break;
191189
}
192-
else if(!base_type_eq(subtype1, subtype2, ns))
190+
else if(subtype1 != subtype2)
193191
{
194192
typedef std::unordered_set<typet, irep_hash> type_sett;
195193
type_sett parent_types;
@@ -313,7 +311,7 @@ void linkingt::detailed_conflict_report_rec(
313311
msg+=std::to_string(parameters1.size())+'/';
314312
msg+=std::to_string(parameters2.size())+')';
315313
}
316-
else if(!base_type_eq(return_type1, return_type2, ns))
314+
else if(return_type1 != return_type2)
317315
{
318316
conflict_path=
319317
index_exprt(conflict_path,
@@ -337,7 +335,7 @@ void linkingt::detailed_conflict_report_rec(
337335
const typet &subtype1=parameters1[i].type();
338336
const typet &subtype2=parameters2[i].type();
339337

340-
if(!base_type_eq(subtype1, subtype2, ns))
338+
if(subtype1 != subtype2)
341339
{
342340
conflict_path=
343341
index_exprt(conflict_path,
@@ -456,7 +454,7 @@ void linkingt::duplicate_code_symbol(
456454
symbolt &new_symbol)
457455
{
458456
// Both are functions.
459-
if(!base_type_eq(old_symbol.type, new_symbol.type, ns))
457+
if(old_symbol.type != new_symbol.type)
460458
{
461459
const code_typet &old_t=to_code_type(old_symbol.type);
462460
const code_typet &new_t=to_code_type(new_symbol.type);
@@ -467,11 +465,8 @@ void linkingt::duplicate_code_symbol(
467465
// casts we need to fail hard
468466
if(old_symbol.type.get_bool(ID_C_incomplete) && old_symbol.value.is_nil())
469467
{
470-
if(base_type_eq(old_t.return_type(), new_t.return_type(), ns))
471-
link_warning(
472-
old_symbol,
473-
new_symbol,
474-
"implicit function declaration");
468+
if(old_t.return_type() == new_t.return_type())
469+
link_warning(old_symbol, new_symbol, "implicit function declaration");
475470
else
476471
link_error(
477472
old_symbol,
@@ -485,7 +480,7 @@ void linkingt::duplicate_code_symbol(
485480
else if(
486481
new_symbol.type.get_bool(ID_C_incomplete) && new_symbol.value.is_nil())
487482
{
488-
if(base_type_eq(old_t.return_type(), new_t.return_type(), ns))
483+
if(old_t.return_type() == new_t.return_type())
489484
link_warning(
490485
old_symbol,
491486
new_symbol,
@@ -497,13 +492,12 @@ void linkingt::duplicate_code_symbol(
497492
"implicit function declaration");
498493
}
499494
// handle (incomplete) function prototypes
500-
else if(base_type_eq(old_t.return_type(), new_t.return_type(), ns) &&
501-
((old_t.parameters().empty() &&
502-
old_t.has_ellipsis() &&
503-
old_symbol.value.is_nil()) ||
504-
(new_t.parameters().empty() &&
505-
new_t.has_ellipsis() &&
506-
new_symbol.value.is_nil())))
495+
else if(
496+
old_t.return_type() == new_t.return_type() &&
497+
((old_t.parameters().empty() && old_t.has_ellipsis() &&
498+
old_symbol.value.is_nil()) ||
499+
(new_t.parameters().empty() && new_t.has_ellipsis() &&
500+
new_symbol.value.is_nil())))
507501
{
508502
if(old_t.parameters().empty() &&
509503
old_t.has_ellipsis() &&
@@ -553,9 +547,9 @@ void linkingt::duplicate_code_symbol(
553547
}
554548
// conflicting declarations without a definition, matching return
555549
// types
556-
else if(base_type_eq(old_t.return_type(), new_t.return_type(), ns) &&
557-
old_symbol.value.is_nil() &&
558-
new_symbol.value.is_nil())
550+
else if(
551+
old_t.return_type() == new_t.return_type() && old_symbol.value.is_nil() &&
552+
new_symbol.value.is_nil())
559553
{
560554
link_warning(
561555
old_symbol,
@@ -594,7 +588,7 @@ void linkingt::duplicate_code_symbol(
594588
typedef std::deque<std::pair<typet, typet> > conflictst;
595589
conflictst conflicts;
596590

597-
if(!base_type_eq(old_t.return_type(), new_t.return_type(), ns))
591+
if(old_t.return_type() != new_t.return_type())
598592
conflicts.push_back(
599593
std::make_pair(old_t.return_type(), new_t.return_type()));
600594

@@ -606,7 +600,7 @@ void linkingt::duplicate_code_symbol(
606600
n_it!=new_t.parameters().end();
607601
++o_it, ++n_it)
608602
{
609-
if(!base_type_eq(o_it->type(), n_it->type(), ns))
603+
if(o_it->type() != n_it->type())
610604
conflicts.push_back(
611605
std::make_pair(o_it->type(), n_it->type()));
612606
}
@@ -699,7 +693,7 @@ void linkingt::duplicate_code_symbol(
699693

700694
bool found=false;
701695
for(const auto &c : union_type.components())
702-
if(base_type_eq(c.type(), src_type, ns))
696+
if(c.type() == src_type)
703697
{
704698
found=true;
705699
if(warn_msg.empty())
@@ -774,7 +768,7 @@ void linkingt::duplicate_code_symbol(
774768
{
775769
// ok, silently ignore
776770
}
777-
else if(base_type_eq(old_symbol.type, new_symbol.type, ns))
771+
else if(old_symbol.type == new_symbol.type)
778772
{
779773
// keep the one in old_symbol -- libraries come last!
780774
warning().source_location=new_symbol.location;
@@ -797,7 +791,7 @@ bool linkingt::adjust_object_type_rec(
797791
const typet &t2,
798792
adjust_type_infot &info)
799793
{
800-
if(base_type_eq(t1, t2, ns))
794+
if(t1 == t2)
801795
return false;
802796

803797
if(
@@ -993,7 +987,7 @@ void linkingt::duplicate_object_symbol(
993987
// both are variables
994988
bool set_to_new = false;
995989

996-
if(!base_type_eq(old_symbol.type, new_symbol.type, ns))
990+
if(old_symbol.type != new_symbol.type)
997991
{
998992
bool failed=
999993
adjust_object_type(old_symbol, new_symbol, set_to_new);
@@ -1051,7 +1045,7 @@ void linkingt::duplicate_object_symbol(
10511045
simplify(tmp_old, ns);
10521046
simplify(tmp_new, ns);
10531047

1054-
if(base_type_eq(tmp_old, tmp_new, ns))
1048+
if(tmp_old == tmp_new)
10551049
{
10561050
// ok, the same
10571051
}
@@ -1176,9 +1170,9 @@ void linkingt::duplicate_type_symbol(
11761170
return;
11771171
}
11781172

1179-
if(old_symbol.type.id()==ID_array &&
1180-
new_symbol.type.id()==ID_array &&
1181-
base_type_eq(old_symbol.type.subtype(), new_symbol.type.subtype(), ns))
1173+
if(
1174+
old_symbol.type.id() == ID_array && new_symbol.type.id() == ID_array &&
1175+
old_symbol.type.subtype() == new_symbol.type.subtype())
11821176
{
11831177
if(to_array_type(old_symbol.type).size().is_nil() &&
11841178
to_array_type(new_symbol.type).size().is_not_nil())
@@ -1248,9 +1242,9 @@ bool linkingt::needs_renaming_type(
12481242
to_union_type(new_symbol.type).is_incomplete())
12491243
return false; // not different
12501244

1251-
if(old_symbol.type.id()==ID_array &&
1252-
new_symbol.type.id()==ID_array &&
1253-
base_type_eq(old_symbol.type.subtype(), new_symbol.type.subtype(), ns))
1245+
if(
1246+
old_symbol.type.id() == ID_array && new_symbol.type.id() == ID_array &&
1247+
old_symbol.type.subtype() == new_symbol.type.subtype())
12541248
{
12551249
if(to_array_type(old_symbol.type).size().is_nil() &&
12561250
to_array_type(new_symbol.type).size().is_not_nil())

src/util/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ SRC = allocate_objects.cpp \
22
arith_tools.cpp \
33
array_element_from_pointer.cpp \
44
array_name.cpp \
5-
base_type.cpp \
65
bv_arithmetic.cpp \
76
byte_operators.cpp \
87
c_types.cpp \

0 commit comments

Comments
 (0)