@@ -668,26 +668,63 @@ bool goto_programt::instructiont::equals(const instructiont &other) const
668
668
// clang-format on
669
669
}
670
670
671
- void goto_programt::instructiont::check_id_consistency_symbol_table (
671
+ bool goto_programt::instructiont::check_internal_invariants (
672
672
const symbol_tablet &table,
673
- std::vector<std::string> &message_collector ) const
673
+ messaget &msg ) const
674
674
{
675
+ bool found_violation = false ;
676
+ std::vector<std::string> id_collector;
675
677
auto symbol_finder = [&](const exprt &e) {
676
678
if (e.id () == ID_symbol)
677
679
{
678
680
auto symbol_expr = to_symbol_expr (e);
679
681
if (!table.has_symbol (symbol_expr.get_identifier ()))
680
- message_collector.push_back (
681
- id2string (symbol_expr.get_identifier ()) + " not found" );
682
+ id_collector.push_back (id2string (symbol_expr.get_identifier ()));
682
683
}
683
684
};
684
685
685
- code.visit (symbol_finder);
686
686
if (!table.has_symbol (function))
687
+ id_collector.push_back (id2string (function));
688
+
689
+ switch (type)
690
+ {
691
+ case GOTO:
692
+ case ASSUME:
693
+ case ASSERT:
694
+ guard.visit (symbol_finder);
695
+ break ;
696
+ case ASSIGN:
697
+ case DECL:
698
+ case DEAD:
699
+ case FUNCTION_CALL:
700
+ code.visit (symbol_finder);
701
+ break ;
702
+ case OTHER:
703
+ case SKIP:
704
+ case LOCATION:
705
+ case END_FUNCTION:
706
+ case START_THREAD:
707
+ case END_THREAD:
708
+ case ATOMIC_BEGIN:
709
+ case ATOMIC_END:
710
+ case RETURN:
711
+ case THROW:
712
+ case CATCH:
713
+ case NO_INSTRUCTION_TYPE:
714
+ case INCOMPLETE_GOTO:
715
+ break ;
716
+ }
717
+
718
+ if (!id_collector.empty ())
687
719
{
688
- message_collector.push_back (" function id not found" );
720
+ for (const auto &id : id_collector)
721
+ {
722
+ msg.error () << id << " not found (" << source_location << " )"
723
+ << messaget::eom;
724
+ }
725
+ found_violation = true ;
689
726
}
690
- guard. visit (symbol_finder) ;
727
+ return found_violation ;
691
728
}
692
729
693
730
bool goto_programt::equals (const goto_programt &other) const
@@ -721,14 +758,17 @@ bool goto_programt::equals(const goto_programt &other) const
721
758
return true ;
722
759
}
723
760
724
- void goto_programt::check_id_consistency_symbol_table (
761
+ bool goto_programt::check_internal_invariants (
725
762
const symbol_tablet &table,
726
- std::vector<std::string> &message_collector ) const
763
+ messaget &msg ) const
727
764
{
765
+ bool found_violation = false ;
728
766
forall_goto_program_instructions (it, (*this ))
729
767
{
730
- it->check_id_consistency_symbol_table (table, message_collector);
768
+ found_violation =
769
+ found_violation || it->check_internal_invariants (table, msg);
731
770
}
771
+ return found_violation;
732
772
}
733
773
734
774
// / Outputs a string representation of a `goto_program_instruction_typet`
0 commit comments