-#include "llvm/Value.h"
-#include "llvm/Analysis/CallGraph.h"
-#include "llvm/Analysis/Dominators.h"
-#include <iostream>
-#include <fstream>
-using namespace llvm;
-
-template<typename GraphType>
-static void WriteGraphToFile(std::ostream &O, const std::string &GraphName,
- const GraphType >) {
- std::string Filename = GraphName + ".dot";
- O << "Writing '" << Filename << "'...";
- std::ofstream F(Filename.c_str());
-
- if (F.good())
- WriteGraph(F, GT);
- else
- O << " error opening file for writing!";
- O << "\n";
-}
-
-
-//===----------------------------------------------------------------------===//
-// Call Graph Printer
-//===----------------------------------------------------------------------===//
-
-namespace llvm {
- template<>
- struct DOTGraphTraits<CallGraph*> : public DefaultDOTGraphTraits {
- static std::string getGraphName(CallGraph *F) {
- return "Call Graph";
- }
-
- static std::string getNodeLabel(CallGraphNode *Node, CallGraph *Graph,
- bool ShortNames) {
- if (Node->getFunction())
- return ((Value*)Node->getFunction())->getName();
- else
- return "Indirect call node";
- }
- };
-}
-