aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CallGraph.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2012-12-21 01:30:23 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2012-12-21 01:30:23 +0000
commit6d42f4d8b8a176336a8c49ec3cf5f7fb6545ccfd (patch)
treea4f2b31f0fde74b42d486050507d0a43d9f772bc /lib/Analysis/CallGraph.cpp
parent0db661e67f613f49d047cdf53da29b9741234ad8 (diff)
Revert r170826. The output of
./bin/clang -cc1 -internal-isystem /home/espindola/llvm/build/lib/clang/3.3/include/ -analyze -analyzer-checker=debug.DumpCallGraph /home/espindola/llvm/clang/test/Analysis/debug-CallGraph.c -fblocks changes in each run. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170829 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CallGraph.cpp')
-rw-r--r--lib/Analysis/CallGraph.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Analysis/CallGraph.cpp b/lib/Analysis/CallGraph.cpp
index 853e0f9df7..424e5c795e 100644
--- a/lib/Analysis/CallGraph.cpp
+++ b/lib/Analysis/CallGraph.cpp
@@ -141,8 +141,14 @@ bool CallGraph::includeInGraph(const Decl *D) {
void CallGraph::addNodeForDecl(Decl* D, bool IsGlobal) {
assert(D);
+ // Do nothing if the node already exists.
+ if (FunctionMap.find(D) != FunctionMap.end())
+ return;
+
// Allocate a new node, mark it as root, and process it's calls.
CallGraphNode *Node = getOrInsertNode(D);
+ if (IsGlobal)
+ Root->addCallee(Node, this);
// Process all the calls by this function as well.
CGBuilder builder(this, Node);
@@ -162,9 +168,9 @@ CallGraphNode *CallGraph::getOrInsertNode(Decl *F) {
return Node;
Node = new CallGraphNode(F);
- // Make Root node a parent of all functions to make sure all are reachable.
+ // If not root, add to the parentless list.
if (F != 0)
- Root->addCallee(Node, this);
+ ParentlessNodes.insert(Node);
return Node;
}