diff --git a/clang/test/Analysis/initializers-cfg-output.cpp b/clang/test/Analysis/initializers-cfg-output.cpp index 8d1039ddf34e..a69e78faeda0 100644 --- a/clang/test/Analysis/initializers-cfg-output.cpp +++ b/clang/test/Analysis/initializers-cfg-output.cpp @@ -12,22 +12,84 @@ class A { public: + // CHECK: A() + // CHECK: [B1 (ENTRY)] + // CHECK-NEXT: Succs (1): B0 + // CHECK: [B0 (EXIT)] + // CHECK-NEXT: Preds (1): B1 A() {} + + // CHECK: A(int i) + // CHECK: [B1 (ENTRY)] + // CHECK-NEXT: Succs (1): B0 + // CHECK: [B0 (EXIT)] + // CHECK-NEXT: Preds (1): B1 A(int i) {} }; class B : public virtual A { public: + // CHECK: B() + // CHECK: [B2 (ENTRY)] + // CHECK-NEXT: Succs (1): B1 + // CHECK: [B1] + // WARNINGS-NEXT: 1: (CXXConstructExpr, class A) + // ANALYZER-NEXT: 1: (CXXConstructExpr, A() (Base initializer), class A) + // CHECK-NEXT: 2: A([B1.1]) (Base initializer) + // CHECK-NEXT: Preds (1): B2 + // CHECK-NEXT: Succs (1): B0 + // CHECK: [B0 (EXIT)] + // CHECK-NEXT: Preds (1): B1 B() {} + + // CHECK: B(int i) + // CHECK: [B2 (ENTRY)] + // CHECK-NEXT: Succs (1): B1 + // CHECK: [B1] + // CHECK-NEXT: 1: i + // CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, LValueToRValue, int) + // WARNINGS-NEXT: 3: [B1.2] (CXXConstructExpr, class A) + // ANALYZER-NEXT: 3: [B1.2] (CXXConstructExpr, A([B1.2]) (Base initializer), class A) + // CHECK-NEXT: 4: A([B1.3]) (Base initializer) + // CHECK-NEXT: Preds (1): B2 + // CHECK-NEXT: Succs (1): B0 + // CHECK: [B0 (EXIT)] + // CHECK-NEXT: Preds (1): B1 B(int i) : A(i) {} }; class C : public virtual A { public: + // CHECK: C() + // CHECK: [B2 (ENTRY)] + // CHECK-NEXT: Succs (1): B1 + // CHECK: [B1] + // WARNINGS-NEXT: 1: (CXXConstructExpr, class A) + // ANALYZER-NEXT: 1: (CXXConstructExpr, A() (Base initializer), class A) + // CHECK-NEXT: 2: A([B1.1]) (Base initializer) + // CHECK-NEXT: Preds (1): B2 + // CHECK-NEXT: Succs (1): B0 + // CHECK: [B0 (EXIT)] + // CHECK-NEXT: Preds (1): B1 C() {} + + // CHECK: C(int i) + // CHECK: [B2 (ENTRY)] + // CHECK-NEXT: Succs (1): B1 + // CHECK: [B1] + // CHECK-NEXT: 1: i + // CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, LValueToRValue, int) + // WARNINGS-NEXT: 3: [B1.2] (CXXConstructExpr, class A) + // ANALYZER-NEXT: 3: [B1.2] (CXXConstructExpr, A([B1.2]) (Base initializer), class A) + // CHECK-NEXT: 4: A([B1.3]) (Base initializer) + // CHECK-NEXT: Preds (1): B2 + // CHECK-NEXT: Succs (1): B0 + // CHECK: [B0 (EXIT)] + // CHECK-NEXT: Preds (1): B1 C(int i) : A(i) {} }; + class TestOrder : public C, public B, public A { int i; int& r; @@ -35,6 +97,34 @@ public: TestOrder(); }; +// CHECK: TestOrder::TestOrder() +// CHECK: [B2 (ENTRY)] +// CHECK-NEXT: Succs (1): B1 +// CHECK: [B1] +// WARNINGS-NEXT: 1: (CXXConstructExpr, class A) +// ANALYZER-NEXT: 1: (CXXConstructExpr, A() (Base initializer), class A) +// CHECK-NEXT: 2: A([B1.1]) (Base initializer) +// WARNINGS-NEXT: 3: (CXXConstructExpr, class C) +// ANALYZER-NEXT: 3: (CXXConstructExpr, C() (Base initializer), class C) +// CHECK-NEXT: 4: C([B1.3]) (Base initializer) +// WARNINGS-NEXT: 5: (CXXConstructExpr, class B) +// ANALYZER-NEXT: 5: (CXXConstructExpr, B() (Base initializer), class B) +// CHECK-NEXT: 6: B([B1.5]) (Base initializer) +// WARNINGS-NEXT: 7: (CXXConstructExpr, class A) +// ANALYZER-NEXT: 7: (CXXConstructExpr, A() (Base initializer), class A) +// CHECK-NEXT: 8: A([B1.7]) (Base initializer) +// CHECK-NEXT: 9: /*implicit*/(int)0 +// CHECK-NEXT: 10: i([B1.9]) (Member initializer) +// CHECK-NEXT: 11: this +// CHECK-NEXT: 12: [B1.11]->i +// CHECK-NEXT: 13: r([B1.12]) (Member initializer) +// WARNINGS-NEXT: 14: (CXXConstructExpr, class A) +// ANALYZER-NEXT: 14: (CXXConstructExpr, [B1.15], class A) +// CHECK-NEXT: 15: A a; +// CHECK-NEXT: Preds (1): B2 +// CHECK-NEXT: Succs (1): B0 +// CHECK: [B0 (EXIT)] +// CHECK-NEXT: Preds (1): B1 TestOrder::TestOrder() : r(i), B(), i(), C() { A a; @@ -46,6 +136,37 @@ public: TestControlFlow(bool b); }; +// CHECK: TestControlFlow::TestControlFlow(bool b) +// CHECK: [B5 (ENTRY)] +// CHECK-NEXT: Succs (1): B4 +// CHECK: [B1] +// CHECK-NEXT: 1: [B4.4] ? [B2.1] : [B3.1] +// CHECK-NEXT: 2: y([B1.1]) (Member initializer) +// CHECK-NEXT: 3: this +// CHECK-NEXT: 4: [B1.3]->y +// CHECK-NEXT: 5: [B1.4] (ImplicitCastExpr, LValueToRValue, int) +// CHECK-NEXT: 6: z([B1.5]) (Member initializer) +// CHECK-NEXT: 7: int v; +// CHECK-NEXT: Preds (2): B2 B3 +// CHECK-NEXT: Succs (1): B0 +// CHECK: [B2] +// CHECK-NEXT: 1: 0 +// CHECK-NEXT: Preds (1): B4 +// CHECK-NEXT: Succs (1): B1 +// CHECK: [B3] +// CHECK-NEXT: 1: 1 +// CHECK-NEXT: Preds (1): B4 +// CHECK-NEXT: Succs (1): B1 +// CHECK: [B4] +// CHECK-NEXT: 1: 0 +// CHECK-NEXT: 2: x([B4.1]) (Member initializer) +// CHECK-NEXT: 3: b +// CHECK-NEXT: 4: [B4.3] (ImplicitCastExpr, LValueToRValue, _Bool) +// CHECK-NEXT: T: [B4.4] ? ... : ... +// CHECK-NEXT: Preds (1): B5 +// CHECK-NEXT: Succs (2): B2 B3 +// CHECK: [B0 (EXIT)] +// CHECK-NEXT: Preds (1): B1 TestControlFlow::TestControlFlow(bool b) : y(b ? 0 : 1) , x(0) @@ -55,77 +176,36 @@ TestControlFlow::TestControlFlow(bool b) class TestDelegating { int x, z; - public: +public: + + // CHECK: TestDelegating() + // CHECK: [B2 (ENTRY)] + // CHECK-NEXT: Succs (1): B1 + // CHECK: [B1] + // CHECK-NEXT: 1: 2 + // CHECK-NEXT: 2: 3 + // WARNINGS-NEXT: 3: [B1.1], [B1.2] (CXXConstructExpr, class TestDelegating) + // ANALYZER-NEXT: 3: [B1.1], [B1.2] (CXXConstructExpr, TestDelegating([B1.1], [B1.2]) (Delegating initializer), class TestDelegating) + // CHECK-NEXT: 4: TestDelegating([B1.3]) (Delegating initializer) + // CHECK-NEXT: Preds (1): B2 + // CHECK-NEXT: Succs (1): B0 + // CHECK: [B0 (EXIT)] + // CHECK-NEXT: Preds (1): B1 TestDelegating() : TestDelegating(2, 3) {} + + // CHECK: TestDelegating(int x, int z) + // CHECK: [B2 (ENTRY)] + // CHECK-NEXT: Succs (1): B1 + // CHECK: [B1] + // CHECK-NEXT: 1: x + // CHECK-NEXT: 2: [B1.1] (ImplicitCastExpr, LValueToRValue, int) + // CHECK-NEXT: 3: x([B1.2]) (Member initializer) + // CHECK-NEXT: 4: z + // CHECK-NEXT: 5: [B1.4] (ImplicitCastExpr, LValueToRValue, int) + // CHECK-NEXT: 6: z([B1.5]) (Member initializer) + // CHECK-NEXT: Preds (1): B2 + // CHECK-NEXT: Succs (1): B0 + // CHECK: [B0 (EXIT)] + // CHECK-NEXT: Preds (1): B1 TestDelegating(int x, int z) : x(x), z(z) {} }; - -// CHECK: [B2 (ENTRY)] -// CHECK: Succs (1): B1 -// CHECK: [B1] -// WARNINGS: 1: (CXXConstructExpr, class A) -// ANALYZER: 1: (CXXConstructExpr, A() (Base initializer), class A) -// CHECK: 2: A([B1.1]) (Base initializer) -// WARNINGS: 3: (CXXConstructExpr, class C) -// ANALYZER: 3: (CXXConstructExpr, C() (Base initializer), class C) -// CHECK: 4: C([B1.3]) (Base initializer) -// WARNINGS: 5: (CXXConstructExpr, class B) -// ANALYZER: 5: (CXXConstructExpr, B() (Base initializer), class B) -// CHECK: 6: B([B1.5]) (Base initializer) -// WARNINGS: 7: (CXXConstructExpr, class A) -// ANALYZER: 7: (CXXConstructExpr, A() (Base initializer), class A) -// CHECK: 8: A([B1.7]) (Base initializer) -// CHECK: 9: /*implicit*/(int)0 -// CHECK: 10: i([B1.9]) (Member initializer) -// CHECK: 11: this -// CHECK: 12: [B1.11]->i -// CHECK: 13: r([B1.12]) (Member initializer) -// WARNINGS: 14: (CXXConstructExpr, class A) -// ANALYZER: 14: (CXXConstructExpr, [B1.15], class A) -// CHECK: 15: A a; -// CHECK: Preds (1): B2 -// CHECK: Succs (1): B0 -// CHECK: [B0 (EXIT)] -// CHECK: Preds (1): B1 -// CHECK: [B5 (ENTRY)] -// CHECK: Succs (1): B4 -// CHECK: [B1] -// CHECK: 1: [B4.4] ? [B2.1] : [B3.1] -// CHECK: 2: y([B1.1]) (Member initializer) -// CHECK: 3: this -// CHECK: 4: [B1.3]->y -// CHECK: 5: [B1.4] (ImplicitCastExpr, LValueToRValue, int) -// CHECK: 6: z([B1.5]) (Member initializer) -// CHECK: 7: int v; -// CHECK: Preds (2): B2 B3 -// CHECK: Succs (1): B0 -// CHECK: [B2] -// CHECK: 1: 0 -// CHECK: Preds (1): B4 -// CHECK: Succs (1): B1 -// CHECK: [B3] -// CHECK: 1: 1 -// CHECK: Preds (1): B4 -// CHECK: Succs (1): B1 -// CHECK: [B4] -// CHECK: 1: 0 -// CHECK: 2: x([B4.1]) (Member initializer) -// CHECK: 3: b -// CHECK: 4: [B4.3] (ImplicitCastExpr, LValueToRValue, _Bool) -// CHECK: T: [B4.4] ? ... : ... -// CHECK: Preds (1): B5 -// CHECK: Succs (2): B2 B3 -// CHECK: [B0 (EXIT)] -// CHECK: Preds (1): B1 -// CHECK: [B2 (ENTRY)] -// CHECK: Succs (1): B1 -// CHECK: [B1] -// CHECK: 1: 2 -// CHECK: 2: 3 -// WARNINGS: 3: [B1.1], [B1.2] (CXXConstructExpr, class TestDelegating) -// ANALYZER: 3: [B1.1], [B1.2] (CXXConstructExpr, TestDelegating([B1.1], [B1.2]) (Delegating initializer), class TestDelegating) -// CHECK: 4: TestDelegating([B1.3]) (Delegating initializer) -// CHECK: Preds (1): B2 -// CHECK: Succs (1): B0 -// CHECK: [B0 (EXIT)] -// CHECK: Preds (1): B1