aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CallGraph.cpp
diff options
context:
space:
mode:
authorZhongxing Xu <xuzhongxing@gmail.com>2009-07-23 09:04:23 +0000
committerZhongxing Xu <xuzhongxing@gmail.com>2009-07-23 09:04:23 +0000
commit16a705f26d069a0c9e391bf064bcd1bc3496ca83 (patch)
tree2eec057bfcb602f27de4d4029da5cddebafaa3bf /lib/Analysis/CallGraph.cpp
parentf7856437cfcf49523d81ebe1fc2351e3284dedfa (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76874 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CallGraph.cpp')
-rw-r--r--lib/Analysis/CallGraph.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Analysis/CallGraph.cpp b/lib/Analysis/CallGraph.cpp
index 5605439ea9..bfc2c0d219 100644
--- a/lib/Analysis/CallGraph.cpp
+++ b/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();
+
+ }
+
+};
+
+}