File tree Expand file tree Collapse file tree 5 files changed +63
-11
lines changed Expand file tree Collapse file tree 5 files changed +63
-11
lines changed Original file line number Diff line number Diff line change @@ -73,3 +73,44 @@ void goto_functionst::compute_loop_numbers()
73
73
func.second .body .compute_loop_numbers ();
74
74
}
75
75
}
76
+
77
+ // / returns a vector of the iterators in alphabetical order
78
+ std::vector<goto_functionst::function_mapt::const_iterator>
79
+ goto_functionst::sorted () const
80
+ {
81
+ std::vector<function_mapt::const_iterator> result;
82
+
83
+ result.reserve (function_map.size ());
84
+
85
+ for (auto it = function_map.begin (); it != function_map.end (); it++)
86
+ result.push_back (it);
87
+
88
+ std::sort (
89
+ result.begin (),
90
+ result.end (),
91
+ [](function_mapt::const_iterator a, function_mapt::const_iterator b) {
92
+ return id2string (a->first ) < id2string (b->first );
93
+ });
94
+
95
+ return result;
96
+ }
97
+
98
+ // / returns a vector of the iterators in alphabetical order
99
+ std::vector<goto_functionst::function_mapt::iterator> goto_functionst::sorted ()
100
+ {
101
+ std::vector<function_mapt::iterator> result;
102
+
103
+ result.reserve (function_map.size ());
104
+
105
+ for (auto it = function_map.begin (); it != function_map.end (); it++)
106
+ result.push_back (it);
107
+
108
+ std::sort (
109
+ result.begin (),
110
+ result.end (),
111
+ [](function_mapt::iterator a, function_mapt::iterator b) {
112
+ return id2string (a->first ) < id2string (b->first );
113
+ });
114
+
115
+ return result;
116
+ }
Original file line number Diff line number Diff line change @@ -118,6 +118,9 @@ class goto_functionst
118
118
for (const auto &fun : other.function_map )
119
119
function_map[fun.first ].copy_from (fun.second );
120
120
}
121
+
122
+ std::vector<function_mapt::const_iterator> sorted () const ;
123
+ std::vector<function_mapt::iterator> sorted ();
121
124
};
122
125
123
126
#define Forall_goto_functions (it, functions ) \
Original file line number Diff line number Diff line change @@ -51,10 +51,13 @@ void show_goto_functions(
51
51
52
52
case ui_message_handlert::uit::PLAIN:
53
53
{
54
- for (const auto &fun : goto_functions.function_map )
54
+ // sort alphabetically
55
+ const auto sorted = goto_functions.sorted ();
56
+
57
+ for (const auto &fun : sorted)
55
58
{
56
- const symbolt &symbol = ns.lookup (fun. first );
57
- const bool has_body = fun. second .body_available ();
59
+ const symbolt &symbol = ns.lookup (fun-> first );
60
+ const bool has_body = fun-> second .body_available ();
58
61
59
62
if (list_only)
60
63
{
@@ -67,10 +70,9 @@ void show_goto_functions(
67
70
{
68
71
msg.status () << " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n " ;
69
72
70
- const symbolt &symbol = ns.lookup (fun.first );
71
73
msg.status () << messaget::bold << symbol.display_name ()
72
74
<< messaget::reset << " /* " << symbol.name << " */\n " ;
73
- fun. second .body .output (ns, symbol.name , msg.status ());
75
+ fun-> second .body .output (ns, symbol.name , msg.status ());
74
76
msg.status () << messaget::eom;
75
77
}
76
78
}
Original file line number Diff line number Diff line change @@ -41,10 +41,13 @@ json_objectt show_goto_functions_jsont::convert(
41
41
{
42
42
json_arrayt json_functions;
43
43
const json_irept no_comments_irep_converter (false );
44
- for (const auto &function_entry : goto_functions.function_map )
44
+
45
+ const auto sorted = goto_functions.sorted ();
46
+
47
+ for (const auto &function_entry : sorted)
45
48
{
46
- const irep_idt &function_name= function_entry. first ;
47
- const goto_functionst::goto_functiont &function= function_entry. second ;
49
+ const irep_idt &function_name = function_entry-> first ;
50
+ const goto_functionst::goto_functiont &function = function_entry-> second ;
48
51
49
52
json_objectt &json_function=
50
53
json_functions.push_back (jsont ()).make_object ();
Original file line number Diff line number Diff line change @@ -43,10 +43,13 @@ xmlt show_goto_functions_xmlt::convert(
43
43
const goto_functionst &goto_functions)
44
44
{
45
45
xmlt xml_functions=xmlt (" functions" );
46
- for (const auto &function_entry : goto_functions.function_map )
46
+
47
+ const auto sorted = goto_functions.sorted ();
48
+
49
+ for (const auto &function_entry : sorted)
47
50
{
48
- const irep_idt &function_name= function_entry. first ;
49
- const goto_functionst::goto_functiont &function= function_entry. second ;
51
+ const irep_idt &function_name = function_entry-> first ;
52
+ const goto_functionst::goto_functiont &function = function_entry-> second ;
50
53
51
54
xmlt &xml_function=xml_functions.new_element (" function" );
52
55
xml_function.set_attribute (" name" , id2string (function_name));
You can’t perform that action at this time.
0 commit comments