Skip to content

Commit 7b04a04

Browse files
committed
Use remove_instanceof in driver programs
This adds a remove_instanceof call wherever there was an existing remove_virtual_functions call.
1 parent def72f4 commit 7b04a04

File tree

5 files changed

+20
-0
lines changed

5 files changed

+20
-0
lines changed

src/cbmc/cbmc_parse_options.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Author: Daniel Kroening, [email protected]
2222
#include <goto-programs/goto_convert_functions.h>
2323
#include <goto-programs/remove_function_pointers.h>
2424
#include <goto-programs/remove_virtual_functions.h>
25+
#include <goto-programs/remove_instanceof.h>
2526
#include <goto-programs/remove_returns.h>
2627
#include <goto-programs/remove_vector.h>
2728
#include <goto-programs/remove_complex.h>
@@ -884,7 +885,10 @@ bool cbmc_parse_optionst::process_goto_program(
884885
symbol_table,
885886
goto_functions,
886887
cmdline.isset("pointer-check"));
888+
// Java virtual functions -> explicit dispatch tables:
887889
remove_virtual_functions(symbol_table, goto_functions);
890+
// Java instanceof -> clsid comparison:
891+
remove_instanceof(symbol_table, goto_functions);
888892

889893
// full slice?
890894
if(cmdline.isset("full-slice"))

src/goto-analyzer/goto_analyzer_parse_options.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Author: Daniel Kroening, [email protected]
1919
#include <goto-programs/set_properties.h>
2020
#include <goto-programs/remove_function_pointers.h>
2121
#include <goto-programs/remove_virtual_functions.h>
22+
#include <goto-programs/remove_instanceof.h>
2223
#include <goto-programs/remove_returns.h>
2324
#include <goto-programs/remove_vector.h>
2425
#include <goto-programs/remove_complex.h>
@@ -380,7 +381,10 @@ bool goto_analyzer_parse_optionst::process_goto_program(
380381
// remove function pointers
381382
status() << "Removing function pointers and virtual functions" << eom;
382383
remove_function_pointers(goto_model, cmdline.isset("pointer-check"));
384+
// Java virtual functions -> explicit dispatch tables:
383385
remove_virtual_functions(goto_model);
386+
// Java instanceof -> clsid comparison:
387+
remove_instanceof(goto_model);
384388

385389
// do partial inlining
386390
status() << "Partial Inlining" << eom;

src/goto-programs/remove_instanceof.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,9 @@ void remove_instanceof(
276276
remove_instanceoft rem(symbol_table, goto_functions);
277277
rem.lower_instanceof();
278278
}
279+
280+
void remove_instanceof(goto_modelt &goto_model)
281+
{
282+
remove_instanceof(
283+
goto_model.symbol_table, goto_model.goto_functions);
284+
}

src/goto-programs/remove_instanceof.h

+2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ Author: Chris Smowton, [email protected]
1111

1212
#include <util/symbol_table.h>
1313
#include "goto_functions.h"
14+
#include "goto_model.h"
1415

1516
void remove_instanceof(
1617
symbol_tablet &symbol_table,
1718
goto_functionst &goto_functions);
1819

20+
void remove_instanceof(goto_modelt &model);
1921

2022
#endif

src/symex/symex_parse_options.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Author: Daniel Kroening, [email protected]
3232
#include <goto-programs/remove_complex.h>
3333
#include <goto-programs/remove_vector.h>
3434
#include <goto-programs/remove_virtual_functions.h>
35+
#include <goto-programs/remove_instanceof.h>
3536

3637
#include <goto-symex/rewrite_union.h>
3738
#include <goto-symex/adjust_float_expressions.h>
@@ -361,7 +362,10 @@ bool symex_parse_optionst::process_goto_program(const optionst &options)
361362
// remove stuff
362363
remove_complex(goto_model);
363364
remove_vector(goto_model);
365+
// Java virtual functions -> explicit dispatch tables:
364366
remove_virtual_functions(goto_model);
367+
// Java instanceof -> clsid comparison:
368+
remove_instanceof(goto_model);
365369
rewrite_union(goto_model);
366370
adjust_float_expressions(goto_model);
367371

0 commit comments

Comments
 (0)