Skip to content

Commit b618d94

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#2269 from peterschrammel/parameters-code-type
Make sure code_typet always has parameters property
2 parents 2a72bf2 + 32fd0c2 commit b618d94

File tree

52 files changed

+264
-129
lines changed

Some content is hidden

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

52 files changed

+264
-129
lines changed
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CORE
2+
new.jar
3+
old.jar
4+
EXIT=0
5+
SIGNAL=0
6+
--
7+
java::java\.nio\.charset\.StandardCharsets::clinit_wrapper$
8+
java::org\.apache\.tika\.mime\.MediaType::clinit_wrapper$

jbmc/src/java_bytecode/java_bytecode_convert_class.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -760,15 +760,12 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
760760

761761
const irep_idt clone_name=
762762
id2string(symbol_type_identifier)+".clone:()Ljava/lang/Object;";
763-
code_typet clone_type;
764-
clone_type.return_type()=
765-
java_reference_type(symbol_typet("java::java.lang.Object"));
766763
code_typet::parametert this_param;
767764
this_param.set_identifier(id2string(clone_name)+"::this");
768765
this_param.set_base_name("this");
769766
this_param.set_this();
770767
this_param.type()=java_reference_type(symbol_type);
771-
clone_type.parameters().push_back(this_param);
768+
code_typet clone_type({this_param}, java_lang_object_type());
772769

773770
parameter_symbolt this_symbol;
774771
this_symbol.name=this_param.get_identifier();

jbmc/src/java_bytecode/java_entry_point.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ static void create_initialize(symbol_table_baset &symbol_table)
3131
initialize.base_name=INITIALIZE_FUNCTION;
3232
initialize.mode=ID_java;
3333

34-
code_typet type;
35-
type.return_type()=empty_typet();
34+
code_typet type({}, empty_typet());
3635
initialize.type=type;
3736

3837
code_blockt init_code;
@@ -688,8 +687,7 @@ bool generate_java_start_function(
688687
// we just built and register it in the symbol table
689688
symbolt new_symbol;
690689

691-
code_typet main_type;
692-
main_type.return_type()=empty_typet();
690+
code_typet main_type({}, empty_typet());
693691

694692
new_symbol.name=goto_functionst::entry_point();
695693
new_symbol.type.swap(main_type);

jbmc/src/java_bytecode/java_static_initializers.cpp

+2-7
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,7 @@ static void create_clinit_wrapper_symbols(
293293

294294
// Create symbol for the "clinit_wrapper"
295295
symbolt wrapper_method_symbol;
296-
code_typet wrapper_method_type;
297-
wrapper_method_type.return_type() = void_typet();
298-
// Ensure the parameters property is there
299-
// to avoid trouble in irept comparisons
300-
wrapper_method_type.parameters();
296+
code_typet wrapper_method_type({}, void_typet());
301297
wrapper_method_symbol.name = clinit_wrapper_name(class_name);
302298
wrapper_method_symbol.pretty_name = wrapper_method_symbol.name;
303299
wrapper_method_symbol.base_name = "clinit_wrapper";
@@ -717,8 +713,7 @@ void stub_global_initializer_factoryt::create_stub_global_initializer_symbols(
717713
"a class cannot be both incomplete, and so have stub static fields, and "
718714
"also define a static initializer");
719715

720-
code_typet thunk_type;
721-
thunk_type.return_type() = void_typet();
716+
code_typet thunk_type({}, void_typet());
722717

723718
symbolt static_init_symbol;
724719
static_init_symbol.name = static_init_name;

jbmc/src/java_bytecode/java_string_library_preprocess.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -1611,9 +1611,7 @@ codet java_string_library_preprocesst::make_object_get_class_code(
16111611
"java::java.lang.Class.forName:(Ljava/lang/String;)Ljava/lang/Class;");
16121612
fun_call.lhs()=class1;
16131613
fun_call.arguments().push_back(string1);
1614-
code_typet fun_type;
1615-
fun_type.parameters().push_back(code_typet::parametert(string_ptr_type));
1616-
fun_type.return_type()=class_type;
1614+
code_typet fun_type({code_typet::parametert(string_ptr_type)}, class_type);
16171615
fun_call.function().type()=fun_type;
16181616
code.add(fun_call, loc);
16191617

jbmc/src/java_bytecode/java_types.cpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -493,24 +493,21 @@ typet java_type_from_string(
493493
if(e_pos==std::string::npos)
494494
return nil_typet();
495495

496-
code_typet result;
497-
498-
result.return_type()=
499-
java_type_from_string(
500-
std::string(src, e_pos+1, std::string::npos),
501-
class_name_prefix);
496+
typet return_type = java_type_from_string(
497+
std::string(src, e_pos + 1, std::string::npos), class_name_prefix);
502498

503499
std::vector<typet> param_types =
504500
parse_list_types(src.substr(0, e_pos + 1), class_name_prefix, '(', ')');
505501

506502
// create parameters for each type
503+
code_typet::parameterst parameters;
507504
std::transform(
508505
param_types.begin(),
509506
param_types.end(),
510-
std::back_inserter(result.parameters()),
507+
std::back_inserter(parameters),
511508
[](const typet &type) { return code_typet::parametert(type); });
512509

513-
return result;
510+
return code_typet(std::move(parameters), std::move(return_type));
514511
}
515512

516513
case '[': // array type
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
goto-programs
2+
java_bytecode
3+
java-testing-utils
4+
langapi # should go away
5+
testing-utils
6+
util
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ci_lazy_methods
2+
java-testing-utils
3+
testing-utils
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
goto-programs
2+
java-testing-utils
3+
testing-utils
4+
util
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
goto_program_generics
2+
java-testing-utils
3+
testing-utils
4+
util
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
inherited_static_fields
2+
java-testing-utils
3+
testing-utils
4+
util
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
java-testing-utils
22
testing-utils
33
java_bytecode
4+
util
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
goto-programs
2+
java_bytecode
3+
java_bytecode_convert_method
4+
java-testing-utils
5+
testing-utils
6+
util
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
java_bytecode_parse_generics
2+
java-testing-utils
3+
testing-utils
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
java_bytecode
2+
java_bytecode_parse_lambdas
3+
java-testing-utils
4+
langapi # should go away
5+
testing-utils
6+
util
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
java_bytecode
2+
java_object_factory
3+
langapi # should go away
4+
testing-utils
5+
util
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
goto-instrument
2+
goto-programs
3+
java_bytecode
4+
java_replace_nondet
5+
java-testing-utils
6+
testing-utils
7+
util
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
java_bytecode
2+
java_string_library_preprocess
3+
langapi # should go away
4+
testing-utils
5+
util
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
java_bytecode
2+
java_types
3+
testing-utils
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
goto-instrument
2+
goto-programs
3+
java_bytecode
4+
java_virtual_functions
5+
java-testing-utils
6+
testing-utils
7+
util
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
java_bytecode
2+
testing-utils
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
goto-programs
2+
java_bytecode
3+
langapi # should go away
4+
pointer-analysis
5+
testing-utils
6+
util
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
java_bytecode
2+
langapi # should go away
3+
solvers/refinement
4+
solvers/sat
5+
string_constraint_instantiation
6+
testing-utils
7+
util

jbmc/unit/solvers/refinement/string_refinement/dependency_graph.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,12 @@ SCENARIO("dependency_graph", "[core][solvers][refinement][string_refinement]")
5858
const symbol_exprt lhs("lhs", unsignedbv_typet(32));
5959
const symbol_exprt lhs2("lhs2", unsignedbv_typet(32));
6060
const symbol_exprt lhs3("lhs3", unsignedbv_typet(32));
61-
code_typet fun_type;
61+
code_typet fun_type(
62+
{code_typet::parametert(length_type()),
63+
code_typet::parametert(pointer_type(java_char_type())),
64+
code_typet::parametert(string_type),
65+
code_typet::parametert(string_type)},
66+
unsignedbv_typet(32));
6267

6368
// fun1 is s3 = s1.concat(s2)
6469
function_application_exprt fun1(fun_type);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
java_bytecode
2+
langapi # should go away
3+
string_refinement
4+
solvers/refinement
5+
testing-utils
6+
util
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
java_bytecode
2+
java-testing-utils
3+
testing-utils
4+
util

src/ansi-c/ansi_c_entry_point.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -445,8 +445,7 @@ bool generate_ansi_c_start_function(
445445
// add the entry point symbol
446446
symbolt new_symbol;
447447

448-
code_typet main_type;
449-
main_type.return_type()=empty_typet();
448+
code_typet main_type({}, empty_typet());
450449

451450
new_symbol.name=goto_functionst::entry_point();
452451
new_symbol.type.swap(main_type);

src/ansi-c/c_typecheck_expr.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,8 @@ void c_typecheck_baset::typecheck_expr_builtin_va_arg(exprt &expr)
450450
typet arg_type=expr.type();
451451
typecheck_type(arg_type);
452452

453-
code_typet new_type;
454-
new_type.return_type().swap(arg_type);
455-
new_type.parameters().resize(1);
456-
new_type.parameters()[0].type()=pointer_type(void_type());
453+
code_typet new_type(
454+
{code_typet::parametert(pointer_type(void_type()))}, std::move(arg_type));
457455

458456
assert(expr.operands().size()==1);
459457
exprt arg=expr.op0();

src/cbmc/symex_coverage.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,6 @@ goto_program_coverage_recordt::goto_program_coverage_recordt(
173173

174174
code_typet sig_type=
175175
original_return_type(ns.get_symbol_table(), gf_it->first);
176-
if(sig_type.is_nil())
177-
sig_type=gf_it->second.type;
178176
xml.set_attribute("signature",
179177
from_type(ns, gf_it->first, sig_type));
180178

0 commit comments

Comments
 (0)