File tree Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Expand file tree Collapse file tree 2 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -992,6 +992,48 @@ void goto_programt::instructiont::transform(
992
992
}
993
993
}
994
994
995
+ void goto_programt::instructiont::apply (
996
+ std::function<void (const exprt &)> f) const
997
+ {
998
+ switch (type)
999
+ {
1000
+ case OTHER:
1001
+ if (get_other ().get_statement () == ID_expression)
1002
+ f (to_code_expression (get_other ()).expression ());
1003
+ break ;
1004
+
1005
+ case RETURN:
1006
+ f (get_return ().return_value ());
1007
+ break ;
1008
+
1009
+ case ASSIGN:
1010
+ f (get_assign ().lhs ());
1011
+ f (get_assign ().rhs ());
1012
+ break ;
1013
+
1014
+ case DECL:
1015
+ f (get_decl ().symbol ());
1016
+ break ;
1017
+
1018
+ case DEAD:
1019
+ f (get_dead ().symbol ());
1020
+ break ;
1021
+
1022
+ case FUNCTION_CALL:
1023
+ {
1024
+ const auto &call = get_function_call ();
1025
+ f (new_call.lhs ());
1026
+ for (auto &a : call.arguments ())
1027
+ f (a);
1028
+ }
1029
+ break ;
1030
+
1031
+ default :
1032
+ if (has_condition ())
1033
+ f (get_condition ());
1034
+ }
1035
+ }
1036
+
995
1037
bool goto_programt::equals (const goto_programt &other) const
996
1038
{
997
1039
if (instructions.size () != other.instructions .size ())
Original file line number Diff line number Diff line change @@ -559,6 +559,9 @@ class goto_programt
559
559
// / Apply given transformer to all expressions; no return value
560
560
// / means no change needed.
561
561
void transform (std::function<optionalt<exprt>(exprt)>);
562
+
563
+ // / Apply given function to all expressions
564
+ void apply (std::function<void (const exprt &)>) const ;
562
565
};
563
566
564
567
// Never try to change this to vector-we mutate the list while iterating
You can’t perform that action at this time.
0 commit comments