SVF
Public Member Functions | Static Public Member Functions | List of all members
llvm::GraphPrinter Class Reference

#include <GraphPrinter.h>

Public Member Functions

 GraphPrinter ()
 

Static Public Member Functions

template<class GraphType >
static void WriteGraphToFile (llvm::raw_ostream &O, const std::string &GraphName, const GraphType &GT, bool simple=false)
 
template<class GraphType >
static void PrintGraph (llvm::raw_ostream &O, const std::string &GraphName, const GraphType &GT)
 

Detailed Description

Definition at line 44 of file GraphPrinter.h.

Constructor & Destructor Documentation

◆ GraphPrinter()

llvm::GraphPrinter::GraphPrinter ( )
inline

Definition at line 48 of file GraphPrinter.h.

49  {
50  }

Member Function Documentation

◆ PrintGraph()

template<class GraphType >
static void llvm::GraphPrinter::PrintGraph ( llvm::raw_ostream &  O,
const std::string &  GraphName,
const GraphType &  GT 
)
inlinestatic

Print the graph to command line

Define the GTraits and node iterator for printing

Definition at line 85 of file GraphPrinter.h.

87  {
89  typedef llvm::GraphTraits<GraphType> GTraits;
90 
91  typedef typename GTraits::NodeRef NodeRef;
92  typedef typename GTraits::nodes_iterator node_iterator;
93  typedef typename GTraits::ChildIteratorType child_iterator;
94 
95  O << "Printing VFG Graph" << "'...\n";
96  // Print each node name and its edges
97  node_iterator I = GTraits::nodes_begin(GT);
98  node_iterator E = GTraits::nodes_end(GT);
99  for (; I != E; ++I)
100  {
101  NodeRef *Node = *I;
102  O << "node :" << Node << "'\n";
103  child_iterator EI = GTraits::child_begin(Node);
104  child_iterator EE = GTraits::child_end(Node);
105  for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i)
106  {
107  O << "child :" << *EI << "'\n";
108  }
109  }
110  }

◆ WriteGraphToFile()

template<class GraphType >
static void llvm::GraphPrinter::WriteGraphToFile ( llvm::raw_ostream &  O,
const std::string &  GraphName,
const GraphType &  GT,
bool  simple = false 
)
inlinestatic

Write the graph into dot file for debugging purpose

Definition at line 56 of file GraphPrinter.h.

58  {
59  // Filename of the output dot file
60  std::string Filename = GraphName + ".dot";
61  O << "Writing '" << Filename << "'...";
62  std::error_code ErrInfo;
63  llvm::ToolOutputFile F(Filename.c_str(), ErrInfo, llvm::sys::fs::F_None);
64 
65  if (!ErrInfo)
66  {
67  // dump the ValueFlowGraph here
68  WriteGraph(F.os(), GT, simple);
69  F.os().close();
70  if (!F.os().has_error())
71  {
72  O << "\n";
73  F.keep();
74  return;
75  }
76  }
77  O << " error opening file for writing!\n";
78  F.os().clear_error();
79  }
llvm::ToolOutputFile ToolOutputFile
Definition: BasicTypes.h:103

The documentation for this class was generated from the following file: