Skip to content

Commit 9d9e213

Browse files
authored
Merge pull request #6587 from diffblue/remove_ID_size_usage
array_typet and vector_typet APIs
2 parents 195458a + a7e039b commit 9d9e213

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+180
-153
lines changed

src/analyses/goto_rw.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,15 @@ void rw_range_sett::get_objects_index(
262262
{
263263
const vector_typet &vector_type=to_vector_type(type);
264264

265-
auto subtype_bits = pointer_offset_bits(vector_type.subtype(), ns);
265+
auto subtype_bits = pointer_offset_bits(vector_type.element_type(), ns);
266266

267267
sub_size = subtype_bits.has_value() ? to_range_spect(*subtype_bits) : -1;
268268
}
269269
else if(type.id()==ID_array)
270270
{
271271
const array_typet &array_type=to_array_type(type);
272272

273-
auto subtype_bits = pointer_offset_bits(array_type.subtype(), ns);
273+
auto subtype_bits = pointer_offset_bits(array_type.element_type(), ns);
274274

275275
sub_size = subtype_bits.has_value() ? to_range_spect(*subtype_bits) : -1;
276276
}
@@ -301,7 +301,7 @@ void rw_range_sett::get_objects_array(
301301
{
302302
const array_typet &array_type = expr.type();
303303

304-
auto subtype_bits = pointer_offset_bits(array_type.subtype(), ns);
304+
auto subtype_bits = pointer_offset_bits(array_type.element_type(), ns);
305305

306306
range_spect sub_size;
307307

@@ -608,7 +608,7 @@ void rw_range_sett::get_objects_rec(const typet &type)
608608
if(type.id()==ID_array)
609609
{
610610
const auto &array_type = to_array_type(type);
611-
get_objects_rec(array_type.subtype());
611+
get_objects_rec(array_type.element_type());
612612
get_objects_rec(get_modet::READ, array_type.size());
613613
}
614614
}

src/analyses/variable-sensitivity/abstract_aggregate_object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ struct array_aggregate_typet
164164
static typet read_type(const typet &, const typet &object_type)
165165
{
166166
array_typet array_type(to_array_type(object_type));
167-
return array_type.subtype();
167+
return array_type.element_type();
168168
}
169169

170170
static void get_statistics(

src/ansi-c/c_expr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ shuffle_vector_exprt::shuffle_vector_exprt(
2323
op1() = std::move(*vector2);
2424

2525
const vector_typet &vt = to_vector_type(op0().type());
26-
type() =
27-
vector_typet{vt.subtype(), from_integer(indices.size(), vt.size().type())};
26+
type() = vector_typet{vt.element_type(),
27+
from_integer(indices.size(), vt.size().type())};
2828

2929
op2().operands().swap(indices);
3030
}

src/ansi-c/c_typecast.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,9 @@ bool check_c_implicit_typecast(
223223
}
224224
}
225225

226-
if(dest_type.id()==ID_array &&
227-
src_type.subtype()==dest_type.subtype())
226+
if(
227+
dest_type.id() == ID_array &&
228+
src_type.subtype() == to_array_type(dest_type).element_type())
228229
return false;
229230

230231
if(dest_type.id()==ID_bool ||

src/ansi-c/c_typecheck_expr.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3389,15 +3389,16 @@ bool c_typecheck_baset::gcc_vector_types_compatible(
33893389
return false;
33903390

33913391
// compare subtype
3392-
if((type0.subtype().id()==ID_signedbv ||
3393-
type0.subtype().id()==ID_unsignedbv) &&
3394-
(type1.subtype().id()==ID_signedbv ||
3395-
type1.subtype().id()==ID_unsignedbv) &&
3396-
to_bitvector_type(type0.subtype()).get_width()==
3397-
to_bitvector_type(type1.subtype()).get_width())
3392+
if(
3393+
(type0.element_type().id() == ID_signedbv ||
3394+
type0.element_type().id() == ID_unsignedbv) &&
3395+
(type1.element_type().id() == ID_signedbv ||
3396+
type1.element_type().id() == ID_unsignedbv) &&
3397+
to_bitvector_type(type0.element_type()).get_width() ==
3398+
to_bitvector_type(type1.element_type()).get_width())
33983399
return true;
33993400

3400-
return type0.subtype()==type1.subtype();
3401+
return type0.element_type() == type1.element_type();
34013402
}
34023403

34033404
void c_typecheck_baset::typecheck_expr_binary_arithmetic(exprt &expr)

src/ansi-c/c_typecheck_gcc_polymorphic_builtins.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,8 @@ exprt c_typecheck_baset::typecheck_shuffle_vector(
14401440
CHECK_RETURN(input_size.has_value());
14411441
if(arg1.has_value())
14421442
input_size = *input_size * 2;
1443-
constant_exprt size = from_integer(*input_size, indices_type.subtype());
1443+
constant_exprt size =
1444+
from_integer(*input_size, indices_type.element_type());
14441445

14451446
for(std::size_t i = 0; i < indices_size; ++i)
14461447
{

src/ansi-c/c_typecheck_initializer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ void c_typecheck_baset::designator_enter(
318318
if(array_type.size().is_nil())
319319
{
320320
entry.size=0;
321-
entry.subtype=array_type.subtype();
321+
entry.subtype = array_type.element_type();
322322
}
323323
else
324324
{
@@ -332,7 +332,7 @@ void c_typecheck_baset::designator_enter(
332332
}
333333

334334
entry.size = numeric_cast_v<std::size_t>(*array_size);
335-
entry.subtype=array_type.subtype();
335+
entry.subtype = array_type.element_type();
336336
}
337337
}
338338
else if(full_type.id()==ID_vector)
@@ -350,7 +350,7 @@ void c_typecheck_baset::designator_enter(
350350
}
351351

352352
entry.size = numeric_cast_v<std::size_t>(*vector_size);
353-
entry.subtype=vector_type.subtype();
353+
entry.subtype = vector_type.element_type();
354354
}
355355
else
356356
UNREACHABLE;

src/ansi-c/c_typecheck_type.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -526,18 +526,18 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type)
526526
const source_locationt size_source_location = size.find_source_location();
527527

528528
// check subtype
529-
typecheck_type(type.subtype());
529+
typecheck_type(type.element_type());
530530

531531
// we don't allow void as subtype
532-
if(type.subtype().id() == ID_empty)
532+
if(type.element_type().id() == ID_empty)
533533
{
534534
error().source_location=type.source_location();
535535
error() << "array of voids" << eom;
536536
throw 0;
537537
}
538538

539539
// we don't allow incomplete structs or unions as subtype
540-
const typet &followed_subtype = follow(type.subtype());
540+
const typet &followed_subtype = follow(type.element_type());
541541

542542
if(
543543
(followed_subtype.id() == ID_struct || followed_subtype.id() == ID_union) &&
@@ -550,7 +550,7 @@ void c_typecheck_baset::typecheck_array_type(array_typet &type)
550550
}
551551

552552
// we don't allow functions as subtype
553-
if(type.subtype().id() == ID_code)
553+
if(type.element_type().id() == ID_code)
554554
{
555555
// ISO/IEC 9899 6.7.5.2
556556
error().source_location = type.source_location();

src/ansi-c/expr2c.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ std::string expr2ct::convert_rec(
587587
const mp_integer size_int = numeric_cast_v<mp_integer>(vector_type.size());
588588
std::string dest="__gcc_v"+integer2string(size_int);
589589

590-
std::string tmp=convert(vector_type.subtype());
590+
std::string tmp = convert(vector_type.element_type());
591591

592592
if(tmp=="signed char" || tmp=="char")
593593
dest+="qi";
@@ -603,7 +603,7 @@ std::string expr2ct::convert_rec(
603603
dest+="df";
604604
else
605605
{
606-
const std::string subtype=convert(vector_type.subtype());
606+
const std::string subtype = convert(vector_type.element_type());
607607
dest=subtype;
608608
dest+=" __attribute__((vector_size (";
609609
dest+=convert(vector_type.size());

src/cpp/cpp_declarator_converter.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,11 @@ void cpp_declarator_convertert::combine_types(
313313
}
314314
else if(symbol.type==decl_type)
315315
return; // ok
316-
else if(symbol.type.id()==ID_array &&
317-
symbol.type.find(ID_size).is_nil() &&
318-
decl_type.id()==ID_array &&
319-
symbol.type.subtype()==decl_type.subtype())
316+
else if(
317+
symbol.type.id() == ID_array &&
318+
to_array_type(symbol.type).size().is_nil() && decl_type.id() == ID_array &&
319+
to_array_type(symbol.type).element_type() ==
320+
to_array_type(decl_type).element_type())
320321
{
321322
symbol.type = decl_type;
322323
return; // ok

0 commit comments

Comments
 (0)