summaryrefslogtreecommitdiff
path: root/test/Analysis/debug-CallGraph.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/debug-CallGraph.c')
-rw-r--r--test/Analysis/debug-CallGraph.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/test/Analysis/debug-CallGraph.c b/test/Analysis/debug-CallGraph.c
index 64259e2069a49..9f3865b35a4ea 100644
--- a/test/Analysis/debug-CallGraph.c
+++ b/test/Analysis/debug-CallGraph.c
@@ -1,4 +1,16 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCallGraph %s -fblocks 2>&1 | FileCheck %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCallGraph %s -fblocks 2>&1 | FileCheck %s
+
+int get5() {
+ return 5;
+}
+
+int add(int val1, int val2) {
+ return val1 + val2;
+}
+
+int test_add() {
+ return add(10, get5());
+}
static void mmm(int y) {
if (y != 0)
@@ -31,8 +43,18 @@ void eee();
void eee() {}
void fff() { eee(); }
+// This test case tests that forward declaration for the top-level function
+// does not affect call graph construction.
+void do_nothing() {}
+void test_single_call();
+void test_single_call() {
+ do_nothing();
+}
+
// CHECK:--- Call graph Dump ---
-// CHECK-NEXT: {{Function: < root > calls: mmm foo aaa < > bbb ccc ddd eee fff $}}
+// CHECK-NEXT: {{Function: < root > calls: get5 add test_add mmm foo aaa < > bbb ddd ccc eee fff do_nothing test_single_call $}}
+// CHECK-NEXT: {{Function: test_single_call calls: do_nothing $}}
+// CHECK-NEXT: {{Function: do_nothing calls: $}}
// CHECK-NEXT: {{Function: fff calls: eee $}}
// CHECK-NEXT: {{Function: eee calls: $}}
// CHECK-NEXT: {{Function: ddd calls: ccc $}}
@@ -42,3 +64,6 @@ void fff() { eee(); }
// CHECK-NEXT: {{Function: aaa calls: foo $}}
// CHECK-NEXT: {{Function: foo calls: mmm $}}
// CHECK-NEXT: {{Function: mmm calls: $}}
+// CHECK-NEXT: {{Function: test_add calls: add get5 $}}
+// CHECK-NEXT: {{Function: add calls: $}}
+// CHECK-NEXT: {{Function: get5 calls: $}}