Skip to content

Commit f0543bd

Browse files
authored
Merge pull request #8418 from tautschnig/lazy_goto_model-no-dynamic_cast
jbmc, janalyzer: Remove unnecessary dynamic_cast
2 parents a29e933 + 3fef02a commit f0543bd

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

jbmc/src/janalyzer/janalyzer_parse_options.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,13 @@ int janalyzer_parse_optionst::doit()
401401
log.status() << "Generating GOTO Program" << messaget::eom;
402402
lazy_goto_model.load_all_functions();
403403

404-
std::unique_ptr<abstract_goto_modelt> goto_model_ptr =
404+
std::unique_ptr<goto_modelt> goto_model_ptr =
405405
lazy_goto_modelt::process_whole_model_and_freeze(
406406
std::move(lazy_goto_model));
407407
if(goto_model_ptr == nullptr)
408408
return CPROVER_EXIT_INTERNAL_ERROR;
409409

410-
goto_modelt &goto_model = dynamic_cast<goto_modelt &>(*goto_model_ptr);
410+
goto_modelt &goto_model = *goto_model_ptr;
411411

412412
// show it?
413413
if(cmdline.isset("show-symbol-table"))

jbmc/src/jbmc/jbmc_parse_options.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -628,12 +628,16 @@ int jbmc_parse_optionst::get_goto_program(
628628

629629
// Move the model out of the local lazy_goto_model
630630
// and into the caller's goto_model
631-
goto_model_ptr = lazy_goto_modelt::process_whole_model_and_freeze(
632-
std::move(lazy_goto_model));
633-
if(goto_model_ptr == nullptr)
631+
auto final_goto_model_ptr =
632+
lazy_goto_modelt::process_whole_model_and_freeze(
633+
std::move(lazy_goto_model));
634+
if(final_goto_model_ptr == nullptr)
634635
return CPROVER_EXIT_INTERNAL_ERROR;
635636

636-
goto_modelt &goto_model = dynamic_cast<goto_modelt &>(*goto_model_ptr);
637+
goto_modelt &goto_model = *final_goto_model_ptr;
638+
goto_model_ptr =
639+
std::unique_ptr<abstract_goto_modelt>(final_goto_model_ptr.get());
640+
final_goto_model_ptr.release();
637641

638642
if(cmdline.isset("validate-goto-model"))
639643
{

0 commit comments

Comments
 (0)