xref: /minix3/external/bsd/llvm/dist/clang/test/Analysis/initializers-cfg-output.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++11 -analyze -analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc class A {
4*f4a2713aSLionel Sambuc public:
A()5*f4a2713aSLionel Sambuc   A() {}
A(int i)6*f4a2713aSLionel Sambuc   A(int i) {}
7*f4a2713aSLionel Sambuc };
8*f4a2713aSLionel Sambuc 
9*f4a2713aSLionel Sambuc class B : public virtual A {
10*f4a2713aSLionel Sambuc public:
B()11*f4a2713aSLionel Sambuc   B() {}
B(int i)12*f4a2713aSLionel Sambuc   B(int i) : A(i) {}
13*f4a2713aSLionel Sambuc };
14*f4a2713aSLionel Sambuc 
15*f4a2713aSLionel Sambuc class C : public virtual A {
16*f4a2713aSLionel Sambuc public:
C()17*f4a2713aSLionel Sambuc   C() {}
C(int i)18*f4a2713aSLionel Sambuc   C(int i) : A(i) {}
19*f4a2713aSLionel Sambuc };
20*f4a2713aSLionel Sambuc 
21*f4a2713aSLionel Sambuc class TestOrder : public C, public B, public A {
22*f4a2713aSLionel Sambuc   int i;
23*f4a2713aSLionel Sambuc   int& r;
24*f4a2713aSLionel Sambuc public:
25*f4a2713aSLionel Sambuc   TestOrder();
26*f4a2713aSLionel Sambuc };
27*f4a2713aSLionel Sambuc 
TestOrder()28*f4a2713aSLionel Sambuc TestOrder::TestOrder()
29*f4a2713aSLionel Sambuc   : r(i), B(), i(), C() {
30*f4a2713aSLionel Sambuc   A a;
31*f4a2713aSLionel Sambuc }
32*f4a2713aSLionel Sambuc 
33*f4a2713aSLionel Sambuc class TestControlFlow {
34*f4a2713aSLionel Sambuc   int x, y, z;
35*f4a2713aSLionel Sambuc public:
36*f4a2713aSLionel Sambuc   TestControlFlow(bool b);
37*f4a2713aSLionel Sambuc };
38*f4a2713aSLionel Sambuc 
TestControlFlow(bool b)39*f4a2713aSLionel Sambuc TestControlFlow::TestControlFlow(bool b)
40*f4a2713aSLionel Sambuc   : y(b ? 0 : 1)
41*f4a2713aSLionel Sambuc   , x(0)
42*f4a2713aSLionel Sambuc   , z(y) {
43*f4a2713aSLionel Sambuc   int v;
44*f4a2713aSLionel Sambuc }
45*f4a2713aSLionel Sambuc 
46*f4a2713aSLionel Sambuc class TestDelegating {
47*f4a2713aSLionel Sambuc   int x, z;
48*f4a2713aSLionel Sambuc  public:
TestDelegating()49*f4a2713aSLionel Sambuc   TestDelegating() : TestDelegating(2, 3) {}
TestDelegating(int x,int z)50*f4a2713aSLionel Sambuc   TestDelegating(int x, int z) : x(x), z(z) {}
51*f4a2713aSLionel Sambuc };
52*f4a2713aSLionel Sambuc 
53*f4a2713aSLionel Sambuc // CHECK:  [B2 (ENTRY)]
54*f4a2713aSLionel Sambuc // CHECK:    Succs (1): B1
55*f4a2713aSLionel Sambuc // CHECK:  [B1]
56*f4a2713aSLionel Sambuc // CHECK:    1:  (CXXConstructExpr, class A)
57*f4a2713aSLionel Sambuc // CHECK:    2: A([B1.1]) (Base initializer)
58*f4a2713aSLionel Sambuc // CHECK:    3:  (CXXConstructExpr, class C)
59*f4a2713aSLionel Sambuc // CHECK:    4: C([B1.3]) (Base initializer)
60*f4a2713aSLionel Sambuc // CHECK:    5:  (CXXConstructExpr, class B)
61*f4a2713aSLionel Sambuc // CHECK:    6: B([B1.5]) (Base initializer)
62*f4a2713aSLionel Sambuc // CHECK:    7:  (CXXConstructExpr, class A)
63*f4a2713aSLionel Sambuc // CHECK:    8: A([B1.7]) (Base initializer)
64*f4a2713aSLionel Sambuc // CHECK:    9: /*implicit*/int()
65*f4a2713aSLionel Sambuc // CHECK:   10: i([B1.9]) (Member initializer)
66*f4a2713aSLionel Sambuc // CHECK:   11: this
67*f4a2713aSLionel Sambuc // CHECK:   12: [B1.11]->i
68*f4a2713aSLionel Sambuc // CHECK:   13: r([B1.12]) (Member initializer)
69*f4a2713aSLionel Sambuc // CHECK:   14:  (CXXConstructExpr, class A)
70*f4a2713aSLionel Sambuc // CHECK:   15: A a;
71*f4a2713aSLionel Sambuc // CHECK:    Preds (1): B2
72*f4a2713aSLionel Sambuc // CHECK:    Succs (1): B0
73*f4a2713aSLionel Sambuc // CHECK:  [B0 (EXIT)]
74*f4a2713aSLionel Sambuc // CHECK:    Preds (1): B1
75*f4a2713aSLionel Sambuc // CHECK:  [B5 (ENTRY)]
76*f4a2713aSLionel Sambuc // CHECK:    Succs (1): B4
77*f4a2713aSLionel Sambuc // CHECK:  [B1]
78*f4a2713aSLionel Sambuc // CHECK:    1: [B4.4] ? [B2.1] : [B3.1]
79*f4a2713aSLionel Sambuc // CHECK:    2: y([B1.1]) (Member initializer)
80*f4a2713aSLionel Sambuc // CHECK:    3: this
81*f4a2713aSLionel Sambuc // CHECK:    4: [B1.3]->y
82*f4a2713aSLionel Sambuc // CHECK:    5: [B1.4] (ImplicitCastExpr, LValueToRValue, int)
83*f4a2713aSLionel Sambuc // CHECK:    6: z([B1.5]) (Member initializer)
84*f4a2713aSLionel Sambuc // CHECK:    7: int v;
85*f4a2713aSLionel Sambuc // CHECK:    Preds (2): B2 B3
86*f4a2713aSLionel Sambuc // CHECK:    Succs (1): B0
87*f4a2713aSLionel Sambuc // CHECK:  [B2]
88*f4a2713aSLionel Sambuc // CHECK:    1: 0
89*f4a2713aSLionel Sambuc // CHECK:    Preds (1): B4
90*f4a2713aSLionel Sambuc // CHECK:    Succs (1): B1
91*f4a2713aSLionel Sambuc // CHECK:  [B3]
92*f4a2713aSLionel Sambuc // CHECK:    1: 1
93*f4a2713aSLionel Sambuc // CHECK:    Preds (1): B4
94*f4a2713aSLionel Sambuc // CHECK:    Succs (1): B1
95*f4a2713aSLionel Sambuc // CHECK:  [B4]
96*f4a2713aSLionel Sambuc // CHECK:    1: 0
97*f4a2713aSLionel Sambuc // CHECK:    2: x([B4.1]) (Member initializer)
98*f4a2713aSLionel Sambuc // CHECK:    3: b
99*f4a2713aSLionel Sambuc // CHECK:    4: [B4.3] (ImplicitCastExpr, LValueToRValue, _Bool)
100*f4a2713aSLionel Sambuc // CHECK:    T: [B4.4] ? ... : ...
101*f4a2713aSLionel Sambuc // CHECK:    Preds (1): B5
102*f4a2713aSLionel Sambuc // CHECK:    Succs (2): B2 B3
103*f4a2713aSLionel Sambuc // CHECK:  [B0 (EXIT)]
104*f4a2713aSLionel Sambuc // CHECK:    Preds (1): B1
105*f4a2713aSLionel Sambuc // CHECK:  [B2 (ENTRY)]
106*f4a2713aSLionel Sambuc // CHECK:    Succs (1): B1
107*f4a2713aSLionel Sambuc // CHECK:  [B1]
108*f4a2713aSLionel Sambuc // CHECK:    1: 2
109*f4a2713aSLionel Sambuc // CHECK:    2: 3
110*f4a2713aSLionel Sambuc // CHECK:    3: [B1.1], [B1.2] (CXXConstructExpr, class TestDelegating)
111*f4a2713aSLionel Sambuc // CHECK:    4: TestDelegating([B1.3]) (Delegating initializer)
112*f4a2713aSLionel Sambuc // CHECK:    Preds (1): B2
113*f4a2713aSLionel Sambuc // CHECK:    Succs (1): B0
114*f4a2713aSLionel Sambuc // CHECK:  [B0 (EXIT)]
115*f4a2713aSLionel Sambuc // CHECK:    Preds (1): B1
116