Skip to content

Commit 61c6489

Browse files
author
thk123
committed
Verify that language options have been initialized
We already had assertions before some of the languaget interface but not for all of them. This can cause errors for regenerating entry points so added assertions. This revealed the problem which is for entry function recreation there is a new languaget that hasn't parsed the cmdline.
1 parent e54c0e9 commit 61c6489

File tree

5 files changed

+19
-6
lines changed

5 files changed

+19
-6
lines changed

src/cbmc/cbmc_parse_options.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -633,9 +633,10 @@ int cbmc_parse_optionst::get_goto_program(
633633
{
634634
const std::string &function_id=cmdline.get_value("function");
635635
rebuild_goto_start_functiont start_function_rebuilder(
636-
get_message_handler(),
637-
goto_model.symbol_table,
638-
goto_model.goto_functions);
636+
get_message_handler(),
637+
cmdline,
638+
goto_model.symbol_table,
639+
goto_model.goto_functions);
639640

640641
if(start_function_rebuilder(function_id))
641642
{

src/goto-programs/initialize_goto_model.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ bool initialize_goto_model(
138138
const std::string &function_id=cmdline.get_value("function");
139139
rebuild_goto_start_functiont start_function_rebuilder(
140140
msg.get_message_handler(),
141+
cmdline,
141142
goto_model.symbol_table,
142143
goto_model.goto_functions);
143144

src/goto-programs/rebuild_goto_start_function.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <util/symbol.h>
1414
#include <util/symbol_table.h>
1515
#include <util/prefix.h>
16+
#include <util/cmdline.h>
1617
#include <langapi/mode.h>
1718
#include <memory>
1819

@@ -25,11 +26,13 @@
2526
/// body of the _start function).
2627
rebuild_goto_start_functiont::rebuild_goto_start_functiont(
2728
message_handlert &_message_handler,
29+
const cmdlinet &cmdline,
2830
symbol_tablet &symbol_table,
2931
goto_functionst &goto_functions):
30-
messaget(_message_handler),
31-
symbol_table(symbol_table),
32-
goto_functions(goto_functions)
32+
messaget(_message_handler),
33+
cmdline(cmdline),
34+
symbol_table(symbol_table),
35+
goto_functions(goto_functions)
3336
{
3437
}
3538

@@ -50,6 +53,7 @@ bool rebuild_goto_start_functiont::operator()(
5053
std::unique_ptr<languaget> language=get_language_from_mode(mode);
5154
INVARIANT(language, "No language found for mode: "+id2string(mode));
5255
language->set_message_handler(get_message_handler());
56+
language->get_language_options(cmdline);
5357

5458
// To create a new entry point we must first remove the old one
5559
remove_existing_entry_point();

src/goto-programs/rebuild_goto_start_function.h

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define CPROVER_GOTO_PROGRAMS_REBUILD_GOTO_START_FUNCTION_H
1111

1212
#include <util/message.h>
13+
class cmdlinet;
1314

1415
class symbol_tablet;
1516
class goto_functionst;
@@ -25,6 +26,7 @@ class rebuild_goto_start_functiont: public messaget
2526
public:
2627
rebuild_goto_start_functiont(
2728
message_handlert &_message_handler,
29+
const cmdlinet &cmdline,
2830
symbol_tablet &symbol_table,
2931
goto_functionst &goto_functions);
3032

@@ -35,6 +37,7 @@ class rebuild_goto_start_functiont: public messaget
3537

3638
void remove_existing_entry_point();
3739

40+
const cmdlinet &cmdline;
3841
symbol_tablet &symbol_table;
3942
goto_functionst &goto_functions;
4043
};

src/java_bytecode/java_bytecode_language.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ bool java_bytecode_languaget::generate_start_function(
116116
const irep_idt &entry_function_symbol_id,
117117
symbol_tablet &symbol_table)
118118
{
119+
PRECONDITION(language_options_initialized);
119120
const auto res=
120121
get_main_symbol(
121122
symbol_table, entry_function_symbol_id, get_message_handler());
@@ -200,6 +201,8 @@ bool java_bytecode_languaget::typecheck(
200201
symbol_tablet &symbol_table,
201202
const std::string &module)
202203
{
204+
PRECONDITION(language_options_initialized);
205+
203206
if(string_refinement_enabled)
204207
string_preprocess.initialize_conversion_table();
205208

@@ -385,6 +388,7 @@ void java_bytecode_languaget::replace_string_methods(
385388

386389
bool java_bytecode_languaget::final(symbol_tablet &symbol_table)
387390
{
391+
PRECONDITION(language_options_initialized);
388392
java_internal_additions(symbol_table);
389393

390394
// replace code of String methods calls by code we generate

0 commit comments

Comments
 (0)