summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2014-12-17 00:34:07 +0000
committerAnna Zaks <ganna@apple.com>2014-12-17 00:34:07 +0000
commit87d404d4580be4005af4b6be6221e8e8b3814ac0 (patch)
tree512a00aaf6548bf3fd25a919580fe08e054779f6 /clang/lib/Analysis
parent04b69f89aaf547d973353e49b2ada5bcd7a58972 (diff)
downloadbcm5719-llvm-87d404d4580be4005af4b6be6221e8e8b3814ac0.tar.gz
bcm5719-llvm-87d404d4580be4005af4b6be6221e8e8b3814ac0.zip
[CallGraph] Make sure the edges are not missed due to re-declarations
A patch by Daniel DeFreez! We were previously dropping edges on re-declarations. Store the canonical declarations in the graph to ensure that different references to the same function end up reflected with the same call graph node. (Note, this might lead to performance fluctuation because call graph is used to determine the function analysis order.) llvm-svn: 224398
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r--clang/lib/Analysis/CallGraph.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/clang/lib/Analysis/CallGraph.cpp b/clang/lib/Analysis/CallGraph.cpp
index f41a96d30ea..91a8492eaa5 100644
--- a/clang/lib/Analysis/CallGraph.cpp
+++ b/clang/lib/Analysis/CallGraph.cpp
@@ -110,14 +110,13 @@ CallGraph::~CallGraph() {
bool CallGraph::includeInGraph(const Decl *D) {
assert(D);
- if (!D->getBody())
+ if (!D->hasBody())
return false;
if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
// We skip function template definitions, as their semantics is
// only determined when they are instantiated.
- if (!FD->isThisDeclarationADefinition() ||
- FD->isDependentContext())
+ if (FD->isDependentContext())
return false;
IdentifierInfo *II = FD->getIdentifier();
@@ -125,11 +124,6 @@ bool CallGraph::includeInGraph(const Decl *D) {
return false;
}
- if (const ObjCMethodDecl *ID = dyn_cast<ObjCMethodDecl>(D)) {
- if (!ID->isThisDeclarationADefinition())
- return false;
- }
-
return true;
}
@@ -152,6 +146,9 @@ CallGraphNode *CallGraph::getNode(const Decl *F) const {
}
CallGraphNode *CallGraph::getOrInsertNode(Decl *F) {
+ if (F && !isa<ObjCMethodDecl>(F))
+ F = F->getCanonicalDecl();
+
CallGraphNode *&Node = FunctionMap[F];
if (Node)
return Node;
OpenPOWER on IntegriCloud