|
15 | 15 |
|
16 | 16 | #include <json/json_parser.h>
|
17 | 17 |
|
| 18 | +#include <goto-programs/lazy_goto_model.h> |
18 | 19 | #include <goto-programs/set_properties.h>
|
19 | 20 | #include <goto-programs/remove_function_pointers.h>
|
20 | 21 | #include <goto-programs/remove_virtual_functions.h>
|
|
32 | 33 | #include <goto-programs/class_hierarchy.h>
|
33 | 34 | #include <goto-programs/remove_exceptions.h>
|
34 | 35 | #include <goto-programs/remove_java_new.h>
|
| 36 | + |
35 | 37 | #include <analyses/call_graph.h>
|
36 | 38 | #include <analyses/call_graph_helpers.h>
|
37 |
| - |
38 | 39 | #include <analyses/goto_check.h>
|
39 | 40 | #include <analyses/local_may_alias.h>
|
40 | 41 |
|
@@ -140,10 +141,36 @@ int sec_driver_parse_optionst::doit()
|
140 | 141 | register_languages();
|
141 | 142 | register_evs_pretty_printer();
|
142 | 143 |
|
143 |
| - goto_model=initialize_goto_model(cmdline, get_message_handler()); |
| 144 | + lazy_goto_modelt lazy_goto_model = lazy_goto_modelt::from_handler_object( |
| 145 | + *this, options, get_message_handler()); |
| 146 | + lazy_goto_model.initialize(cmdline); |
| 147 | + |
| 148 | + status() << "Generating GOTO Program" << messaget::eom; |
| 149 | + lazy_goto_model.load_all_functions(); |
| 150 | + |
| 151 | + // Show the symbol table before process_goto_functions mangles return |
| 152 | + // values, etc |
| 153 | + if(cmdline.isset("show-symbol-table")) |
| 154 | + { |
| 155 | + ::show_symbol_table(lazy_goto_model.symbol_table, get_ui()); |
| 156 | + return 6; |
| 157 | + } |
144 | 158 |
|
145 |
| - if(process_goto_program(options)) |
| 159 | + std::unique_ptr<goto_modelt> maybe_goto_model = |
| 160 | + lazy_goto_modelt::process_whole_model_and_freeze( |
| 161 | + std::move(lazy_goto_model)); |
| 162 | + if(maybe_goto_model == nullptr) |
146 | 163 | return 6;
|
| 164 | + goto_modelt &goto_model = *maybe_goto_model; |
| 165 | + |
| 166 | + // show it? |
| 167 | + if(cmdline.isset("show-goto-functions")) |
| 168 | + { |
| 169 | + namespacet ns(goto_model.symbol_table); |
| 170 | + |
| 171 | + goto_model.goto_functions.output(ns, std::cout); |
| 172 | + return 6; |
| 173 | + } |
147 | 174 |
|
148 | 175 | if (cmdline.isset("security-scanner"))
|
149 | 176 | {
|
@@ -292,16 +319,45 @@ int sec_driver_parse_optionst::doit()
|
292 | 319 | return 6;
|
293 | 320 | }
|
294 | 321 |
|
295 |
| -bool sec_driver_parse_optionst::process_goto_program( |
296 |
| - const optionst &options) |
| 322 | +void sec_driver_parse_optionst::process_goto_function( |
| 323 | + goto_functionst::goto_functiont &function, |
| 324 | + symbol_tablet &symbol_table) |
297 | 325 | {
|
298 | 326 | try
|
299 | 327 | {
|
300 | 328 | #if 0
|
301 | 329 | // Remove inline assembler; this needs to happen before
|
302 | 330 | // adding the library.
|
303 |
| - remove_asm(goto_model); |
| 331 | + remove_asm(function.body, symbol_table); |
| 332 | +#endif |
| 333 | + } |
304 | 334 |
|
| 335 | + catch(const char *e) |
| 336 | + { |
| 337 | + error() << e << eom; |
| 338 | + throw; |
| 339 | + } |
| 340 | + |
| 341 | + catch(const std::string &e) |
| 342 | + { |
| 343 | + error() << e << eom; |
| 344 | + throw; |
| 345 | + } |
| 346 | + |
| 347 | + catch(const std::bad_alloc &) |
| 348 | + { |
| 349 | + error() << "Out of memory" << eom; |
| 350 | + throw; |
| 351 | + } |
| 352 | +} |
| 353 | + |
| 354 | +bool sec_driver_parse_optionst::process_goto_functions( |
| 355 | + goto_modelt &goto_model, |
| 356 | + const optionst &options) |
| 357 | +{ |
| 358 | + try |
| 359 | + { |
| 360 | +#if 0 |
305 | 361 | // add the library
|
306 | 362 | status() << "Adding CPROVER library ("
|
307 | 363 | << config.ansi_c.arch << ")" << eom;
|
@@ -339,25 +395,6 @@ bool sec_driver_parse_optionst::process_goto_program(
|
339 | 395 |
|
340 | 396 | // recalculate numbers, etc.
|
341 | 397 | goto_model.goto_functions.update();
|
342 |
| - |
343 |
| - // add loop ids |
344 |
| - goto_model.goto_functions.compute_loop_numbers(); |
345 |
| - |
346 |
| - // show it? |
347 |
| - if(cmdline.isset("show-goto-functions")) |
348 |
| - { |
349 |
| - namespacet ns(goto_model.symbol_table); |
350 |
| - |
351 |
| - goto_model.goto_functions.output(ns, std::cout); |
352 |
| - return true; |
353 |
| - } |
354 |
| - |
355 |
| - // show it? |
356 |
| - if(cmdline.isset("show-symbol-table")) |
357 |
| - { |
358 |
| - ::show_symbol_table(goto_model, get_ui()); |
359 |
| - return true; |
360 |
| - } |
361 | 398 | }
|
362 | 399 |
|
363 | 400 | catch(const char *e)
|
|
0 commit comments