Skip to content

Commit 64cd733

Browse files
Make code_typet declarations const
Fixes: diffblue#2287
1 parent b618d94 commit 64cd733

14 files changed

+26
-36
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_class.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ void java_bytecode_convert_classt::add_array_types(symbol_tablet &symbol_table)
765765
this_param.set_base_name("this");
766766
this_param.set_this();
767767
this_param.type()=java_reference_type(symbol_type);
768-
code_typet clone_type({this_param}, java_lang_object_type());
768+
const code_typet clone_type({this_param}, java_lang_object_type());
769769

770770
parameter_symbolt this_symbol;
771771
this_symbol.name=this_param.get_identifier();

jbmc/src/java_bytecode/java_entry_point.cpp

+2-5
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({}, empty_typet());
35-
initialize.type=type;
34+
initialize.type = code_typet({}, empty_typet());
3635

3736
code_blockt init_code;
3837

@@ -687,10 +686,8 @@ bool generate_java_start_function(
687686
// we just built and register it in the symbol table
688687
symbolt new_symbol;
689688

690-
code_typet main_type({}, empty_typet());
691-
692689
new_symbol.name=goto_functionst::entry_point();
693-
new_symbol.type.swap(main_type);
690+
new_symbol.type = code_typet({}, empty_typet());
694691
new_symbol.value.swap(init_code);
695692
new_symbol.mode=ID_java;
696693

jbmc/src/java_bytecode/java_static_initializers.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -293,7 +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({}, void_typet());
296+
const code_typet wrapper_method_type({}, void_typet());
297297
wrapper_method_symbol.name = clinit_wrapper_name(class_name);
298298
wrapper_method_symbol.pretty_name = wrapper_method_symbol.name;
299299
wrapper_method_symbol.base_name = "clinit_wrapper";
@@ -713,7 +713,7 @@ void stub_global_initializer_factoryt::create_stub_global_initializer_symbols(
713713
"a class cannot be both incomplete, and so have stub static fields, and "
714714
"also define a static initializer");
715715

716-
code_typet thunk_type({}, void_typet());
716+
const code_typet thunk_type({}, void_typet());
717717

718718
symbolt static_init_symbol;
719719
static_init_symbol.name = static_init_name;

jbmc/src/java_bytecode/java_string_library_preprocess.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1611,7 +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({code_typet::parametert(string_ptr_type)}, class_type);
1614+
const code_typet fun_type({code_typet::parametert(string_ptr_type)}, class_type);
16151615
fun_call.function().type()=fun_type;
16161616
code.add(fun_call, loc);
16171617

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ 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+
const code_typet fun_type(
6262
{code_typet::parametert(length_type()),
6363
code_typet::parametert(pointer_type(java_char_type())),
6464
code_typet::parametert(string_type),

src/ansi-c/ansi_c_entry_point.cpp

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

448-
code_typet main_type({}, empty_typet());
449-
450448
new_symbol.name=goto_functionst::entry_point();
451-
new_symbol.type.swap(main_type);
449+
new_symbol.type = code_typet({}, empty_typet());
452450
new_symbol.value.swap(init_code);
453451
new_symbol.mode=symbol.mode;
454452

src/ansi-c/c_typecheck_expr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,7 @@ 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(
453+
const code_typet new_type(
454454
{code_typet::parametert(pointer_type(void_type()))}, std::move(arg_type));
455455

456456
assert(expr.operands().size()==1);

src/cpp/cpp_typecheck_expr.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1479,7 +1479,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name(
14791479
symbol_exprt result;
14801480
result.add_source_location()=source_location;
14811481
result.set_identifier(identifier);
1482-
code_typet t(
1482+
const code_typet t(
14831483
{code_typet::parametert(ptr_arg.type()),
14841484
code_typet::parametert(signed_int_type())},
14851485
ptr_arg.type().subtype());
@@ -1513,7 +1513,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name(
15131513
symbol_exprt result;
15141514
result.add_source_location()=source_location;
15151515
result.set_identifier(identifier);
1516-
code_typet t(
1516+
const code_typet t(
15171517
{code_typet::parametert(ptr_arg.type()),
15181518
code_typet::parametert(ptr_arg.type().subtype()),
15191519
code_typet::parametert(signed_int_type())},
@@ -1548,7 +1548,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name(
15481548
symbol_exprt result;
15491549
result.add_source_location()=source_location;
15501550
result.set_identifier(identifier);
1551-
code_typet t(
1551+
const code_typet t(
15521552
{code_typet::parametert(ptr_arg.type()),
15531553
code_typet::parametert(ptr_arg.type().subtype()),
15541554
code_typet::parametert(signed_int_type())},
@@ -1591,7 +1591,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name(
15911591
symbol_exprt result;
15921592
result.add_source_location()=source_location;
15931593
result.set_identifier(identifier);
1594-
code_typet t(
1594+
const code_typet t(
15951595
{code_typet::parametert(ptr_arg.type()),
15961596
code_typet::parametert(ptr_arg.type()),
15971597
code_typet::parametert(signed_int_type())},
@@ -1640,7 +1640,7 @@ void cpp_typecheckt::typecheck_expr_cpp_name(
16401640
symbol_exprt result;
16411641
result.add_source_location()=source_location;
16421642
result.set_identifier(identifier);
1643-
code_typet t(
1643+
const code_typet t(
16441644
{code_typet::parametert(ptr_arg.type()),
16451645
code_typet::parametert(ptr_arg.type()),
16461646
code_typet::parametert(ptr_arg.type()),

src/cpp/cpp_typecheck_resolve.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -611,22 +611,22 @@ void cpp_typecheck_resolvet::make_constructors(
611611

612612
// 1. no arguments, default initialization
613613
{
614-
code_typet t1({}, it->type());
614+
const code_typet t1({}, it->type());
615615
exprt pod_constructor1("pod_constructor", t1);
616616
new_identifiers.push_back(pod_constructor1);
617617
}
618618

619619
// 2. one argument, copy/conversion
620620
{
621-
code_typet t2({code_typet::parametert(it->type())}, it->type());
621+
const code_typet t2({code_typet::parametert(it->type())}, it->type());
622622
exprt pod_constructor2("pod_constructor", t2);
623623
new_identifiers.push_back(pod_constructor2);
624624
}
625625

626626
// enums, in addition, can also be constructed from int
627627
if(symbol_type.id()==ID_c_enum_tag)
628628
{
629-
code_typet t3({code_typet::parametert(signed_int_type())}, it->type());
629+
const code_typet t3({code_typet::parametert(signed_int_type())}, it->type());
630630
exprt pod_constructor3("pod_constructor", t3);
631631
new_identifiers.push_back(pod_constructor3);
632632
}

src/goto-cc/linker_script_merge.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ int linker_script_merget::ls_data2instructions(
593593
for(const auto &d : data["regions"].array)
594594
{
595595
code_function_callt f;
596-
code_typet void_t({}, empty_typet());
596+
const code_typet void_t({}, empty_typet());
597597
f.function()=symbol_exprt(CPROVER_PREFIX "allocated_memory", void_t);
598598
unsigned start=safe_string2unsigned(d["start"].value);
599599
unsigned size=safe_string2unsigned(d["size"].value);
@@ -619,7 +619,7 @@ int linker_script_merget::ls_data2instructions(
619619
sym.name=CPROVER_PREFIX "allocated_memory";
620620
sym.pretty_name=CPROVER_PREFIX "allocated_memory";
621621
sym.is_lvalue=sym.is_static_lifetime=true;
622-
code_typet void_t({}, empty_typet());
622+
const code_typet void_t({}, empty_typet());
623623
sym.type=void_t;
624624
symbol_table.add(sym);
625625
}

src/goto-instrument/goto_program2code.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ goto_programt::const_targett goto_program2codet::convert_instruction(
228228
case ATOMIC_END:
229229
{
230230
code_function_callt f;
231-
code_typet void_t({}, empty_typet());
231+
const code_typet void_t({}, empty_typet());
232232
f.function()=symbol_exprt(
233233
target->is_atomic_begin() ?
234234
"__CPROVER_atomic_begin" :
@@ -1948,12 +1948,10 @@ void goto_program2codet::cleanup_expr(exprt &expr, bool no_typecast)
19481948
base_name="nondet_"+std::to_string(count);
19491949
}
19501950

1951-
code_typet code_type({}, expr.type());
1952-
19531951
symbolt symbol;
19541952
symbol.base_name=base_name;
19551953
symbol.name=base_name;
1956-
symbol.type=code_type;
1954+
symbol.type = code_typet({}, expr.type());
19571955
id=symbol.name;
19581956

19591957
symbol_table.insert(std::move(symbol));

src/jsil/jsil_entry_point.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ static void create_initialize(symbol_tablet &symbol_table)
2626
initialize.base_name = INITIALIZE_FUNCTION;
2727
initialize.mode="jsil";
2828

29-
code_typet type({}, empty_typet());
30-
initialize.type=type;
29+
initialize.type = code_typet({}, empty_typet());
3130

3231
code_blockt init_code;
3332

@@ -151,10 +150,8 @@ bool jsil_entry_point(
151150
// add "main"
152151
symbolt new_symbol;
153152

154-
code_typet main_type({}, empty_typet());
155-
156153
new_symbol.name=goto_functionst::entry_point();
157-
new_symbol.type.swap(main_type);
154+
new_symbol.type = code_typet({}, empty_typet());
158155
new_symbol.value.swap(init_code);
159156

160157
if(!symbol_table.insert(std::move(new_symbol)).second)

unit/analyses/call_graph.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static symbolt create_void_function_symbol(
2222
const irep_idt &name,
2323
const codet &code)
2424
{
25-
code_typet void_function_type({}, empty_typet());
25+
const code_typet void_function_type({}, empty_typet());
2626
symbolt function;
2727
function.name=name;
2828
function.type=void_function_type;

unit/analyses/dependence_graph.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ static symbolt create_void_function_symbol(
2222
const irep_idt &name,
2323
const codet &code)
2424
{
25-
code_typet void_function_type({}, empty_typet());
25+
const code_typet void_function_type({}, empty_typet());
2626
symbolt function;
2727
function.name = name;
2828
function.type = void_function_type;
@@ -74,7 +74,7 @@ SCENARIO("dependence_graph", "[core][analyses][dependence_graph]")
7474
x_symbol.is_file_local = true;
7575
goto_model.symbol_table.add(x_symbol);
7676

77-
code_typet void_function_type({}, empty_typet());
77+
const code_typet void_function_type({}, empty_typet());
7878

7979
code_blockt a_body;
8080
code_declt declare_x(x_symbol.symbol_expr());

0 commit comments

Comments
 (0)