Skip to content

Commit e8e20ea

Browse files
authored
Merge pull request #1117 from mgudemann/fix/ignore_functions_not_in_symbol_table_remove_static_init
Skip functions not in the symbol table in remove <clinit> loops
2 parents dba081f + 4da42f9 commit e8e20ea

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

src/cbmc/cbmc_parse_options.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,11 @@ int cbmc_parse_optionst::doit()
506506
// unwinds <clinit> loops to number of enum elements
507507
// side effect: add this as explicit unwind to unwind set
508508
if(options.get_bool_option("java-unwind-enum-static"))
509-
remove_static_init_loops(symbol_table, goto_functions, options);
509+
remove_static_init_loops(
510+
symbol_table,
511+
goto_functions,
512+
options,
513+
ui_message_handler);
510514

511515
// get solver
512516
cbmc_solverst cbmc_solvers(options, symbol_table, ui_message_handler);

src/goto-programs/remove_static_init_loops.cpp

+16-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include <algorithm>
1313

14-
#include <util/message.h>
1514
#include <util/suffix.h>
1615
#include <util/string2int.h>
1716

@@ -27,7 +26,8 @@ class remove_static_init_loopst
2726

2827
void unwind_enum_static(
2928
const goto_functionst &goto_functions,
30-
optionst &options);
29+
optionst &options,
30+
message_handlert &);
3131
protected:
3232
const symbol_tablet &symbol_table;
3333
};
@@ -38,9 +38,12 @@ class remove_static_init_loopst
3838
/// \return side effect is adding <clinit> loops to unwindset
3939
void remove_static_init_loopst::unwind_enum_static(
4040
const goto_functionst &goto_functions,
41-
optionst &options)
41+
optionst &options,
42+
message_handlert &msg)
4243
{
4344
size_t unwind_max=0;
45+
messaget message;
46+
message.set_message_handler(msg);
4447
forall_goto_functions(f, goto_functions)
4548
{
4649
auto &p=f->second.body;
@@ -53,6 +56,13 @@ void remove_static_init_loopst::unwind_enum_static(
5356
const std::string java_clinit="<clinit>:()V";
5457
const std::string &fname=id2string(ins.function);
5558
size_t class_prefix_length=fname.find_last_of('.');
59+
// is the function symbol in the symbol table?
60+
if(!symbol_table.has_symbol(ins.function))
61+
{
62+
message.warning() << "function `" << id2string(ins.function)
63+
<< "` is not in symbol table" << messaget::eom;
64+
continue;
65+
}
5666
// is Java function and static init?
5767
const symbolt &function_name=symbol_table.lookup(ins.function);
5868
if(!(function_name.mode==ID_java && has_suffix(fname, java_clinit)))
@@ -96,8 +106,9 @@ void remove_static_init_loopst::unwind_enum_static(
96106
void remove_static_init_loops(
97107
const symbol_tablet &symbol_table,
98108
const goto_functionst &goto_functions,
99-
optionst &options)
109+
optionst &options,
110+
message_handlert &msg)
100111
{
101112
remove_static_init_loopst remove_loops(symbol_table);
102-
remove_loops.unwind_enum_static(goto_functions, options);
113+
remove_loops.unwind_enum_static(goto_functions, options, msg);
103114
}

src/goto-programs/remove_static_init_loops.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Author: Daniel Kroening, [email protected]
1111

1212
#include <goto-programs/goto_functions.h>
1313

14+
#include <util/message.h>
1415
#include <util/options.h>
1516
#include <util/symbol_table.h>
1617

@@ -20,6 +21,7 @@ Author: Daniel Kroening, [email protected]
2021
void remove_static_init_loops(
2122
const symbol_tablet &,
2223
const goto_functionst &,
23-
optionst &);
24+
optionst &,
25+
message_handlert &);
2426

2527
#endif // CPROVER_GOTO_PROGRAMS_REMOVE_STATIC_INIT_LOOPS_H

0 commit comments

Comments
 (0)