Skip to content

Commit

Permalink
Added lexicographical order to textual dump of functions and symbols.
Browse files Browse the repository at this point in the history
  • Loading branch information
marek-trtik committed Oct 2, 2017
1 parent 733f7b2 commit 56b0b26
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
13 changes: 12 additions & 1 deletion src/goto-programs/goto_functions_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Date: June 2003

#include <ostream>
#include <cassert>
#include <algorithm>

#include <util/std_types.h>
#include <util/symbol.h>
Expand Down Expand Up @@ -166,8 +167,18 @@ void goto_functions_templatet<bodyT>::output(
const namespacet &ns,
std::ostream &out) const
{
std::vector<irep_idt> sorted_names;
sorted_names.reserve(function_map.size());
for(const auto &fun : function_map)
{
sorted_names.push_back(fun.first);
std::sort(
sorted_names.begin(),
sorted_names.end(),
[](const irep_idt &a, const irep_idt &b)
{ return as_string(a)<as_string(b); });
for(const auto &name : sorted_names)
{
const auto &fun=*function_map.find(name);
if(fun.second.body_available())
{
out << "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n";
Expand Down
15 changes: 12 additions & 3 deletions src/util/symbol_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "symbol_table.h"

#include <ostream>
#include <algorithm>
#include <util/invariant.h>


Expand Down Expand Up @@ -80,10 +81,18 @@ bool symbol_tablet::remove(const irep_idt &name)
/// \param out: The ostream to direct output to
void symbol_tablet::show(std::ostream &out) const
{
std::vector<irep_idt> sorted_names;
sorted_names.reserve(symbols.size());
for(const auto &elem : symbols)
sorted_names.push_back(elem.first);
std::sort(
sorted_names.begin(),
sorted_names.end(),
[](const irep_idt &a, const irep_idt &b)
{ return as_string(a)<as_string(b); });
out << "\n" << "Symbols:" << "\n";

forall_symbols(it, symbols)
out << it->second;
for(const auto &name : sorted_names)
out << symbols.at(name);
}

/// Print the contents of the symbol table
Expand Down

0 comments on commit 56b0b26

Please sign in to comment.