aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Analysis/CallGraph.h
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-12-21 01:19:15 +0000
committerAnna Zaks <ganna@apple.com>2012-12-21 01:19:15 +0000
commit4f858dfd42c89b67200dac0afc228a0baa323691 (patch)
treead4d008b16fb3bc5ff7f057897561388d715d154 /include/clang/Analysis/CallGraph.h
parentcd0fd18909e3b89ed6f2cc1118809003db64e67a (diff)
[analyzer] Add blocks and ObjC messages to the call graph.
This paves the road for constructing a better function dependency graph. If we analyze a function before the functions it calls and inlines, there is more opportunity for optimization. Note, we add call edges to the called methods that correspond to function definitions (declarations with bodies). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170825 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Analysis/CallGraph.h')
-rw-r--r--include/clang/Analysis/CallGraph.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/include/clang/Analysis/CallGraph.h b/include/clang/Analysis/CallGraph.h
index 509de7bc21..d554f3a7af 100644
--- a/include/clang/Analysis/CallGraph.h
+++ b/include/clang/Analysis/CallGraph.h
@@ -102,23 +102,30 @@ public:
void dump() const;
void viewGraph() const;
+ void addNodesForBlocks(DeclContext *D);
+
/// Part of recursive declaration visitation. We recursively visit all the
- /// Declarations to collect the root functions.
+ /// declarations to collect the root functions.
bool VisitFunctionDecl(FunctionDecl *FD) {
// We skip function template definitions, as their semantics is
// only determined when they are instantiated.
- if (includeInGraph(FD))
+ if (includeInGraph(FD)) {
+ // Add all blocks declared inside this function to the graph.
+ addNodesForBlocks(FD);
// If this function has external linkage, anything could call it.
// Note, we are not precise here. For example, the function could have
// its address taken.
addNodeForDecl(FD, FD->isGlobal());
+ }
return true;
}
/// Part of recursive declaration visitation.
bool VisitObjCMethodDecl(ObjCMethodDecl *MD) {
- if (includeInGraph(MD))
+ if (includeInGraph(MD)) {
+ addNodesForBlocks(MD);
addNodeForDecl(MD, true);
+ }
return true;
}
@@ -144,8 +151,6 @@ private:
Decl *FD;
/// \brief The list of functions called from this node.
- // Small vector might be more efficient since we are only tracking functions
- // whose definition is in the current TU.
llvm::SmallVector<CallRecord, 5> CalledFunctions;
public:
@@ -170,8 +175,6 @@ public:
Decl *getDecl() const { return FD; }
- StringRef getName() const;
-
void print(raw_ostream &os) const;
void dump() const;
};