Skip to content

Commit 3788467

Browse files
committed
JBMC: add failed symbols on a per-function basis
This uses our journal of all new symbols relating to this function, both from the front-end's activity and subsequent goto-conversion and post-processing (e.g. remove-returns' new symbols) and creates corresponding failed symbols.
1 parent e934867 commit 3788467

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

src/jbmc/jbmc_parse_options.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,10 @@ int jbmc_parse_optionst::get_goto_program(
573573
*this, options, get_message_handler());
574574
lazy_goto_model.initialize(cmdline);
575575

576+
// Add failed symbols for any symbol created prior to loading any
577+
// particular function:
578+
add_failed_symbols(lazy_goto_model.symbol_table);
579+
576580
status() << "Generating GOTO Program" << messaget::eom;
577581
lazy_goto_model.load_all_functions();
578582

@@ -693,6 +697,17 @@ void jbmc_parse_optionst::process_goto_function(
693697

694698
// checks don't know about adjusted float expressions
695699
adjust_float_expressions(goto_function, ns);
700+
701+
// add failed symbols for anything created relating to this particular
702+
// function (note this means subseqent passes mustn't create more!):
703+
journalling_symbol_tablet::changesett new_symbols =
704+
symbol_table.get_inserted();
705+
for(const irep_idt &new_symbol_name : new_symbols)
706+
{
707+
add_failed_symbol_if_needed(
708+
symbol_table.lookup_ref(new_symbol_name),
709+
symbol_table);
710+
}
696711
}
697712

698713
catch(const char *e)
@@ -739,10 +754,6 @@ bool jbmc_parse_optionst::process_goto_functions(
739754
nondet_static(goto_model);
740755
}
741756

742-
// add failed symbols
743-
// needs to be done before pointer analysis
744-
add_failed_symbols(goto_model.symbol_table);
745-
746757
// recalculate numbers, etc.
747758
goto_model.goto_functions.update();
748759

src/pointer-analysis/add_failed_symbols.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ irep_idt failed_symbol_id(const irep_idt &id)
2020
return id2string(id)+"$object";
2121
}
2222

23-
void add_failed_symbol(symbolt &symbol, symbol_tablet &symbol_table)
23+
void add_failed_symbol(symbolt &symbol, symbol_table_baset &symbol_table)
2424
{
2525
if(symbol.type.id()==ID_pointer)
2626
{
@@ -43,7 +43,8 @@ void add_failed_symbol(symbolt &symbol, symbol_tablet &symbol_table)
4343
}
4444
}
4545

46-
void add_failed_symbol(const symbolt &symbol, symbol_tablet &symbol_table)
46+
void add_failed_symbol_if_needed(
47+
const symbolt &symbol, symbol_table_baset &symbol_table)
4748
{
4849
if(!symbol.is_lvalue)
4950
return;
@@ -54,7 +55,7 @@ void add_failed_symbol(const symbolt &symbol, symbol_tablet &symbol_table)
5455
add_failed_symbol(*symbol_table.get_writeable(symbol.name), symbol_table);
5556
}
5657

57-
void add_failed_symbols(symbol_tablet &symbol_table)
58+
void add_failed_symbols(symbol_table_baset &symbol_table)
5859
{
5960
// the symbol table iterators are not stable, and
6061
// we are adding new symbols, this
@@ -64,7 +65,7 @@ void add_failed_symbols(symbol_tablet &symbol_table)
6465
symbol_list.push_back(&(named_symbol.second));
6566

6667
for(const symbolt *symbol : symbol_list)
67-
add_failed_symbol(*symbol, symbol_table);
68+
add_failed_symbol_if_needed(*symbol, symbol_table);
6869
}
6970

7071
exprt get_failed_symbol(

src/pointer-analysis/add_failed_symbols.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,16 @@ Author: Daniel Kroening, [email protected]
1414

1515
#include <util/irep.h>
1616

17-
class symbol_tablet;
17+
class symbol_table_baset;
18+
class symbolt;
1819
class exprt;
1920
class namespacet;
2021
class symbol_exprt;
2122

22-
void add_failed_symbols(symbol_tablet &symbol_table);
23+
void add_failed_symbols(symbol_table_baset &symbol_table);
24+
25+
void add_failed_symbol_if_needed(
26+
const symbolt &symbol, symbol_table_baset &symbol_table);
2327

2428
irep_idt failed_symbol_id(const irep_idt &identifier);
2529

0 commit comments

Comments
 (0)