diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-07-23 09:04:23 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-07-23 09:04:23 +0000 |
commit | a598e5c9d515beaedff2412dba4f72e5be0068ba (patch) | |
tree | 42ac6f379c1f6154975b2d0441b71d056e2d50dd /clang/lib/Analysis/CallGraph.cpp | |
parent | fdd52922c2ed7f9ae50009937f9187e1bfb9235e (diff) | |
download | bcm5719-llvm-a598e5c9d515beaedff2412dba4f72e5be0068ba.tar.gz bcm5719-llvm-a598e5c9d515beaedff2412dba4f72e5be0068ba.zip |
Add template specializations to view the call graph in dot format.
- change the DenseMap used in callgraph to std::map, since DenseMap cannot
be used with mapped_iterator and friends.
llvm-svn: 76874
Diffstat (limited to 'clang/lib/Analysis/CallGraph.cpp')
-rw-r--r-- | clang/lib/Analysis/CallGraph.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/Analysis/CallGraph.cpp b/clang/lib/Analysis/CallGraph.cpp index 5605439ea94..bfc2c0d2194 100644 --- a/clang/lib/Analysis/CallGraph.cpp +++ b/clang/lib/Analysis/CallGraph.cpp @@ -16,6 +16,8 @@ #include "clang/AST/ASTContext.h" #include "clang/AST/StmtVisitor.h" +#include "llvm/Support/GraphWriter.h" + using namespace clang; using namespace idx; @@ -111,3 +113,22 @@ void CallGraph::print(llvm::raw_ostream &os) { void CallGraph::dump() { print(llvm::errs()); } + +void CallGraph::ViewCallGraph() const { + llvm::ViewGraph(*this, "CallGraph"); +} + +namespace llvm { + +template <> +struct DOTGraphTraits<CallGraph> : public DefaultDOTGraphTraits { + + static std::string getNodeLabel(const CallGraphNode *Node, + const CallGraph &CG, bool ShortNames) { + return Node->getName(); + + } + +}; + +} |