File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed
Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 33#include " symbol_table.h"
44
55#include < ostream>
6+ #include < algorithm>
67#include < util/invariant.h>
78
89// / Add a new symbol to the symbol table
@@ -142,10 +143,20 @@ void symbol_tablet::erase(const symbolst::const_iterator &entry)
142143// / \param out: The ostream to direct output to
143144void symbol_tablet::show (std::ostream &out) const
144145{
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+ });
145157 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);
149160}
150161
151162// / Print the contents of the symbol table
You can’t perform that action at this time.
0 commit comments