@@ -668,36 +668,27 @@ bool goto_programt::instructiont::equals(const instructiont &other) const
668668 // clang-format on
669669}
670670
671- bool goto_programt::instructiont::check_internal_invariants (
672- const symbol_tablet &table,
673- messaget &msg) const
671+ void goto_programt::instructiont::validate (
672+ const std::function<void (const exprt &, const source_locationt &)>
673+ &symbol_finder,
674+ const validation_modet &vm) const
674675{
675- bool found_violation = false ;
676- std::vector<std::string> id_collector;
677- auto symbol_finder = [&](const exprt &e) {
678- if (e.id () == ID_symbol)
679- {
680- auto symbol_expr = to_symbol_expr (e);
681- if (!table.has_symbol (symbol_expr.get_identifier ()))
682- id_collector.push_back (id2string (symbol_expr.get_identifier ()));
683- }
676+ auto expr_symbol_finder = [&](const exprt &e) {
677+ symbol_finder (e, source_location);
684678 };
685679
686- if (!table.has_symbol (function))
687- id_collector.push_back (id2string (function));
688-
689680 switch (type)
690681 {
691682 case GOTO:
692683 case ASSUME:
693684 case ASSERT:
694- guard.visit (symbol_finder );
685+ guard.visit (expr_symbol_finder );
695686 break ;
696687 case ASSIGN:
697688 case DECL:
698689 case DEAD:
699690 case FUNCTION_CALL:
700- code.visit (symbol_finder );
691+ code.visit (expr_symbol_finder );
701692 break ;
702693 case OTHER:
703694 case SKIP:
@@ -714,17 +705,6 @@ bool goto_programt::instructiont::check_internal_invariants(
714705 case INCOMPLETE_GOTO:
715706 break ;
716707 }
717-
718- if (!id_collector.empty ())
719- {
720- for (const auto &id : id_collector)
721- {
722- msg.error () << id << " not found (" << source_location << " )"
723- << messaget::eom;
724- }
725- found_violation = true ;
726- }
727- return found_violation;
728708}
729709
730710bool goto_programt::equals (const goto_programt &other) const
@@ -758,17 +738,15 @@ bool goto_programt::equals(const goto_programt &other) const
758738 return true ;
759739}
760740
761- bool goto_programt::check_internal_invariants (
762- const symbol_tablet &table,
763- messaget &msg) const
741+ void goto_programt::validate (
742+ const std::function<void (const exprt &, const source_locationt &)>
743+ &symbol_finder,
744+ const validation_modet &vm) const
764745{
765- bool found_violation = false ;
766746 forall_goto_program_instructions (it, (*this ))
767747 {
768- found_violation =
769- found_violation || it->check_internal_invariants (table, msg);
748+ it->validate (symbol_finder, vm);
770749 }
771- return found_violation;
772750}
773751
774752// / Outputs a string representation of a `goto_program_instruction_typet`
0 commit comments