@@ -26,6 +26,8 @@ Date: November 2011
2626
2727#include < linking/static_lifetime_init.h>
2828
29+ #include < regex>
30+
2931// / See the return.
3032// / \param symbol_expr: The symbol expression to analyze.
3133// / \param ns: Namespace for resolving type information
@@ -200,3 +202,31 @@ void nondet_static(
200202
201203 nondet_static (ns, goto_model.goto_functions , INITIALIZE_FUNCTION);
202204}
205+
206+ // / Nondeterministically initializes global scope variables that
207+ // / match the given regex.
208+ // / \param [out] goto_model: Existing goto-model to be updated.
209+ // / \param regex: regex for matching variables in the format
210+ // / "filename:variable" (same format as those of except_values in
211+ // / nondet_static(goto_model, except_values) variant above).
212+ void nondet_static_matching (goto_modelt &goto_model, const std::string ®ex)
213+ {
214+ const auto regex_matcher = std::regex (regex);
215+ symbol_tablet &symbol_table = goto_model.symbol_table ;
216+
217+ for (symbol_tablet::iteratort symbol_it = symbol_table.begin ();
218+ symbol_it != symbol_table.end ();
219+ symbol_it++)
220+ {
221+ symbolt &symbol = symbol_it.get_writeable_symbol ();
222+ std::string qualified_name = id2string (symbol.location .get_file ()) + " :" +
223+ id2string (symbol.display_name ());
224+ if (!std::regex_match (qualified_name, regex_matcher))
225+ {
226+ symbol.value .set (ID_C_no_nondet_initialization, 1 );
227+ }
228+ }
229+
230+ const namespacet ns (goto_model.symbol_table );
231+ nondet_static (ns, goto_model.goto_functions , INITIALIZE_FUNCTION);
232+ }
0 commit comments