Skip to content

Commit 7153dc5

Browse files
authored
Merge pull request #6989 from diffblue/remove_base_type
remove uses of base_type_eq
2 parents c00319e + e42aaf7 commit 7153dc5

12 files changed

+41
-408
lines changed

src/analyses/does_remove_const.cpp

+4-10
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,13 @@ 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

2019
/// A naive analysis to look for casts that remove const-ness from pointers.
2120
/// \param goto_program: the goto program to check
22-
/// \param ns: the namespace of the goto program (used for checking type
23-
/// equality)
24-
does_remove_constt::does_remove_constt(
25-
const goto_programt &goto_program,
26-
const namespacet &ns):
27-
goto_program(goto_program),
28-
ns(ns)
21+
does_remove_constt::does_remove_constt(const goto_programt &goto_program)
22+
: goto_program(goto_program)
2923
{}
3024

3125
/// A naive analysis to look for casts that remove const-ness from pointers.
@@ -69,11 +63,11 @@ bool does_remove_constt::does_expr_lose_const(const exprt &expr) const
6963
{
7064
const typet &root_type=expr.type();
7165

72-
// Look in each child that has the same base type as the root
66+
// Look in each child that has the same type as the root
7367
for(const exprt &op : expr.operands())
7468
{
7569
const typet &op_type=op.type();
76-
if(base_type_eq(op_type, root_type, ns))
70+
if(op_type == root_type)
7771
{
7872
// Is this child more const-qualified than the root
7973
if(!does_type_preserve_const_correctness(&root_type, &op_type))

src/analyses/does_remove_const.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,14 @@ Author: Diffblue Ltd.
1414
#include <utility>
1515

1616
class goto_programt;
17-
class namespacet;
1817
class exprt;
1918
class source_locationt;
2019
class typet;
2120

2221
class does_remove_constt
2322
{
2423
public:
25-
does_remove_constt(const goto_programt &goto_program, const namespacet &ns);
24+
explicit does_remove_constt(const goto_programt &);
2625
std::pair<bool, source_locationt> operator()() const;
2726

2827
private:
@@ -35,7 +34,6 @@ class does_remove_constt
3534
const typet *target_type, const typet *source_type) const;
3635

3736
const goto_programt &goto_program;
38-
const namespacet &ns;
3937

4038
friend class does_remove_const_testt;
4139
};

src/goto-instrument/replace_calls.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ Author: Daniel Poetzl
1313

1414
#include "replace_calls.h"
1515

16-
#include <util/base_type.h>
1716
#include <util/exception_utils.h>
1817
#include <util/invariant.h>
1918
#include <util/namespace.h>
@@ -161,8 +160,7 @@ void replace_callst::check_replacement_map(
161160
auto it1 = goto_functions.function_map.find(p.first);
162161
if(it1 != goto_functions.function_map.end())
163162
{
164-
if(!base_type_eq(
165-
ns.lookup(it1->first).type, ns.lookup(it2->first).type, ns))
163+
if(ns.lookup(it1->first).type != ns.lookup(it2->first).type)
166164
throw invalid_command_line_argument_exceptiont(
167165
"functions " + id2string(p.first) + " and " + id2string(p.second) +
168166
" are not type-compatible",

src/goto-programs/goto_program.cpp

+2-3
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/goto-programs/remove_function_pointers.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ void remove_function_pointerst::remove_function_pointer(
270270

271271
const exprt &pointer = function.pointer();
272272
remove_const_function_pointerst::functionst functions;
273-
does_remove_constt const_removal_check(goto_program, ns);
273+
does_remove_constt const_removal_check(goto_program);
274274
const auto does_remove_const = const_removal_check();
275275
messaget log{message_handler};
276276
if(does_remove_const.first)

src/linking/linking.cpp

+29-40
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())

src/util/Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
SRC = arith_tools.cpp \
22
array_element_from_pointer.cpp \
33
array_name.cpp \
4-
base_type.cpp \
54
bitvector_expr.cpp \
65
bitvector_types.cpp \
76
bv_arithmetic.cpp \

0 commit comments

Comments
 (0)