Skip to content

Commit 72e99a0

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#2201 from diffblue/remove-incomplete-type-constructors
Remove incomplete type constructors
2 parents a6652d2 + 1fe7cd7 commit 72e99a0

11 files changed

+55
-61
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

+1-1
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

+5
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

+8-3
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

+12-6
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/ansi_c_convert_type.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,8 @@ void ansi_c_convert_typet::write(typet &type)
601601

602602
if(vector_size.is_not_nil())
603603
{
604-
vector_typet new_type;
605-
new_type.size()=vector_size;
604+
vector_typet new_type(type, vector_size);
606605
new_type.add_source_location()=vector_size.source_location();
607-
new_type.subtype().swap(type);
608606
type=new_type;
609607
}
610608

src/ansi-c/c_typecheck_type.cpp

+1-2
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/cpp/parse.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -5987,9 +5987,7 @@ bool Parser::rNewDeclarator(typet &decl)
59875987
if(lex.get_token(cb)!=']')
59885988
return false;
59895989

5990-
array_typet array_type;
5991-
array_type.size().swap(expr);
5992-
array_type.subtype().swap(decl);
5990+
array_typet array_type(decl, expr);
59935991
set_location(array_type, ob);
59945992

59955993
decl.swap(array_type);

src/goto-programs/remove_virtual_functions.cpp

+1-1
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/goto-programs/string_instrumentation.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -791,9 +791,7 @@ void string_instrumentationt::do_strerror(
791791
new_symbol_size.is_lvalue=true;
792792
new_symbol_size.is_static_lifetime=true;
793793

794-
array_typet type;
795-
type.subtype()=char_type();
796-
type.size()=new_symbol_size.symbol_expr();
794+
array_typet type(char_type(), new_symbol_size.symbol_expr());
797795
symbolt new_symbol_buf;
798796
new_symbol_buf.mode=ID_C;
799797
new_symbol_buf.type=type;

src/solvers/smt2/smt2_parser.cpp

+16-14
Original file line numberDiff line numberDiff line change
@@ -1028,26 +1028,27 @@ typet smt2_parsert::function_signature_definition()
10281028
return sort();
10291029
}
10301030

1031-
mathematical_function_typet result;
1031+
mathematical_function_typet::domaint domain;
10321032

10331033
while(peek()!=CLOSE)
10341034
{
10351035
if(next_token()!=OPEN)
10361036
{
10371037
error() << "expected '(' at beginning of parameter" << eom;
1038-
return result;
1038+
return nil_typet();
10391039
}
10401040

10411041
if(next_token()!=SYMBOL)
10421042
{
10431043
error() << "expected symbol in parameter" << eom;
1044-
return result;
1044+
return nil_typet();
10451045
}
10461046

1047-
auto &var=result.add_variable();
1047+
mathematical_function_typet::variablet var;
10481048
std::string id=buffer;
10491049
var.set_identifier(id);
10501050
var.type()=sort();
1051+
domain.push_back(var);
10511052

10521053
auto &entry=id_map[id];
10531054
entry.type=var.type();
@@ -1056,15 +1057,15 @@ typet smt2_parsert::function_signature_definition()
10561057
if(next_token()!=CLOSE)
10571058
{
10581059
error() << "expected ')' at end of parameter" << eom;
1059-
return result;
1060+
return nil_typet();
10601061
}
10611062
}
10621063

10631064
next_token(); // eat the ')'
10641065

1065-
result.codomain()=sort();
1066+
typet codomain = sort();
10661067

1067-
return result;
1068+
return mathematical_function_typet(domain, codomain);
10681069
}
10691070

10701071
typet smt2_parsert::function_signature_declaration()
@@ -1081,37 +1082,38 @@ typet smt2_parsert::function_signature_declaration()
10811082
return sort();
10821083
}
10831084

1084-
mathematical_function_typet result;
1085+
mathematical_function_typet::domaint domain;
10851086

10861087
while(peek()!=CLOSE)
10871088
{
10881089
if(next_token()!=OPEN)
10891090
{
10901091
error() << "expected '(' at beginning of parameter" << eom;
1091-
return result;
1092+
return nil_typet();
10921093
}
10931094

10941095
if(next_token()!=SYMBOL)
10951096
{
10961097
error() << "expected symbol in parameter" << eom;
1097-
return result;
1098+
return nil_typet();
10981099
}
10991100

1100-
auto &var=result.add_variable();
1101+
mathematical_function_typet::variablet var;
11011102
var.type()=sort();
1103+
domain.push_back(var);
11021104

11031105
if(next_token()!=CLOSE)
11041106
{
11051107
error() << "expected ')' at end of parameter" << eom;
1106-
return result;
1108+
return nil_typet();
11071109
}
11081110
}
11091111

11101112
next_token(); // eat the ')'
11111113

1112-
result.codomain()=sort();
1114+
typet codomain = sort();
11131115

1114-
return result;
1116+
return mathematical_function_typet(domain, codomain);
11151117
}
11161118

11171119
void smt2_parsert::command(const std::string &c)

src/util/std_types.h

+8-25
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);
@@ -492,10 +488,6 @@ inline union_typet &to_union_type(typet &type)
492488
class tag_typet:public typet
493489
{
494490
public:
495-
explicit tag_typet(const irep_idt &_id):typet(_id)
496-
{
497-
}
498-
499491
explicit tag_typet(
500492
const irep_idt &_id,
501493
const irep_idt &identifier):typet(_id)
@@ -980,10 +972,6 @@ inline code_typet &to_code_type(typet &type)
980972
class array_typet:public type_with_subtypet
981973
{
982974
public:
983-
array_typet():type_with_subtypet(ID_array)
984-
{
985-
}
986-
987975
array_typet(
988976
const typet &_subtype,
989977
const exprt &_size):type_with_subtypet(ID_array, _subtype)
@@ -1575,10 +1563,6 @@ inline const string_typet &to_string_type(const typet &type)
15751563
class range_typet:public typet
15761564
{
15771565
public:
1578-
range_typet():typet(ID_range)
1579-
{
1580-
}
1581-
15821566
range_typet(const mp_integer &_from, const mp_integer &_to)
15831567
{
15841568
set_from(_from);
@@ -1613,10 +1597,6 @@ inline const range_typet &to_range_type(const typet &type)
16131597
class vector_typet:public type_with_subtypet
16141598
{
16151599
public:
1616-
vector_typet():type_with_subtypet(ID_vector)
1617-
{
1618-
}
1619-
16201600
vector_typet(
16211601
const typet &_subtype,
16221602
const exprt &_size):type_with_subtypet(ID_vector, _subtype)
@@ -1706,11 +1686,6 @@ inline complex_typet &to_complex_type(typet &type)
17061686
class mathematical_function_typet:public typet
17071687
{
17081688
public:
1709-
mathematical_function_typet():typet(ID_mathematical_function)
1710-
{
1711-
subtypes().resize(2);
1712-
}
1713-
17141689
// the domain of the function is composed of zero, one, or
17151690
// many variables
17161691
class variablet:public irept
@@ -1740,6 +1715,14 @@ class mathematical_function_typet:public typet
17401715

17411716
using domaint=std::vector<variablet>;
17421717

1718+
mathematical_function_typet(const domaint &_domain, const typet &_codomain)
1719+
: typet(ID_mathematical_function)
1720+
{
1721+
subtypes().resize(2);
1722+
domain() = _domain;
1723+
codomain() = _codomain;
1724+
}
1725+
17431726
domaint &domain()
17441727
{
17451728
return (domaint &)subtypes()[0].subtypes();

0 commit comments

Comments
 (0)