Summary: public 1. When function uses return parameter instead of returning directly, populate that parameter. 2. Turn on new feature for C/C++ functions/methods that return structured types Reviewed By: jberdine Differential Revision: D2865091 fb-gh-sync-id: e15e6ebmaster
parent
61de633647
commit
ec80d40bdd
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* 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 X {
|
||||||
|
int f;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct A {
|
||||||
|
X get(int p) {
|
||||||
|
X x;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
int test(A *a) {
|
||||||
|
X x = a->get(1);
|
||||||
|
return 1 / x.f;
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
digraph iCFG {
|
||||||
|
12 [label="12: DeclStmt \n n$2=*&a:class A * [line 22]\n _fun_A_get(n$2:class A *,1:int ,&SIL_materialize_temp__n$1:struct X *) [line 22]\n n$3=*&SIL_materialize_temp__n$1:struct X [line 22]\n _fun_X_X(&x:struct X *,&SIL_materialize_temp__n$1:struct X ) [line 22]\n REMOVE_TEMPS(n$2,n$3); [line 22]\n NULLIFY(&a,false); [line 22]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
12 -> 11 ;
|
||||||
|
11 [label="11: Return Stmt \n n$0=*&x.f:int [line 23]\n *&return:int =(1 / n$0) [line 23]\n REMOVE_TEMPS(n$0); [line 23]\n NULLIFY(&SIL_materialize_temp__n$1,false); [line 23]\n NULLIFY(&x,false); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
11 -> 10 ;
|
||||||
|
10 [label="10: Exit test \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
9 [label="9: Start test\nFormals: a:class A *\nLocals: x:struct X SIL_materialize_temp__n$1:struct X \n DECLARE_LOCALS(&return,&x,&SIL_materialize_temp__n$1); [line 21]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
9 -> 12 ;
|
||||||
|
8 [label="8: DeclStmt \n _fun_X_X(&x:struct X *) [line 16]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
8 -> 7 ;
|
||||||
|
7 [label="7: Return Stmt \n n$0=*&__return_param:void * [line 17]\n _fun_X_X(n$0:struct X *,&x:struct X ) [line 17]\n REMOVE_TEMPS(n$0); [line 17]\n NULLIFY(&__return_param,false); [line 17]\n NULLIFY(&x,false); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
7 -> 6 ;
|
||||||
|
6 [label="6: Exit A_get \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
5 [label="5: Start A_get\nFormals: this:class A * p:int __return_param:struct X *\nLocals: x:struct X \n DECLARE_LOCALS(&return,&x); [line 15]\n NULLIFY(&p,false); [line 15]\n NULLIFY(&this,false); [line 15]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
5 -> 8 ;
|
||||||
|
4 [label="4: Exit X_X \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
3 [label="3: Start X_X\nFormals: this:class X * :void \nLocals: \n DECLARE_LOCALS(&return); [line 10]\n NULLIFY(&,false); [line 10]\n NULLIFY(&this,false); [line 10]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
3 -> 4 ;
|
||||||
|
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 10]\n NULLIFY(&this,false); [line 10]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
1 -> 2 ;
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* 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 X {
|
||||||
|
int f;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
X get(int a) {
|
||||||
|
X x;
|
||||||
|
x.f = a;
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test() {
|
||||||
|
X x = get(0);
|
||||||
|
return 1 / x.f;
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
digraph iCFG {
|
||||||
|
13 [label="13: DeclStmt \n _fun_get(0:int ,&SIL_materialize_temp__n$1:struct X *) [line 22]\n n$2=*&SIL_materialize_temp__n$1:struct X [line 22]\n _fun_X_X(&x:struct X *,&SIL_materialize_temp__n$1:struct X ) [line 22]\n REMOVE_TEMPS(n$2); [line 22]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
13 -> 12 ;
|
||||||
|
12 [label="12: Return Stmt \n n$0=*&x.f:int [line 23]\n *&return:int =(1 / n$0) [line 23]\n REMOVE_TEMPS(n$0); [line 23]\n NULLIFY(&SIL_materialize_temp__n$1,false); [line 23]\n NULLIFY(&x,false); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
12 -> 11 ;
|
||||||
|
11 [label="11: Exit test \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
10 [label="10: Start test\nFormals: \nLocals: x:struct X SIL_materialize_temp__n$1:struct X \n DECLARE_LOCALS(&return,&x,&SIL_materialize_temp__n$1); [line 21]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
10 -> 13 ;
|
||||||
|
9 [label="9: DeclStmt \n _fun_X_X(&x:struct X *) [line 16]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
9 -> 8 ;
|
||||||
|
8 [label="8: BinaryOperatorStmt: Assign \n n$1=*&a:int [line 17]\n *&x.f:int =n$1 [line 17]\n REMOVE_TEMPS(n$1); [line 17]\n NULLIFY(&a,false); [line 17]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
8 -> 7 ;
|
||||||
|
7 [label="7: Return Stmt \n n$0=*&__return_param:void * [line 18]\n _fun_X_X(n$0:struct X *,&x:struct X ) [line 18]\n REMOVE_TEMPS(n$0); [line 18]\n NULLIFY(&__return_param,false); [line 18]\n NULLIFY(&x,false); [line 18]\n APPLY_ABSTRACTION; [line 18]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
7 -> 6 ;
|
||||||
|
6 [label="6: Exit get \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
5 [label="5: Start get\nFormals: a:int __return_param:struct X *\nLocals: x:struct X \n DECLARE_LOCALS(&return,&x); [line 15]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
5 -> 9 ;
|
||||||
|
4 [label="4: Exit X_X \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
3 [label="3: Start X_X\nFormals: this:class X * :void \nLocals: \n DECLARE_LOCALS(&return); [line 10]\n NULLIFY(&,false); [line 10]\n NULLIFY(&this,false); [line 10]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
3 -> 4 ;
|
||||||
|
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 10]\n NULLIFY(&this,false); [line 10]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
1 -> 2 ;
|
||||||
|
}
|
Loading…
Reference in new issue