@@ -978,3 +978,63 @@ void symex_target_equationt::SSA_stept::output(std::ostream &out) const
978978
979979 out << " Guard: " << format (guard) << ' \n ' ;
980980}
981+
982+ // / Check that the SSA step is well-formed
983+ // / \param ns namespace to lookup identifiers
984+ // / \param vm validation mode to be used for reporting failures
985+ void symex_target_equationt::SSA_stept::validate (
986+ const namespacet &ns,
987+ const validation_modet vm) const
988+ {
989+ validate_full_expr (guard, ns, vm);
990+
991+ switch (type)
992+ {
993+ case goto_trace_stept::typet::ASSERT:
994+ case goto_trace_stept::typet::ASSUME:
995+ case goto_trace_stept::typet::GOTO:
996+ case goto_trace_stept::typet::CONSTRAINT:
997+ validate_full_expr (cond_expr, ns, vm);
998+ break ;
999+ case goto_trace_stept::typet::ASSIGNMENT:
1000+ case goto_trace_stept::typet::DECL:
1001+ validate_full_expr (ssa_lhs, ns, vm);
1002+ validate_full_expr (ssa_full_lhs, ns, vm);
1003+ validate_full_expr (original_full_lhs, ns, vm);
1004+ validate_full_expr (ssa_rhs, ns, vm);
1005+ DATA_CHECK (
1006+ vm,
1007+ base_type_eq (ssa_lhs.get_original_expr (), ssa_rhs, ns),
1008+ " Type inequality in SSA assignment\n lhs-type: " +
1009+ ssa_lhs.get_original_expr ().type ().id_string () +
1010+ " \n rhs-type: " + ssa_rhs.type ().id_string ());
1011+ break ;
1012+ case goto_trace_stept::typet::INPUT:
1013+ case goto_trace_stept::typet::OUTPUT:
1014+ for (const auto &expr : io_args)
1015+ validate_full_expr (expr, ns, vm);
1016+ break ;
1017+ case goto_trace_stept::typet::FUNCTION_CALL:
1018+ for (const auto &expr : ssa_function_arguments)
1019+ validate_full_expr (expr, ns, vm);
1020+ case goto_trace_stept::typet::FUNCTION_RETURN:
1021+ {
1022+ const symbolt *symbol;
1023+ DATA_CHECK (
1024+ vm,
1025+ called_function.empty () || !ns.lookup (called_function, symbol),
1026+ " unknown function identifier " + id2string (called_function));
1027+ }
1028+ break ;
1029+ case goto_trace_stept::typet::NONE:
1030+ case goto_trace_stept::typet::LOCATION:
1031+ case goto_trace_stept::typet::DEAD:
1032+ case goto_trace_stept::typet::SHARED_READ:
1033+ case goto_trace_stept::typet::SHARED_WRITE:
1034+ case goto_trace_stept::typet::SPAWN:
1035+ case goto_trace_stept::typet::MEMORY_BARRIER:
1036+ case goto_trace_stept::typet::ATOMIC_BEGIN:
1037+ case goto_trace_stept::typet::ATOMIC_END:
1038+ break ;
1039+ }
1040+ }
0 commit comments