File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 3
3
#include " symbol_table.h"
4
4
5
5
#include < ostream>
6
+ #include < algorithm>
6
7
#include < util/invariant.h>
7
8
8
9
// / Add a new symbol to the symbol table
@@ -142,10 +143,20 @@ void symbol_tablet::erase(const symbolst::const_iterator &entry)
142
143
// / \param out: The ostream to direct output to
143
144
void symbol_tablet::show (std::ostream &out) const
144
145
{
146
+ std::vector<irep_idt> sorted_names;
147
+ sorted_names.reserve (symbols.size ());
148
+ for (const auto &elem : symbols)
149
+ sorted_names.push_back (elem.first );
150
+ std::sort (
151
+ sorted_names.begin (),
152
+ sorted_names.end (),
153
+ [](const irep_idt &a, const irep_idt &b)
154
+ {
155
+ return as_string (a) < as_string (b);
156
+ });
145
157
out << " \n " << " Symbols:" << " \n " ;
146
-
147
- forall_symbols (it, symbols)
148
- out << it->second ;
158
+ for (const auto &name : sorted_names)
159
+ out << symbols.at (name);
149
160
}
150
161
151
162
// / Print the contents of the symbol table
You can’t perform that action at this time.
0 commit comments