Skip to content

Commit 5f18b69

Browse files
author
Daniel Kroening
committed
java frontend: symbol_type -> struct_tag
1 parent 65a6e30 commit 5f18b69

File tree

57 files changed

+483
-474
lines changed

Some content is hidden

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

57 files changed

+483
-474
lines changed

jbmc/src/java_bytecode/ci_lazy_methods.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ ci_lazy_methodst::ci_lazy_methodst(
6161
/// class
6262
static bool references_class_model(const exprt &expr)
6363
{
64-
static const symbol_typet class_type("java::java.lang.Class");
64+
static const struct_tag_typet class_type("java::java.lang.Class");
6565

6666
for(auto it = expr.depth_begin(); it != expr.depth_end(); ++it)
6767
{

jbmc/src/java_bytecode/ci_lazy_methods_needed.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void ci_lazy_methods_neededt::initialize_instantiated_classes_from_pointer(
101101
const pointer_typet &pointer_type,
102102
const namespacet &ns)
103103
{
104-
const symbol_typet &class_type = to_symbol_type(pointer_type.subtype());
104+
const auto &class_type = to_struct_tag_type(pointer_type.subtype());
105105
const auto &param_classid = class_type.get_identifier();
106106

107107
// Note here: different arrays may have different element types, so we should
@@ -139,10 +139,10 @@ void ci_lazy_methods_neededt::gather_field_types(
139139
{
140140
// If class_type is not a symbol this may be a reference array,
141141
// but we can't tell what type.
142-
if(class_type.id() == ID_symbol_type)
142+
if(class_type.id() == ID_struct_tag)
143143
{
144144
const typet &element_type =
145-
java_array_element_type(to_symbol_type(class_type));
145+
java_array_element_type(to_struct_tag_type(class_type));
146146
if(element_type.id() == ID_pointer)
147147
{
148148
// This is a reference array -- mark its element type available.
@@ -154,11 +154,11 @@ void ci_lazy_methods_neededt::gather_field_types(
154154
{
155155
for(const auto &field : underlying_type.components())
156156
{
157-
if(field.type().id() == ID_struct || field.type().id() == ID_symbol_type)
157+
if(field.type().id() == ID_struct || field.type().id() == ID_struct_tag)
158158
gather_field_types(field.type(), ns);
159159
else if(field.type().id() == ID_pointer)
160160
{
161-
if(field.type().subtype().id() == ID_symbol_type)
161+
if(field.type().subtype().id() == ID_struct_tag)
162162
{
163163
add_all_needed_classes(to_pointer_type(field.type()));
164164
}

jbmc/src/java_bytecode/generic_parameter_specialization_map_keys.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,29 +136,29 @@ void generic_parameter_specialization_map_keyst::insert_pairs_for_pointer(
136136
/// in the form of a symbol rather than a pointer (as opposed to the function
137137
/// insert_pairs_for_pointer). Own the keys and pop from their stack
138138
/// on destruction; otherwise do nothing.
139-
/// \param symbol_type symbol type to get the specialized generic types from
139+
/// \param struct_tag_type symbol type to get the specialized generic types from
140140
/// \param symbol_struct struct type of the symbol type, must be generic if
141141
/// the symbol is generic
142142
void generic_parameter_specialization_map_keyst::insert_pairs_for_symbol(
143-
const symbol_typet &symbol_type,
143+
const struct_tag_typet &struct_tag_type,
144144
const typet &symbol_struct)
145145
{
146146
// If the struct is:
147147
// - an incomplete class or
148148
// - a class that is neither generic nor implicitly generic (this
149149
// may be due to unsupported class signature)
150-
// then ignore the generic types in the symbol_type and do not add any pairs.
150+
// then ignore the generic types in the struct_tag_type and do not add any pairs.
151151
// TODO TG-1996 should decide how mocking and generics should work
152152
// together. Currently an incomplete class is never marked as generic. If
153153
// this changes in TG-1996 then the condition below should be updated.
154154
if(
155-
is_java_generic_symbol_type(symbol_type) &&
155+
is_java_generic_struct_tag_type(struct_tag_type) &&
156156
!symbol_struct.get_bool(ID_incomplete_class) &&
157157
(is_java_generic_class_type(symbol_struct) ||
158158
is_java_implicitly_generic_class_type(symbol_struct)))
159159
{
160-
const java_generic_symbol_typet &generic_symbol =
161-
to_java_generic_symbol_type(symbol_type);
160+
const java_generic_struct_tag_typet &generic_symbol =
161+
to_java_generic_struct_tag_type(struct_tag_type);
162162

163163
const std::vector<java_generic_parametert> &generic_parameters =
164164
get_all_generic_parameters(symbol_struct);

jbmc/src/java_bytecode/generic_parameter_specialization_map_keys.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
/// Author: Diffblue Ltd.
23

34
#ifndef CPROVER_JAVA_BYTECODE_GENERIC_PARAMETER_SPECIALIZATION_MAP_KEYS_H
@@ -50,9 +51,8 @@ class generic_parameter_specialization_map_keyst
5051
void insert_pairs_for_pointer(
5152
const pointer_typet &pointer_type,
5253
const typet &pointer_subtype_struct);
53-
void insert_pairs_for_symbol(
54-
const symbol_typet &symbol_type,
55-
const typet &symbol_struct);
54+
void
55+
insert_pairs_for_symbol(const struct_tag_typet &, const typet &symbol_struct);
5656

5757
private:
5858
/// Generic parameter specialization map to modify

jbmc/src/java_bytecode/java_bytecode_concurrency_instrumentation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ static void instrument_synchronized_code(
230230

231231
// Create the finally block with the same label targeted in the catch-push
232232
const symbolt &tmp_symbol = get_fresh_aux_symbol(
233-
java_reference_type(symbol_typet("java::java.lang.Throwable")),
233+
java_reference_type(struct_tag_typet("java::java.lang.Throwable")),
234234
id2string(symbol.name),
235235
"caught-synchronized-exception",
236236
code.source_location(),

jbmc/src/java_bytecode/java_bytecode_convert_class.cpp

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ void java_bytecode_convert_classt::convert(
338338

339339
if(!c.super_class.empty())
340340
{
341-
const symbol_typet base("java::" + id2string(c.super_class));
341+
const struct_tag_typet base("java::" + id2string(c.super_class));
342342

343343
// if the superclass is generic then the class has the superclass reference
344344
// including the generic info in its signature
@@ -350,7 +350,7 @@ void java_bytecode_convert_classt::convert(
350350
{
351351
try
352352
{
353-
const java_generic_symbol_typet generic_base(
353+
const java_generic_struct_tag_typet generic_base(
354354
base, superclass_ref.value(), qualified_classname);
355355
class_type.add_base(generic_base);
356356
}
@@ -378,7 +378,7 @@ void java_bytecode_convert_classt::convert(
378378
// interfaces are recorded as bases
379379
for(const auto &interface : c.implements)
380380
{
381-
const symbol_typet base("java::" + id2string(interface));
381+
const struct_tag_typet base("java::" + id2string(interface));
382382

383383
// if the interface is generic then the class has the interface reference
384384
// including the generic info in its signature
@@ -390,7 +390,7 @@ void java_bytecode_convert_classt::convert(
390390
{
391391
try
392392
{
393-
const java_generic_symbol_typet generic_base(
393+
const java_generic_struct_tag_typet generic_base(
394394
base, interface_ref.value(), qualified_classname);
395395
class_type.add_base(generic_base);
396396
}
@@ -772,26 +772,27 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
772772

773773
for(const char l : letters)
774774
{
775-
symbol_typet symbol_type=
776-
to_symbol_type(java_array_type(l).subtype());
775+
struct_tag_typet struct_tag_type =
776+
to_struct_tag_type(java_array_type(l).subtype());
777777

778-
const irep_idt &symbol_type_identifier=symbol_type.get_identifier();
779-
if(symbol_table.has_symbol(symbol_type_identifier))
778+
const irep_idt &struct_tag_type_identifier =
779+
struct_tag_type.get_identifier();
780+
if(symbol_table.has_symbol(struct_tag_type_identifier))
780781
return;
781782

782783
java_class_typet class_type;
783784
// we have the base class, java.lang.Object, length and data
784785
// of appropriate type
785-
class_type.set_tag(symbol_type_identifier);
786+
class_type.set_tag(struct_tag_type_identifier);
786787
// Note that non-array types don't have "java::" at the beginning of their
787788
// tag, and their name is "java::" + their tag. Since arrays do have
788789
// "java::" at the beginning of their tag we set the name to be the same as
789790
// the tag.
790-
class_type.set_name(symbol_type_identifier);
791+
class_type.set_name(struct_tag_type_identifier);
791792

792793
class_type.components().reserve(3);
793794
class_typet::componentt base_class_component(
794-
"@java.lang.Object", symbol_typet("java::java.lang.Object"));
795+
"@java.lang.Object", struct_tag_typet("java::java.lang.Object"));
795796
base_class_component.set_pretty_name("@java.lang.Object");
796797
base_class_component.set_base_name("@java.lang.Object");
797798
class_type.components().push_back(base_class_component);
@@ -807,16 +808,16 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
807808
data_component.set_base_name("data");
808809
class_type.components().push_back(data_component);
809810

810-
class_type.add_base(symbol_typet("java::java.lang.Object"));
811+
class_type.add_base(struct_tag_typet("java::java.lang.Object"));
811812

812813
INVARIANT(
813814
is_valid_java_array(class_type),
814815
"Constructed a new type representing a Java Array "
815816
"object that doesn't match expectations");
816817

817818
symbolt symbol;
818-
symbol.name=symbol_type_identifier;
819-
symbol.base_name=symbol_type.get(ID_C_base_name);
819+
symbol.name = struct_tag_type_identifier;
820+
symbol.base_name = struct_tag_type.get(ID_C_base_name);
820821
symbol.is_type=true;
821822
symbol.type = class_type;
822823
symbol.mode = ID_java;
@@ -825,13 +826,13 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
825826
// Also provide a clone method:
826827
// ----------------------------
827828

828-
const irep_idt clone_name=
829-
id2string(symbol_type_identifier)+".clone:()Ljava/lang/Object;";
829+
const irep_idt clone_name =
830+
id2string(struct_tag_type_identifier) + ".clone:()Ljava/lang/Object;";
830831
java_method_typet::parametert this_param;
831832
this_param.set_identifier(id2string(clone_name)+"::this");
832833
this_param.set_base_name("this");
833834
this_param.set_this();
834-
this_param.type()=java_reference_type(symbol_type);
835+
this_param.type() = java_reference_type(struct_tag_type);
835836
const java_method_typet clone_type({this_param}, java_lang_object_type());
836837

837838
parameter_symbolt this_symbol;
@@ -848,7 +849,7 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
848849
local_symbol.name=local_name;
849850
local_symbol.base_name="cloned_array";
850851
local_symbol.pretty_name=local_symbol.base_name;
851-
local_symbol.type=java_reference_type(symbol_type);
852+
local_symbol.type = java_reference_type(struct_tag_type);
852853
local_symbol.mode=ID_java;
853854
symbol_table.add(local_symbol);
854855
const auto &local_symexpr=local_symbol.symbol_expr();
@@ -858,9 +859,9 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
858859
source_locationt location;
859860
location.set_function(local_name);
860861
side_effect_exprt java_new_array(
861-
ID_java_new_array, java_reference_type(symbol_type), location);
862-
dereference_exprt old_array(this_symbol.symbol_expr(), symbol_type);
863-
dereference_exprt new_array(local_symexpr, symbol_type);
862+
ID_java_new_array, java_reference_type(struct_tag_type), location);
863+
dereference_exprt old_array(this_symbol.symbol_expr(), struct_tag_type);
864+
dereference_exprt new_array(local_symexpr, struct_tag_type);
864865
member_exprt old_length(
865866
old_array, length_component.get_name(), length_component.type());
866867
java_new_array.copy_to_operands(old_length);
@@ -925,8 +926,8 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
925926

926927
symbolt clone_symbol;
927928
clone_symbol.name=clone_name;
928-
clone_symbol.pretty_name=
929-
id2string(symbol_type_identifier)+".clone:()";
929+
clone_symbol.pretty_name =
930+
id2string(struct_tag_type_identifier) + ".clone:()";
930931
clone_symbol.base_name="clone";
931932
clone_symbol.type=clone_type;
932933
clone_symbol.value=clone_body;
@@ -1055,9 +1056,10 @@ static void find_and_replace_parameters(
10551056
find_and_replace_parameters(argument, replacement_parameters);
10561057
}
10571058
}
1058-
else if(is_java_generic_symbol_type(type))
1059+
else if(is_java_generic_struct_tag_type(type))
10591060
{
1060-
java_generic_symbol_typet &generic_base = to_java_generic_symbol_type(type);
1061+
java_generic_struct_tag_typet &generic_base =
1062+
to_java_generic_struct_tag_type(type);
10611063
std::vector<reference_typet> &gen_types = generic_base.generic_types();
10621064
for(auto &gen_type : gen_types)
10631065
{

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -383,8 +383,8 @@ void java_bytecode_convert_method_lazy(
383383
{
384384
java_method_typet::parameterst &parameters = member_type.parameters();
385385
java_method_typet::parametert this_p;
386-
const reference_typet object_ref_type=
387-
java_reference_type(symbol_typet(class_symbol.name));
386+
const reference_typet object_ref_type =
387+
java_reference_type(struct_tag_typet(class_symbol.name));
388388
this_p.type()=object_ref_type;
389389
this_p.set_this();
390390
parameters.insert(parameters.begin(), this_p);
@@ -658,7 +658,7 @@ static irep_idt get_if_cmp_operator(const irep_idt &stmt)
658658

659659
static member_exprt to_member(const exprt &pointer, const exprt &fieldref)
660660
{
661-
symbol_typet class_type(fieldref.get(ID_class));
661+
struct_tag_typet class_type(fieldref.get(ID_class));
662662

663663
const typecast_exprt pointer2(pointer, java_reference_type(class_type));
664664

@@ -1184,9 +1184,11 @@ codet java_bytecode_convert_methodt::convert_instructions(
11841184
{
11851185
if(cur_pc==it->handler_pc)
11861186
{
1187-
if(catch_type != typet() || it->catch_type == symbol_typet(irep_idt()))
1187+
if(
1188+
catch_type != typet() ||
1189+
it->catch_type == struct_tag_typet(irep_idt()))
11881190
{
1189-
catch_type=symbol_typet("java::java.lang.Throwable");
1191+
catch_type = struct_tag_typet("java::java.lang.Throwable");
11901192
break;
11911193
}
11921194
else
@@ -1636,7 +1638,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
16361638
const typecast_exprt pointer(op[0], java_array_type(statement[0]));
16371639

16381640
dereference_exprt array(pointer, pointer.type().subtype());
1639-
PRECONDITION(pointer.type().subtype().id() == ID_symbol_type);
1641+
PRECONDITION(pointer.type().subtype().id() == ID_struct_tag);
16401642
array.set(ID_java_member_access, true);
16411643

16421644
const member_exprt length(array, "length", java_int_type());
@@ -2115,7 +2117,7 @@ void java_bytecode_convert_methodt::convert_invoke(
21152117
if(parameters.empty() || !parameters[0].get_this())
21162118
{
21172119
irep_idt classname = arg0.get(ID_C_class);
2118-
typet thistype = symbol_typet(classname);
2120+
typet thistype = struct_tag_typet(classname);
21192121
// Note invokespecial is used for super-method calls as well as
21202122
// constructors.
21212123
if(statement == "invokespecial")
@@ -2530,7 +2532,7 @@ void java_bytecode_convert_methodt::convert_new(
25302532
c = code_assignt(tmp, java_new_expr);
25312533
c.add_source_location() = location;
25322534
codet clinit_call =
2533-
get_clinit_call(to_symbol_type(arg0.type()).get_identifier());
2535+
get_clinit_call(to_struct_tag_type(arg0.type()).get_identifier());
25342536
if(clinit_call.get_statement() != ID_skip)
25352537
{
25362538
c = code_blockt({clinit_call, c});
@@ -2544,10 +2546,10 @@ codet java_bytecode_convert_methodt::convert_putstatic(
25442546
const exprt::operandst &op,
25452547
const symbol_exprt &symbol_expr)
25462548
{
2547-
if(needed_lazy_methods && arg0.type().id() == ID_symbol_type)
2549+
if(needed_lazy_methods && arg0.type().id() == ID_struct_tag)
25482550
{
25492551
needed_lazy_methods->add_needed_class(
2550-
to_symbol_type(arg0.type()).get_identifier());
2552+
to_struct_tag_type(arg0.type()).get_identifier());
25512553
}
25522554

25532555
code_blockt block;
@@ -2594,18 +2596,18 @@ void java_bytecode_convert_methodt::convert_getstatic(
25942596
{
25952597
if(needed_lazy_methods)
25962598
{
2597-
if(arg0.type().id() == ID_symbol_type)
2599+
if(arg0.type().id() == ID_struct_tag)
25982600
{
25992601
needed_lazy_methods->add_needed_class(
2600-
to_symbol_type(arg0.type()).get_identifier());
2602+
to_struct_tag_type(arg0.type()).get_identifier());
26012603
}
26022604
else if(arg0.type().id() == ID_pointer)
26032605
{
26042606
const auto &pointer_type = to_pointer_type(arg0.type());
2605-
if(pointer_type.subtype().id() == ID_symbol_type)
2607+
if(pointer_type.subtype().id() == ID_struct_tag)
26062608
{
26072609
needed_lazy_methods->add_needed_class(
2608-
to_symbol_type(pointer_type.subtype()).get_identifier());
2610+
to_struct_tag_type(pointer_type.subtype()).get_identifier());
26092611
}
26102612
}
26112613
else if(is_assertions_disabled_field)

jbmc/src/java_bytecode/java_bytecode_instrument.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ codet java_bytecode_instrumentt::throw_exception(
108108
struct_union_typet::componentst{});
109109
}
110110

111-
pointer_typet exc_ptr_type=
112-
pointer_type(symbol_typet(exc_class_name));
111+
pointer_typet exc_ptr_type = pointer_type(struct_tag_typet(exc_class_name));
113112

114113
// Allocate and throw an instance of the exception class:
115114

jbmc/src/java_bytecode/java_bytecode_language.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ static void infer_opaque_type_fields(
360360
static symbol_exprt get_or_create_class_literal_symbol(
361361
const irep_idt &class_id, symbol_tablet &symbol_table)
362362
{
363-
symbol_typet java_lang_Class("java::java.lang.Class");
363+
struct_tag_typet java_lang_Class("java::java.lang.Class");
364364
symbol_exprt symbol_expr(
365365
id2string(class_id) + JAVA_CLASS_MODEL_SUFFIX,
366366
java_lang_Class);

jbmc/src/java_bytecode/java_bytecode_parse_tree.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,8 @@ java_bytecode_parse_treet::find_annotation(
117117
if(annotation.type.id() != ID_pointer)
118118
return false;
119119
const typet &type = annotation.type.subtype();
120-
return type.id() == ID_symbol_type &&
121-
to_symbol_type(type).get_identifier() == annotation_type_name;
120+
return type.id() == ID_struct_tag &&
121+
to_struct_tag_type(type).get_identifier() == annotation_type_name;
122122
});
123123
if(annotation_it == annotations.end())
124124
return {};

jbmc/src/java_bytecode/java_bytecode_parse_tree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ struct java_bytecode_parse_treet
116116
std::size_t start_pc;
117117
std::size_t end_pc;
118118
std::size_t handler_pc;
119-
symbol_typet catch_type;
119+
struct_tag_typet catch_type;
120120
};
121121

122122
typedef std::vector<exceptiont> exception_tablet;

0 commit comments

Comments
 (0)