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