xref: /minix3/external/bsd/llvm/dist/clang/test/Analysis/debug-CallGraph.c (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCallGraph %s -fblocks 2>&1 | FileCheck %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc static void mmm(int y) {
4*f4a2713aSLionel Sambuc   if (y != 0)
5*f4a2713aSLionel Sambuc       y++;
6*f4a2713aSLionel Sambuc   y = y/y;
7*f4a2713aSLionel Sambuc }
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc static int foo(int x, int y) {
10*f4a2713aSLionel Sambuc     mmm(y);
11*f4a2713aSLionel Sambuc     if (x != 0)
12*f4a2713aSLionel Sambuc       x++;
13*f4a2713aSLionel Sambuc     return 5/x;
14*f4a2713aSLionel Sambuc }
15*f4a2713aSLionel Sambuc 
16*f4a2713aSLionel Sambuc void aaa() {
17*f4a2713aSLionel Sambuc   foo(1,2);
18*f4a2713aSLionel Sambuc }
19*f4a2713aSLionel Sambuc 
20*f4a2713aSLionel Sambuc void bbb(int y) {
21*f4a2713aSLionel Sambuc   int x = (y > 2);
22*f4a2713aSLionel Sambuc   ^ {
23*f4a2713aSLionel Sambuc       foo(x, y);
24*f4a2713aSLionel Sambuc   }();
25*f4a2713aSLionel Sambuc }
26*f4a2713aSLionel Sambuc 
27*f4a2713aSLionel Sambuc // CHECK:--- Call graph Dump ---
28*f4a2713aSLionel Sambuc // CHECK: Function: < root > calls: mmm foo aaa < > bbb
29*f4a2713aSLionel Sambuc // CHECK: Function: bbb calls: < >
30*f4a2713aSLionel Sambuc // CHECK: Function: < > calls: foo
31*f4a2713aSLionel Sambuc // CHECK: Function: aaa calls: foo
32*f4a2713aSLionel Sambuc // CHECK: Function: foo calls: mmm
33*f4a2713aSLionel Sambuc // CHECK: Function: mmm calls:
34