aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/debug-CallGraph.c
diff options
context:
space:
mode:
authorAnna Zaks <ganna@apple.com>2012-03-08 00:42:23 +0000
committerAnna Zaks <ganna@apple.com>2012-03-08 00:42:23 +0000
commit196b8cfe9cfcc452eb2f83aa4ad330c2324f8c7d (patch)
treeea3a4db00450824ae99c91aabe9dddb2aad8b84d /test/Analysis/debug-CallGraph.c
parenta34194f035096dd8dce10574e3a186da968aa211 (diff)
Add a basic CallGraph to Analysis.
The final graph contains a single root node, which is a parent of all externally available functions(and 'main'). As well as a list of Parentless/Unreachable functions, which are either truly unreachable or are unreachable due to our analyses imprecision. The analyzer checkers debug.DumpCallGraph or debug.ViewGraph can be used to look at the produced graph. Currently, the graph is not very precise, for example, it entirely skips edges resulted from ObjC method calls. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152272 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis/debug-CallGraph.c')
-rw-r--r--test/Analysis/debug-CallGraph.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/Analysis/debug-CallGraph.c b/test/Analysis/debug-CallGraph.c
new file mode 100644
index 0000000000..b7c7c8a844
--- /dev/null
+++ b/test/Analysis/debug-CallGraph.c
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCallGraph %s 2>&1 | FileCheck %s
+
+static void mmm(int y) {
+ if (y != 0)
+ y++;
+ y = y/0;
+}
+
+static int foo(int x, int y) {
+ mmm(y);
+ if (x != 0)
+ x++;
+ return 5/x;
+}
+
+void aaa() {
+ foo(1,2);
+}
+
+// CHECK:--- Call graph Dump ---
+// CHECK: Function: < root > calls: aaa