Summary: public Don't skip constructor init list anymore. Reviewed By: jberdine Differential Revision: D2895364 fb-gh-sync-id: 4bd8139master
parent
1d6aea0fb9
commit
359ad9dd4b
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
struct A {
|
||||
int f;
|
||||
A(int f) : f(f) {
|
||||
}
|
||||
};
|
||||
|
||||
struct B : public A {
|
||||
struct T {
|
||||
int v;
|
||||
T(int v) : v(v) {}
|
||||
};
|
||||
int f2;
|
||||
T t;
|
||||
B(int a) :
|
||||
A(a),
|
||||
f2(a),
|
||||
t(a) {
|
||||
}
|
||||
|
||||
B(int a, int b) :
|
||||
B(a+b) {
|
||||
f2 = b;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
int f2_div0() {
|
||||
B b(0);
|
||||
return 1/b.f2;
|
||||
}
|
||||
|
||||
int f_div0() {
|
||||
B b(0);
|
||||
return 1/b.f;
|
||||
}
|
||||
|
||||
int t_div0() {
|
||||
B b(0);
|
||||
return 1/b.t.v;
|
||||
}
|
||||
|
||||
int delegate_constr_f_div0() {
|
||||
B b(-1, 1);
|
||||
int v = 1/b.f2;
|
||||
return 1/b.f;
|
||||
}
|
||||
|
||||
int delegate_constr_f2_div0() {
|
||||
B b(-1, 0);
|
||||
int v = 1/b.f;
|
||||
return 1/b.f2;
|
||||
}
|
||||
|
||||
int f_f2_div1() {
|
||||
B b(1);
|
||||
int v = 1/b.f;
|
||||
int v2 = 1/b.f2;
|
||||
int v3 = 1/b.t.v;
|
||||
return v + v2;
|
||||
}
|
@ -0,0 +1,168 @@
|
||||
digraph iCFG {
|
||||
44 [label="44: DeclStmt \n _fun_B_B(&b:class B *,1:int ) [line 64]\n " shape="box"]
|
||||
|
||||
|
||||
44 -> 43 ;
|
||||
43 [label="43: DeclStmt \n n$4=*&b.f:int [line 65]\n *&v:int =(1 / n$4) [line 65]\n REMOVE_TEMPS(n$4); [line 65]\n " shape="box"]
|
||||
|
||||
|
||||
43 -> 42 ;
|
||||
42 [label="42: DeclStmt \n n$3=*&b.f2:int [line 66]\n *&v2:int =(1 / n$3) [line 66]\n REMOVE_TEMPS(n$3); [line 66]\n " shape="box"]
|
||||
|
||||
|
||||
42 -> 41 ;
|
||||
41 [label="41: DeclStmt \n n$2=*&b.t.v:int [line 67]\n *&v3:int =(1 / n$2) [line 67]\n REMOVE_TEMPS(n$2); [line 67]\n NULLIFY(&v3,false); [line 67]\n " shape="box"]
|
||||
|
||||
|
||||
41 -> 40 ;
|
||||
40 [label="40: Return Stmt \n n$0=*&v:int [line 68]\n n$1=*&v2:int [line 68]\n *&return:int =(n$0 + n$1) [line 68]\n REMOVE_TEMPS(n$0,n$1); [line 68]\n NULLIFY(&v,false); [line 68]\n NULLIFY(&v2,false); [line 68]\n NULLIFY(&b,false); [line 68]\n APPLY_ABSTRACTION; [line 68]\n " shape="box"]
|
||||
|
||||
|
||||
40 -> 39 ;
|
||||
39 [label="39: Exit f_f2_div1 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
38 [label="38: Start f_f2_div1\nFormals: \nLocals: v3:int v2:int v:int b:class B \n DECLARE_LOCALS(&return,&v3,&v2,&v,&b); [line 63]\n NULLIFY(&v,false); [line 63]\n NULLIFY(&v2,false); [line 63]\n NULLIFY(&v3,false); [line 63]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
38 -> 44 ;
|
||||
37 [label="37: DeclStmt \n _fun_B_B(&b:class B *,-1:int ,0:int ) [line 58]\n " shape="box"]
|
||||
|
||||
|
||||
37 -> 36 ;
|
||||
36 [label="36: DeclStmt \n n$1=*&b.f:int [line 59]\n *&v:int =(1 / n$1) [line 59]\n REMOVE_TEMPS(n$1); [line 59]\n NULLIFY(&v,false); [line 59]\n " shape="box"]
|
||||
|
||||
|
||||
36 -> 35 ;
|
||||
35 [label="35: Return Stmt \n n$0=*&b.f2:int [line 60]\n *&return:int =(1 / n$0) [line 60]\n REMOVE_TEMPS(n$0); [line 60]\n NULLIFY(&b,false); [line 60]\n APPLY_ABSTRACTION; [line 60]\n " shape="box"]
|
||||
|
||||
|
||||
35 -> 34 ;
|
||||
34 [label="34: Exit delegate_constr_f2_div0 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
33 [label="33: Start delegate_constr_f2_div0\nFormals: \nLocals: v:int b:class B \n DECLARE_LOCALS(&return,&v,&b); [line 57]\n NULLIFY(&v,false); [line 57]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
33 -> 37 ;
|
||||
32 [label="32: DeclStmt \n _fun_B_B(&b:class B *,-1:int ,1:int ) [line 52]\n " shape="box"]
|
||||
|
||||
|
||||
32 -> 31 ;
|
||||
31 [label="31: DeclStmt \n n$1=*&b.f2:int [line 53]\n *&v:int =(1 / n$1) [line 53]\n REMOVE_TEMPS(n$1); [line 53]\n NULLIFY(&v,false); [line 53]\n " shape="box"]
|
||||
|
||||
|
||||
31 -> 30 ;
|
||||
30 [label="30: Return Stmt \n n$0=*&b.f:int [line 54]\n *&return:int =(1 / n$0) [line 54]\n REMOVE_TEMPS(n$0); [line 54]\n NULLIFY(&b,false); [line 54]\n APPLY_ABSTRACTION; [line 54]\n " shape="box"]
|
||||
|
||||
|
||||
30 -> 29 ;
|
||||
29 [label="29: Exit delegate_constr_f_div0 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
28 [label="28: Start delegate_constr_f_div0\nFormals: \nLocals: v:int b:class B \n DECLARE_LOCALS(&return,&v,&b); [line 51]\n NULLIFY(&v,false); [line 51]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
28 -> 32 ;
|
||||
27 [label="27: DeclStmt \n _fun_B_B(&b:class B *,0:int ) [line 47]\n " shape="box"]
|
||||
|
||||
|
||||
27 -> 26 ;
|
||||
26 [label="26: Return Stmt \n n$0=*&b.t.v:int [line 48]\n *&return:int =(1 / n$0) [line 48]\n REMOVE_TEMPS(n$0); [line 48]\n NULLIFY(&b,false); [line 48]\n APPLY_ABSTRACTION; [line 48]\n " shape="box"]
|
||||
|
||||
|
||||
26 -> 25 ;
|
||||
25 [label="25: Exit t_div0 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
24 [label="24: Start t_div0\nFormals: \nLocals: b:class B \n DECLARE_LOCALS(&return,&b); [line 46]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
24 -> 27 ;
|
||||
23 [label="23: DeclStmt \n _fun_B_B(&b:class B *,0:int ) [line 42]\n " shape="box"]
|
||||
|
||||
|
||||
23 -> 22 ;
|
||||
22 [label="22: Return Stmt \n n$0=*&b.f:int [line 43]\n *&return:int =(1 / n$0) [line 43]\n REMOVE_TEMPS(n$0); [line 43]\n NULLIFY(&b,false); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"]
|
||||
|
||||
|
||||
22 -> 21 ;
|
||||
21 [label="21: Exit f_div0 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
20 [label="20: Start f_div0\nFormals: \nLocals: b:class B \n DECLARE_LOCALS(&return,&b); [line 41]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
20 -> 23 ;
|
||||
19 [label="19: DeclStmt \n _fun_B_B(&b:class B *,0:int ) [line 37]\n " shape="box"]
|
||||
|
||||
|
||||
19 -> 18 ;
|
||||
18 [label="18: Return Stmt \n n$0=*&b.f2:int [line 38]\n *&return:int =(1 / n$0) [line 38]\n REMOVE_TEMPS(n$0); [line 38]\n NULLIFY(&b,false); [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"]
|
||||
|
||||
|
||||
18 -> 17 ;
|
||||
17 [label="17: Exit f2_div0 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
16 [label="16: Start f2_div0\nFormals: \nLocals: b:class B \n DECLARE_LOCALS(&return,&b); [line 36]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
16 -> 19 ;
|
||||
15 [label="15: Constructor Init \n n$2=*&this:class B * [line 30]\n n$3=*&a:int [line 30]\n n$4=*&b:int [line 30]\n _fun_B_B(n$2:class B *,(n$3 + n$4):int ) [line 30]\n REMOVE_TEMPS(n$2,n$3,n$4); [line 30]\n NULLIFY(&a,false); [line 30]\n " shape="box"]
|
||||
|
||||
|
||||
15 -> 14 ;
|
||||
14 [label="14: BinaryOperatorStmt: Assign \n n$0=*&this:class B * [line 31]\n n$1=*&b:int [line 31]\n *n$0.f2:int =n$1 [line 31]\n REMOVE_TEMPS(n$0,n$1); [line 31]\n NULLIFY(&b,false); [line 31]\n NULLIFY(&this,false); [line 31]\n APPLY_ABSTRACTION; [line 31]\n " shape="box"]
|
||||
|
||||
|
||||
14 -> 13 ;
|
||||
13 [label="13: Exit B_B \n " color=yellow style=filled]
|
||||
|
||||
|
||||
12 [label="12: Start B_B\nFormals: this:class B * a:int b:int \nLocals: \n DECLARE_LOCALS(&return); [line 29]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
12 -> 15 ;
|
||||
11 [label="11: Constructor Init \n n$4=*&this:class B * [line 24]\n n$5=*&a:int [line 24]\n _fun_A_A(n$4:class B *,n$5:int ) [line 24]\n REMOVE_TEMPS(n$4,n$5); [line 24]\n " shape="box"]
|
||||
|
||||
|
||||
11 -> 10 ;
|
||||
10 [label="10: Constructor Init \n n$2=*&this:class B * [line 25]\n n$3=*&a:int [line 25]\n *n$2.f2:int =n$3 [line 25]\n REMOVE_TEMPS(n$2,n$3); [line 25]\n " shape="box"]
|
||||
|
||||
|
||||
10 -> 9 ;
|
||||
9 [label="9: Constructor Init \n n$0=*&this:class B * [line 26]\n n$1=*&a:int [line 26]\n _fun_B::T_T(n$0.t:class B::T *,n$1:int ) [line 26]\n REMOVE_TEMPS(n$0,n$1); [line 26]\n NULLIFY(&a,false); [line 26]\n NULLIFY(&this,false); [line 26]\n APPLY_ABSTRACTION; [line 26]\n " shape="box"]
|
||||
|
||||
|
||||
9 -> 8 ;
|
||||
8 [label="8: Exit B_B \n " color=yellow style=filled]
|
||||
|
||||
|
||||
7 [label="7: Start B_B\nFormals: this:class B * a:int \nLocals: \n DECLARE_LOCALS(&return); [line 23]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
7 -> 11 ;
|
||||
6 [label="6: Constructor Init \n n$0=*&this:class B::T * [line 19]\n n$1=*&v:int [line 19]\n *n$0.v:int =n$1 [line 19]\n REMOVE_TEMPS(n$0,n$1); [line 19]\n NULLIFY(&this,false); [line 19]\n NULLIFY(&v,false); [line 19]\n APPLY_ABSTRACTION; [line 19]\n " shape="box"]
|
||||
|
||||
|
||||
6 -> 5 ;
|
||||
5 [label="5: Exit B::T_T \n " color=yellow style=filled]
|
||||
|
||||
|
||||
4 [label="4: Start B::T_T\nFormals: this:class B::T * v:int \nLocals: \n DECLARE_LOCALS(&return); [line 19]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
4 -> 6 ;
|
||||
3 [label="3: Constructor Init \n n$0=*&this:class A * [line 12]\n n$1=*&f:int [line 12]\n *n$0.f:int =n$1 [line 12]\n REMOVE_TEMPS(n$0,n$1); [line 12]\n NULLIFY(&f,false); [line 12]\n NULLIFY(&this,false); [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="box"]
|
||||
|
||||
|
||||
3 -> 2 ;
|
||||
2 [label="2: Exit A_A \n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 [label="1: Start A_A\nFormals: this:class A * f:int \nLocals: \n DECLARE_LOCALS(&return); [line 12]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 -> 3 ;
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// NOTE: that test will break if we start doing copy elision
|
||||
// will have default copy/move constructors - used to test
|
||||
// whether they get translated correctly
|
||||
struct X {
|
||||
int f;
|
||||
};
|
||||
|
||||
// used to test whether backend can distinguish copy
|
||||
// and move constructor
|
||||
struct Y {
|
||||
int f;
|
||||
Y() = default;
|
||||
Y(const Y &y) = default;
|
||||
// move constructor with different behavior than copy constructor
|
||||
Y(const Y &&y) : f(y.f - 1) {}
|
||||
};
|
||||
|
||||
X getX(int f) {
|
||||
X x;
|
||||
x.f = f;
|
||||
return x; // will call move constructor
|
||||
}
|
||||
|
||||
Y getY(int f) {
|
||||
Y y;
|
||||
y.f = f;
|
||||
return y;
|
||||
}
|
||||
|
||||
int copyX_div0() {
|
||||
X x1;
|
||||
x1.f = 0;
|
||||
X x2 = x1; // will call copy constructor
|
||||
return 1 / x2.f;
|
||||
}
|
||||
|
||||
int moveX_div0() {
|
||||
return 1 / getX(0).f;
|
||||
}
|
||||
|
||||
|
||||
int copyY_div0() {
|
||||
Y y1;
|
||||
y1.f = 0;
|
||||
Y y2 = y1; // will call copy constructor
|
||||
return 1 / y2.f;
|
||||
}
|
||||
|
||||
int moveY_div0() {
|
||||
return 1 / getY(1).f;
|
||||
}
|
||||
|
||||
int moveY_moveY_copyY_div0() {
|
||||
Y y1 = getY(2); //move constructor in getY and in assignment
|
||||
Y y2 = y1;
|
||||
return 1 / y2.f;
|
||||
}
|
||||
|
||||
int copyX_moveX_div1() {
|
||||
X x1;
|
||||
x1.f = 1;
|
||||
X x2 = x1;
|
||||
int d1 = 1 / x2.f;
|
||||
int d2 = 1 / getX(1).f;
|
||||
return d1 + d2;
|
||||
}
|
||||
|
||||
int copyY_moveY_div1() {
|
||||
Y y1;
|
||||
y1.f = 1;
|
||||
Y y2 = y1;
|
||||
int d1 = 1 / y2.f;
|
||||
int d2 = 1 / getY(2).f;
|
||||
return d1 + d2;
|
||||
}
|
@ -0,0 +1,247 @@
|
||||
digraph iCFG {
|
||||
65 [label="65: DeclStmt \n _fun_Y_Y(&y1:class Y *) [line 78]\n " shape="box"]
|
||||
|
||||
|
||||
65 -> 64 ;
|
||||
64 [label="64: BinaryOperatorStmt: Assign \n *&y1.f:int =1 [line 79]\n " shape="box"]
|
||||
|
||||
|
||||
64 -> 63 ;
|
||||
63 [label="63: DeclStmt \n _fun_Y_Y(&y2:class Y *,&y1:class Y &) [line 80]\n " shape="box"]
|
||||
|
||||
|
||||
63 -> 62 ;
|
||||
62 [label="62: DeclStmt \n n$5=*&y2.f:int [line 81]\n *&d1:int =(1 / n$5) [line 81]\n REMOVE_TEMPS(n$5); [line 81]\n " shape="box"]
|
||||
|
||||
|
||||
62 -> 61 ;
|
||||
61 [label="61: DeclStmt \n _fun_getY(2:int ,&__temp_return_n$3:class Y *) [line 82]\n n$4=*&__temp_return_n$3.f:int [line 82]\n *&d2:int =(1 / n$4) [line 82]\n REMOVE_TEMPS(n$4); [line 82]\n " shape="box"]
|
||||
|
||||
|
||||
61 -> 60 ;
|
||||
60 [label="60: Return Stmt \n n$0=*&d1:int [line 83]\n n$1=*&d2:int [line 83]\n *&return:int =(n$0 + n$1) [line 83]\n REMOVE_TEMPS(n$0,n$1); [line 83]\n NULLIFY(&d1,false); [line 83]\n NULLIFY(&d2,false); [line 83]\n NULLIFY(&__temp_return_n$3,false); [line 83]\n NULLIFY(&y1,false); [line 83]\n NULLIFY(&y2,false); [line 83]\n APPLY_ABSTRACTION; [line 83]\n " shape="box"]
|
||||
|
||||
|
||||
60 -> 59 ;
|
||||
59 [label="59: Exit copyY_moveY_div1 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
58 [label="58: Start copyY_moveY_div1\nFormals: \nLocals: d2:int __temp_return_n$3:class Y d1:int y2:class Y y1:class Y \n DECLARE_LOCALS(&return,&d2,&__temp_return_n$3,&d1,&y2,&y1); [line 77]\n NULLIFY(&d1,false); [line 77]\n NULLIFY(&d2,false); [line 77]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
58 -> 65 ;
|
||||
57 [label="57: DeclStmt \n _fun_X_X(&x1:class X *) [line 69]\n " shape="box"]
|
||||
|
||||
|
||||
57 -> 56 ;
|
||||
56 [label="56: BinaryOperatorStmt: Assign \n *&x1.f:int =1 [line 70]\n " shape="box"]
|
||||
|
||||
|
||||
56 -> 55 ;
|
||||
55 [label="55: DeclStmt \n _fun_X_X(&x2:class X *,&x1:class X &) [line 71]\n " shape="box"]
|
||||
|
||||
|
||||
55 -> 54 ;
|
||||
54 [label="54: DeclStmt \n n$5=*&x2.f:int [line 72]\n *&d1:int =(1 / n$5) [line 72]\n REMOVE_TEMPS(n$5); [line 72]\n " shape="box"]
|
||||
|
||||
|
||||
54 -> 53 ;
|
||||
53 [label="53: DeclStmt \n _fun_getX(1:int ,&__temp_return_n$3:class X *) [line 73]\n n$4=*&__temp_return_n$3.f:int [line 73]\n *&d2:int =(1 / n$4) [line 73]\n REMOVE_TEMPS(n$4); [line 73]\n " shape="box"]
|
||||
|
||||
|
||||
53 -> 52 ;
|
||||
52 [label="52: Return Stmt \n n$0=*&d1:int [line 74]\n n$1=*&d2:int [line 74]\n *&return:int =(n$0 + n$1) [line 74]\n REMOVE_TEMPS(n$0,n$1); [line 74]\n NULLIFY(&d1,false); [line 74]\n NULLIFY(&d2,false); [line 74]\n NULLIFY(&__temp_return_n$3,false); [line 74]\n NULLIFY(&x1,false); [line 74]\n NULLIFY(&x2,false); [line 74]\n APPLY_ABSTRACTION; [line 74]\n " shape="box"]
|
||||
|
||||
|
||||
52 -> 51 ;
|
||||
51 [label="51: Exit copyX_moveX_div1 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
50 [label="50: Start copyX_moveX_div1\nFormals: \nLocals: d2:int __temp_return_n$3:class X d1:int x2:class X x1:class X \n DECLARE_LOCALS(&return,&d2,&__temp_return_n$3,&d1,&x2,&x1); [line 68]\n NULLIFY(&d1,false); [line 68]\n NULLIFY(&d2,false); [line 68]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
50 -> 57 ;
|
||||
49 [label="49: DeclStmt \n _fun_getY(2:int ,&SIL_materialize_temp__n$1:class Y *) [line 63]\n _fun_Y_Y(&y1:class Y *,&SIL_materialize_temp__n$1:class Y &) [line 63]\n " shape="box"]
|
||||
|
||||
|
||||
49 -> 48 ;
|
||||
48 [label="48: DeclStmt \n _fun_Y_Y(&y2:class Y *,&y1:class Y &) [line 64]\n " shape="box"]
|
||||
|
||||
|
||||
48 -> 47 ;
|
||||
47 [label="47: Return Stmt \n n$0=*&y2.f:int [line 65]\n *&return:int =(1 / n$0) [line 65]\n REMOVE_TEMPS(n$0); [line 65]\n NULLIFY(&SIL_materialize_temp__n$1,false); [line 65]\n NULLIFY(&y1,false); [line 65]\n NULLIFY(&y2,false); [line 65]\n APPLY_ABSTRACTION; [line 65]\n " shape="box"]
|
||||
|
||||
|
||||
47 -> 46 ;
|
||||
46 [label="46: Exit moveY_moveY_copyY_div0 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
45 [label="45: Start moveY_moveY_copyY_div0\nFormals: \nLocals: y2:class Y y1:class Y SIL_materialize_temp__n$1:class Y \n DECLARE_LOCALS(&return,&y2,&y1,&SIL_materialize_temp__n$1); [line 62]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
45 -> 49 ;
|
||||
44 [label="44: Return Stmt \n _fun_getY(1:int ,&__temp_return_n$1:class Y *) [line 59]\n n$2=*&__temp_return_n$1.f:int [line 59]\n *&return:int =(1 / n$2) [line 59]\n REMOVE_TEMPS(n$2); [line 59]\n NULLIFY(&__temp_return_n$1,false); [line 59]\n APPLY_ABSTRACTION; [line 59]\n " shape="box"]
|
||||
|
||||
|
||||
44 -> 43 ;
|
||||
43 [label="43: Exit moveY_div0 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
42 [label="42: Start moveY_div0\nFormals: \nLocals: __temp_return_n$1:class Y \n DECLARE_LOCALS(&return,&__temp_return_n$1); [line 58]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
42 -> 44 ;
|
||||
41 [label="41: DeclStmt \n _fun_Y_Y(&y1:class Y *) [line 52]\n " shape="box"]
|
||||
|
||||
|
||||
41 -> 40 ;
|
||||
40 [label="40: BinaryOperatorStmt: Assign \n *&y1.f:int =0 [line 53]\n " shape="box"]
|
||||
|
||||
|
||||
40 -> 39 ;
|
||||
39 [label="39: DeclStmt \n _fun_Y_Y(&y2:class Y *,&y1:class Y &) [line 54]\n " shape="box"]
|
||||
|
||||
|
||||
39 -> 38 ;
|
||||
38 [label="38: Return Stmt \n n$0=*&y2.f:int [line 55]\n *&return:int =(1 / n$0) [line 55]\n REMOVE_TEMPS(n$0); [line 55]\n NULLIFY(&y1,false); [line 55]\n NULLIFY(&y2,false); [line 55]\n APPLY_ABSTRACTION; [line 55]\n " shape="box"]
|
||||
|
||||
|
||||
38 -> 37 ;
|
||||
37 [label="37: Exit copyY_div0 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
36 [label="36: Start copyY_div0\nFormals: \nLocals: y2:class Y y1:class Y \n DECLARE_LOCALS(&return,&y2,&y1); [line 51]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
36 -> 41 ;
|
||||
35 [label="35: Return Stmt \n _fun_getX(0:int ,&__temp_return_n$1:class X *) [line 47]\n n$2=*&__temp_return_n$1.f:int [line 47]\n *&return:int =(1 / n$2) [line 47]\n REMOVE_TEMPS(n$2); [line 47]\n NULLIFY(&__temp_return_n$1,false); [line 47]\n APPLY_ABSTRACTION; [line 47]\n " shape="box"]
|
||||
|
||||
|
||||
35 -> 34 ;
|
||||
34 [label="34: Exit moveX_div0 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
33 [label="33: Start moveX_div0\nFormals: \nLocals: __temp_return_n$1:class X \n DECLARE_LOCALS(&return,&__temp_return_n$1); [line 46]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
33 -> 35 ;
|
||||
32 [label="32: DeclStmt \n _fun_X_X(&x1:class X *) [line 40]\n " shape="box"]
|
||||
|
||||
|
||||
32 -> 31 ;
|
||||
31 [label="31: BinaryOperatorStmt: Assign \n *&x1.f:int =0 [line 41]\n " shape="box"]
|
||||
|
||||
|
||||
31 -> 30 ;
|
||||
30 [label="30: DeclStmt \n _fun_X_X(&x2:class X *,&x1:class X &) [line 42]\n " shape="box"]
|
||||
|
||||
|
||||
30 -> 29 ;
|
||||
29 [label="29: Return Stmt \n n$0=*&x2.f:int [line 43]\n *&return:int =(1 / n$0) [line 43]\n REMOVE_TEMPS(n$0); [line 43]\n NULLIFY(&x1,false); [line 43]\n NULLIFY(&x2,false); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"]
|
||||
|
||||
|
||||
29 -> 28 ;
|
||||
28 [label="28: Exit copyX_div0 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
27 [label="27: Start copyX_div0\nFormals: \nLocals: x2:class X x1:class X \n DECLARE_LOCALS(&return,&x2,&x1); [line 39]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
27 -> 32 ;
|
||||
26 [label="26: DeclStmt \n _fun_Y_Y(&y:class Y *) [line 34]\n " shape="box"]
|
||||
|
||||
|
||||
26 -> 25 ;
|
||||
25 [label="25: BinaryOperatorStmt: Assign \n n$1=*&f:int [line 35]\n *&y.f:int =n$1 [line 35]\n REMOVE_TEMPS(n$1); [line 35]\n NULLIFY(&f,false); [line 35]\n " shape="box"]
|
||||
|
||||
|
||||
25 -> 24 ;
|
||||
24 [label="24: Return Stmt \n n$0=*&__return_param:class Y * [line 36]\n _fun_Y_Y(n$0:class Y *,&y:class Y &) [line 36]\n REMOVE_TEMPS(n$0); [line 36]\n NULLIFY(&__return_param,false); [line 36]\n NULLIFY(&y,false); [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"]
|
||||
|
||||
|
||||
24 -> 23 ;
|
||||
23 [label="23: Exit getY \n " color=yellow style=filled]
|
||||
|
||||
|
||||
22 [label="22: Start getY\nFormals: f:int __return_param:class Y *\nLocals: y:class Y \n DECLARE_LOCALS(&return,&y); [line 33]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
22 -> 26 ;
|
||||
21 [label="21: DeclStmt \n _fun_X_X(&x:class X *) [line 28]\n " shape="box"]
|
||||
|
||||
|
||||
21 -> 20 ;
|
||||
20 [label="20: BinaryOperatorStmt: Assign \n n$1=*&f:int [line 29]\n *&x.f:int =n$1 [line 29]\n REMOVE_TEMPS(n$1); [line 29]\n NULLIFY(&f,false); [line 29]\n " shape="box"]
|
||||
|
||||
|
||||
20 -> 19 ;
|
||||
19 [label="19: Return Stmt \n n$0=*&__return_param:class X * [line 30]\n _fun_X_X(n$0:class X *,&x:class X &) [line 30]\n REMOVE_TEMPS(n$0); [line 30]\n NULLIFY(&__return_param,false); [line 30]\n NULLIFY(&x,false); [line 30]\n APPLY_ABSTRACTION; [line 30]\n " shape="box"]
|
||||
|
||||
|
||||
19 -> 18 ;
|
||||
18 [label="18: Exit getX \n " color=yellow style=filled]
|
||||
|
||||
|
||||
17 [label="17: Start getX\nFormals: f:int __return_param:class X *\nLocals: x:class X \n DECLARE_LOCALS(&return,&x); [line 27]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
17 -> 21 ;
|
||||
16 [label="16: Constructor Init \n n$0=*&this:class Y * [line 24]\n n$1=*&y:class Y & [line 24]\n n$2=*n$1.f:int [line 24]\n *n$0.f:int =(n$2 - 1) [line 24]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 24]\n NULLIFY(&this,false); [line 24]\n NULLIFY(&y,false); [line 24]\n APPLY_ABSTRACTION; [line 24]\n " shape="box"]
|
||||
|
||||
|
||||
16 -> 15 ;
|
||||
15 [label="15: Exit Y_Y \n " color=yellow style=filled]
|
||||
|
||||
|
||||
14 [label="14: Start Y_Y\nFormals: this:class Y * y:class Y &\nLocals: \n DECLARE_LOCALS(&return); [line 24]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
14 -> 16 ;
|
||||
13 [label="13: Constructor Init \n n$0=*&this:class Y * [line 22]\n n$1=*&y:class Y & [line 22]\n n$2=*n$1.f:int [line 22]\n *n$0.f:int =n$2 [line 22]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 22]\n NULLIFY(&this,false); [line 22]\n NULLIFY(&y,false); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"]
|
||||
|
||||
|
||||
13 -> 12 ;
|
||||
12 [label="12: Exit Y_Y \n " color=yellow style=filled]
|
||||
|
||||
|
||||
11 [label="11: Start Y_Y\nFormals: this:class Y * y:class Y &\nLocals: \n DECLARE_LOCALS(&return); [line 22]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
11 -> 13 ;
|
||||
10 [label="10: Exit Y_Y \n " color=yellow style=filled]
|
||||
|
||||
|
||||
9 [label="9: Start Y_Y\nFormals: this:class Y *\nLocals: \n DECLARE_LOCALS(&return); [line 21]\n NULLIFY(&this,false); [line 21]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
9 -> 10 ;
|
||||
8 [label="8: Constructor Init \n n$0=*&this:class X * [line 13]\n n$1=*&__param_0:class X & [line 13]\n n$2=*n$1.f:int [line 13]\n *n$0.f:int =n$2 [line 13]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 13]\n NULLIFY(&__param_0,false); [line 13]\n NULLIFY(&this,false); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="box"]
|
||||
|
||||
|
||||
8 -> 7 ;
|
||||
7 [label="7: Exit X_X \n " color=yellow style=filled]
|
||||
|
||||
|
||||
6 [label="6: Start X_X\nFormals: this:class X * __param_0:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
6 -> 8 ;
|
||||
5 [label="5: Constructor Init \n n$0=*&this:class X * [line 13]\n n$1=*&__param_0:class X & [line 13]\n n$2=*n$1.f:int [line 13]\n *n$0.f:int =n$2 [line 13]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 13]\n NULLIFY(&__param_0,false); [line 13]\n NULLIFY(&this,false); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="box"]
|
||||
|
||||
|
||||
5 -> 4 ;
|
||||
4 [label="4: Exit X_X \n " color=yellow style=filled]
|
||||
|
||||
|
||||
3 [label="3: Start X_X\nFormals: this:class X * __param_0:class X &\nLocals: \n DECLARE_LOCALS(&return); [line 13]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
3 -> 5 ;
|
||||
2 [label="2: Exit X_X \n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 [label="1: Start X_X\nFormals: this:class X *\nLocals: \n DECLARE_LOCALS(&return); [line 13]\n NULLIFY(&this,false); [line 13]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 -> 2 ;
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.cpp;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.DebuggableTemporaryFolder;
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
import utils.InferRunner;
|
||||
|
||||
public class ConstructorInitTest {
|
||||
|
||||
public static final String FILE =
|
||||
"infer/tests/codetoanalyze/cpp/frontend/constructors/constructor_init.cpp";
|
||||
|
||||
private static ImmutableList<String> inferCmd;
|
||||
|
||||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
||||
|
||||
@ClassRule
|
||||
public static DebuggableTemporaryFolder folder =
|
||||
new DebuggableTemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void runInfer() throws InterruptedException, IOException {
|
||||
inferCmd = InferRunner.createCPPInferCommand(folder, FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnDiv0MethodsErrorIsFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
||||
String[] procedures = {
|
||||
"f2_div0",
|
||||
"f_div0",
|
||||
"t_div0",
|
||||
"delegate_constr_f_div0",
|
||||
"delegate_constr_f2_div0",
|
||||
};
|
||||
assertThat(
|
||||
"Results should contain the expected divide by zero",
|
||||
inferResults,
|
||||
containsExactly(
|
||||
DIVIDE_BY_ZERO,
|
||||
FILE,
|
||||
procedures
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2016 - present Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package endtoend.cpp;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.ResultContainsExactly.containsExactly;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.ClassRule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.DebuggableTemporaryFolder;
|
||||
import utils.InferException;
|
||||
import utils.InferResults;
|
||||
import utils.InferRunner;
|
||||
|
||||
public class CopyMoveConstructorTest {
|
||||
|
||||
public static final String FILE =
|
||||
"infer/tests/codetoanalyze/cpp/frontend/constructors/copy_move_constructor.cpp";
|
||||
|
||||
private static ImmutableList<String> inferCmd;
|
||||
|
||||
public static final String DIVIDE_BY_ZERO = "DIVIDE_BY_ZERO";
|
||||
|
||||
@ClassRule
|
||||
public static DebuggableTemporaryFolder folder =
|
||||
new DebuggableTemporaryFolder();
|
||||
|
||||
@BeforeClass
|
||||
public static void runInfer() throws InterruptedException, IOException {
|
||||
inferCmd = InferRunner.createCPPInferCommand(folder, FILE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenInferRunsOnDiv0MethodsErrorIsFound()
|
||||
throws InterruptedException, IOException, InferException {
|
||||
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
||||
String[] procedures = {
|
||||
"copyX_div0",
|
||||
"moveX_div0",
|
||||
"copyY_div0",
|
||||
"moveY_div0",
|
||||
"moveY_moveY_copyY_div0",
|
||||
};
|
||||
assertThat(
|
||||
"Results should contain the expected divide by zero",
|
||||
inferResults,
|
||||
containsExactly(
|
||||
DIVIDE_BY_ZERO,
|
||||
FILE,
|
||||
procedures
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue