retdec
graphviz_cg_writer.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_LLVMIR2HLL_GRAPHS_CG_CG_WRITERS_GRAPHVIZ_CG_WRITER_H
8 #define RETDEC_LLVMIR2HLL_GRAPHS_CG_CG_WRITERS_GRAPHVIZ_CG_WRITER_H
9 
10 #include <ostream>
11 #include <string>
12 
16 
17 namespace retdec {
18 namespace llvmir2hll {
19 
28 class GraphvizCGWriter: public CGWriter {
29 public:
30  static ShPtr<CGWriter> create(ShPtr<CG> cg, std::ostream &out);
31 
32  virtual std::string getId() const override;
33  virtual bool emitCG() override;
34 
35 private:
37  using NodeLabelMapping = std::map<ShPtr<Function>, std::string>;
38 
39 private:
40  GraphvizCGWriter(ShPtr<CG> cg, std::ostream &out);
41 
42  void emitNode(ShPtr<Function> caller, ShPtr<CG::CalledFuncs> callees);
43  std::string getNodeLabelForFunc(ShPtr<Function> func);
44 };
45 
46 } // namespace llvmir2hll
47 } // namespace retdec
48 
49 #endif
A representation of a call graph (CG).
A base class of all call graph (CG) writers.
A base class of all call graph (CG) writers.
Definition: cg_writer.h:27
std::ostream & out
Stream, where the resulting CG will be emitted.
Definition: cg_writer.h:53
ShPtr< CG > cg
CG to be emitted.
Definition: cg_writer.h:50
A CG writer in the dot format (graphviz).
Definition: graphviz_cg_writer.h:28
virtual bool emitCG() override
Emits the given CG into the given output stream.
Definition: graphviz_cg_writer.cpp:66
std::string getNodeLabelForFunc(ShPtr< Function > func)
Returns a node label for the given function.
Definition: graphviz_cg_writer.cpp:162
GraphvizCGWriter(ShPtr< CG > cg, std::ostream &out)
Constructs a new graphviz CG writer.
Definition: graphviz_cg_writer.cpp:49
static ShPtr< CGWriter > create(ShPtr< CG > cg, std::ostream &out)
Creates a new graphviz CG writer.
Definition: graphviz_cg_writer.cpp:58
std::map< ShPtr< Function >, std::string > NodeLabelMapping
Mapping between a node and its label.
Definition: graphviz_cg_writer.h:37
void emitNode(ShPtr< Function > caller, ShPtr< CG::CalledFuncs > callees)
Emits the node given by caller and callees.
Definition: graphviz_cg_writer.cpp:144
virtual std::string getId() const override
Returns the ID of the writer.
Definition: graphviz_cg_writer.cpp:62
A library providing API for working with back-end IR.
std::shared_ptr< T > ShPtr
An alias for a shared pointer.
Definition: smart_ptr.h:18
Definition: archive_wrapper.h:19
Declarations, aliases, macros, etc. for the use of smart pointers.