Skip to content

Commit 516ed14

Browse files
author
Daniel Kroening
committed
remove symbol_typet() constructor, which produces an incomplete object
1 parent 9a0aa9c commit 516ed14

File tree

7 files changed

+28
-17
lines changed

7 files changed

+28
-17
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ codet java_bytecode_convert_methodt::convert_instructions(
11851185
{
11861186
if(cur_pc==it->handler_pc)
11871187
{
1188-
if(catch_type!=typet() || it->catch_type==symbol_typet())
1188+
if(catch_type != typet() || it->catch_type == symbol_typet(irep_idt()))
11891189
{
11901190
catch_type=symbol_typet("java::java.lang.Throwable");
11911191
break;

jbmc/src/java_bytecode/java_bytecode_parse_tree.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ class java_bytecode_parse_treet
105105
struct exceptiont
106106
{
107107
public:
108+
exceptiont()
109+
: start_pc(0), end_pc(0), handler_pc(0), catch_type(irep_idt())
110+
{
111+
}
112+
108113
std::size_t start_pc;
109114
std::size_t end_pc;
110115
std::size_t handler_pc;

jbmc/src/java_bytecode/java_string_library_preprocess.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,8 @@ exprt java_string_library_preprocesst::get_primitive_value_of_object(
12491249
symbol_table_baset &symbol_table,
12501250
code_blockt &code)
12511251
{
1252-
symbol_typet object_type;
1252+
optionalt<symbol_typet> object_type;
1253+
12531254
typet value_type;
12541255
if(type_name==ID_boolean)
12551256
{
@@ -1296,6 +1297,8 @@ exprt java_string_library_preprocesst::get_primitive_value_of_object(
12961297
else
12971298
UNREACHABLE;
12981299

1300+
DATA_INVARIANT(object_type.has_value(), "must have symbol for primitive");
1301+
12991302
// declare tmp_type_name to hold the value
13001303
std::string aux_name="tmp_"+id2string(type_name);
13011304
symbolt symbol=get_fresh_aux_symbol(
@@ -1304,7 +1307,9 @@ exprt java_string_library_preprocesst::get_primitive_value_of_object(
13041307

13051308
// Check that the type of the object is in the symbol table,
13061309
// otherwise there is no safe way of finding its value.
1307-
if(const auto maybe_symbol=symbol_table.lookup(object_type.get_identifier()))
1310+
if(
1311+
const auto maybe_symbol =
1312+
symbol_table.lookup(object_type->get_identifier()))
13081313
{
13091314
struct_typet struct_type=to_struct_type(maybe_symbol->type);
13101315
// Check that the type has a value field
@@ -1321,7 +1326,7 @@ exprt java_string_library_preprocesst::get_primitive_value_of_object(
13211326
}
13221327
}
13231328

1324-
warning() << object_type.get_identifier()
1329+
warning() << object_type->get_identifier()
13251330
<< " not available to format function" << eom;
13261331
code.add(code_declt(value), loc);
13271332
return value;

jbmc/unit/java_bytecode/java_types/generic_type_index.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ SCENARIO("generic_type_index", "[core][java_types]")
1717
const auto symbol_type = symbol_typet("java::GenericClass");
1818
const auto generic_symbol_type = java_generic_symbol_typet(
1919
symbol_type, "LGenericClass<TX;Tvalue;>;", "PrefixClassName");
20-
java_generic_parametert paramX("PrefixClassName::X", symbol_typet());
21-
java_generic_parametert value("PrefixClassName::value", symbol_typet());
22-
java_generic_parametert paramZ("PrefixClassName::Z", symbol_typet());
20+
java_generic_parametert paramX(
21+
"PrefixClassName::X", symbol_typet(irep_idt()));
22+
java_generic_parametert value(
23+
"PrefixClassName::value", symbol_typet(irep_idt()));
24+
java_generic_parametert paramZ(
25+
"PrefixClassName::Z", symbol_typet(irep_idt()));
2326

2427
WHEN("Looking for parameter indexes")
2528
{
@@ -43,9 +46,12 @@ SCENARIO("generic_type_index", "[core][java_types]")
4346
const auto symbol_type = symbol_typet("java::java.util.Map");
4447
const auto generic_symbol_type = java_generic_symbol_typet(
4548
symbol_type, "Ljava/util/Map<TK;TV;>;", "java.util.HashMap");
46-
java_generic_parametert param0("java.util.HashMap::K", symbol_typet());
47-
java_generic_parametert param1("java.util.HashMap::V", symbol_typet());
48-
java_generic_parametert param2("java.util.HashMap::T", symbol_typet());
49+
java_generic_parametert param0(
50+
"java.util.HashMap::K", symbol_typet(irep_idt()));
51+
java_generic_parametert param1(
52+
"java.util.HashMap::V", symbol_typet(irep_idt()));
53+
java_generic_parametert param2(
54+
"java.util.HashMap::T", symbol_typet(irep_idt()));
4955

5056
WHEN("Looking for parameter indexes")
5157
{

src/ansi-c/c_typecheck_type.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,9 +792,8 @@ void c_typecheck_baset::typecheck_compound_type(struct_union_typet &type)
792792
}
793793
}
794794

795-
symbol_typet symbol_type;
795+
symbol_typet symbol_type(identifier);
796796
symbol_type.add_source_location()=type.source_location();
797-
symbol_type.set_identifier(identifier);
798797

799798
c_qualifierst original_qualifiers(type);
800799
type.swap(symbol_type);

src/goto-programs/remove_virtual_functions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ void remove_virtual_functionst::remove_virtual_function(
177177
// So long as `this` is already not `void*` typed, the second parameter
178178
// is ignored:
179179
exprt this_class_identifier =
180-
get_class_identifier_field(this_expr, symbol_typet(), ns);
180+
get_class_identifier_field(this_expr, symbol_typet(irep_idt()), ns);
181181

182182
// If instructed, add an ASSUME(FALSE) to handle the case where we don't
183183
// match any expected type:

src/util/std_types.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,6 @@ class real_typet:public typet
110110
class symbol_typet:public typet
111111
{
112112
public:
113-
symbol_typet():typet(ID_symbol)
114-
{
115-
}
116-
117113
explicit symbol_typet(const irep_idt &identifier):typet(ID_symbol)
118114
{
119115
set_identifier(identifier);

0 commit comments

Comments
 (0)