Summary: @public 1. Factor out some of the common code for comparing C++ dot files 2. Create new directory with smaller .cpp files to translate Reviewed By: @dulmarod Differential Revision: D2507757master
parent
1e9ce38056
commit
b78d6f623a
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 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.
|
||||
*/
|
||||
|
||||
class A {
|
||||
public:
|
||||
// default parameters
|
||||
int fun_default(int a, int b = 10, int c = 20) {return a+b+c;}
|
||||
};
|
||||
|
||||
void call_method_with_default_parameters() {
|
||||
A *a_ptr;
|
||||
a_ptr->fun_default(1,2,3);
|
||||
a_ptr->fun_default(1,2);
|
||||
a_ptr->fun_default(1);
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
digraph iCFG {
|
||||
8 [label="8: Call _fun_A_fun_default \n n$4=*&a_ptr:class A * [line 18]\n n$5=_fun_A_fun_default(n$4:class A ,1:int ,2:int ,3:int ) [line 18]\n REMOVE_TEMPS(n$4,n$5); [line 18]\n " shape="box"]
|
||||
|
||||
|
||||
8 -> 7 ;
|
||||
7 [label="7: Call _fun_A_fun_default \n n$2=*&a_ptr:class A * [line 19]\n n$3=_fun_A_fun_default(n$2:class A ,1:int ,2:int ,20:int ) [line 19]\n REMOVE_TEMPS(n$2,n$3); [line 19]\n " shape="box"]
|
||||
|
||||
|
||||
7 -> 6 ;
|
||||
6 [label="6: Call _fun_A_fun_default \n n$0=*&a_ptr:class A * [line 20]\n n$1=_fun_A_fun_default(n$0:class A ,1:int ,10:int ,20:int ) [line 20]\n REMOVE_TEMPS(n$0,n$1); [line 20]\n NULLIFY(&a_ptr,false); [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"]
|
||||
|
||||
|
||||
6 -> 5 ;
|
||||
5 [label="5: Exit call_method_with_default_parameters \n " color=yellow style=filled]
|
||||
|
||||
|
||||
4 [label="4: Start call_method_with_default_parameters\nFormals: \nLocals: a_ptr:class A * \n DECLARE_LOCALS(&return,&a_ptr); [line 16]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
4 -> 8 ;
|
||||
3 [label="3: Return Stmt \n n$0=*&a:int [line 13]\n n$1=*&b:int [line 13]\n n$2=*&c:int [line 13]\n *&return:int =((n$0 + n$1) + n$2) [line 13]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 13]\n NULLIFY(&a,false); [line 13]\n NULLIFY(&b,false); [line 13]\n NULLIFY(&c,false); [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="box"]
|
||||
|
||||
|
||||
3 -> 2 ;
|
||||
2 [label="2: Exit A_fun_default \n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 [label="1: Start A_fun_default\nFormals: this:class A a:int b:int c:int \nLocals: \n DECLARE_LOCALS(&return); [line 13]\n NULLIFY(&this,false); [line 13]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 -> 3 ;
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 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.
|
||||
*/
|
||||
|
||||
class A {
|
||||
struct AIn {
|
||||
int fun() { return 1;}
|
||||
};
|
||||
AIn *in;
|
||||
// inline definition
|
||||
int fun() { int c = 10; return c+1;}
|
||||
};
|
||||
|
||||
void test_call() {
|
||||
A *a_ptr;
|
||||
a_ptr->fun();
|
||||
a_ptr->in->fun();
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
digraph iCFG {
|
||||
11 [label="11: Call _fun_A_fun \n n$3=*&a_ptr:class A * [line 21]\n n$4=_fun_A_fun(n$3:class A ) [line 21]\n REMOVE_TEMPS(n$3,n$4); [line 21]\n " shape="box"]
|
||||
|
||||
|
||||
11 -> 10 ;
|
||||
10 [label="10: Call _fun_A::AIn_fun \n n$0=*&a_ptr:class A * [line 22]\n n$1=*n$0.in:class A::AIn * [line 22]\n n$2=_fun_A::AIn_fun(n$1:class A::AIn ) [line 22]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 22]\n NULLIFY(&a_ptr,false); [line 22]\n APPLY_ABSTRACTION; [line 22]\n " shape="box"]
|
||||
|
||||
|
||||
10 -> 9 ;
|
||||
9 [label="9: Exit test_call \n " color=yellow style=filled]
|
||||
|
||||
|
||||
8 [label="8: Start test_call\nFormals: \nLocals: a_ptr:class A * \n DECLARE_LOCALS(&return,&a_ptr); [line 19]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
8 -> 11 ;
|
||||
7 [label="7: DeclStmt \n *&c:int =10 [line 16]\n " shape="box"]
|
||||
|
||||
|
||||
7 -> 6 ;
|
||||
6 [label="6: Return Stmt \n n$0=*&c:int [line 16]\n *&return:int =(n$0 + 1) [line 16]\n REMOVE_TEMPS(n$0); [line 16]\n NULLIFY(&c,false); [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"]
|
||||
|
||||
|
||||
6 -> 5 ;
|
||||
5 [label="5: Exit A_fun \n " color=yellow style=filled]
|
||||
|
||||
|
||||
4 [label="4: Start A_fun\nFormals: this:class A \nLocals: c:int \n DECLARE_LOCALS(&return,&c); [line 16]\n NULLIFY(&c,false); [line 16]\n NULLIFY(&this,false); [line 16]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
4 -> 7 ;
|
||||
3 [label="3: Return Stmt \n *&return:int =1 [line 12]\n APPLY_ABSTRACTION; [line 12]\n " shape="box"]
|
||||
|
||||
|
||||
3 -> 2 ;
|
||||
2 [label="2: Exit A::AIn_fun \n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 [label="1: Start A::AIn_fun\nFormals: this:class A::AIn \nLocals: \n DECLARE_LOCALS(&return); [line 12]\n NULLIFY(&this,false); [line 12]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 -> 3 ;
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 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.
|
||||
*/
|
||||
|
||||
class A {
|
||||
int fun(int a, int b);
|
||||
int fun(int a, int b, int c);
|
||||
};
|
||||
|
||||
int A::fun(int a, int b, int c) {
|
||||
return a + b + c;
|
||||
}
|
||||
|
||||
int A::fun(int a, int b) {
|
||||
return a - b;
|
||||
}
|
||||
|
||||
void test() {
|
||||
A *a_ptr;
|
||||
// calling methods
|
||||
a_ptr->fun(1,2);
|
||||
a_ptr->fun(1,2,3);
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
digraph iCFG {
|
||||
10 [label="10: Call _fun_A_fun \n n$2=*&a_ptr:class A * [line 26]\n n$3=_fun_A_fun(n$2:class A ,1:int ,2:int ) [line 26]\n REMOVE_TEMPS(n$2,n$3); [line 26]\n " shape="box"]
|
||||
|
||||
|
||||
10 -> 9 ;
|
||||
9 [label="9: Call _fun_A_fun \n n$0=*&a_ptr:class A * [line 27]\n n$1=_fun_A_fun(n$0:class A ,1:int ,2:int ,3:int ) [line 27]\n REMOVE_TEMPS(n$0,n$1); [line 27]\n NULLIFY(&a_ptr,false); [line 27]\n APPLY_ABSTRACTION; [line 27]\n " shape="box"]
|
||||
|
||||
|
||||
9 -> 8 ;
|
||||
8 [label="8: Exit test \n " color=yellow style=filled]
|
||||
|
||||
|
||||
7 [label="7: Start test\nFormals: \nLocals: a_ptr:class A * \n DECLARE_LOCALS(&return,&a_ptr); [line 23]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
7 -> 10 ;
|
||||
6 [label="6: Return Stmt \n n$0=*&a:int [line 20]\n n$1=*&b:int [line 20]\n *&return:int =(n$0 - n$1) [line 20]\n REMOVE_TEMPS(n$0,n$1); [line 20]\n NULLIFY(&a,false); [line 20]\n NULLIFY(&b,false); [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"]
|
||||
|
||||
|
||||
6 -> 5 ;
|
||||
5 [label="5: Exit A_fun \n " color=yellow style=filled]
|
||||
|
||||
|
||||
4 [label="4: Start A_fun\nFormals: this:class A a:int b:int \nLocals: \n DECLARE_LOCALS(&return); [line 19]\n NULLIFY(&this,false); [line 19]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
4 -> 6 ;
|
||||
3 [label="3: Return Stmt \n n$0=*&a:int [line 16]\n n$1=*&b:int [line 16]\n n$2=*&c:int [line 16]\n *&return:int =((n$0 + n$1) + n$2) [line 16]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 16]\n NULLIFY(&a,false); [line 16]\n NULLIFY(&b,false); [line 16]\n NULLIFY(&c,false); [line 16]\n APPLY_ABSTRACTION; [line 16]\n " shape="box"]
|
||||
|
||||
|
||||
3 -> 2 ;
|
||||
2 [label="2: Exit A_fun \n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 [label="1: Start A_fun\nFormals: this:class A a:int b:int c:int \nLocals: \n DECLARE_LOCALS(&return); [line 15]\n NULLIFY(&this,false); [line 15]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 -> 3 ;
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
// commented out parts are not done yet
|
||||
struct A {
|
||||
public:
|
||||
int member1;
|
||||
float member2;
|
||||
public:
|
||||
int fun(int a, int b);
|
||||
// overloading
|
||||
int fun(int a, int b, int c);
|
||||
int add(const A& other);
|
||||
|
||||
struct AIn {
|
||||
int fun1() { return 1;}
|
||||
int fun(int a, int b);
|
||||
};
|
||||
// inline definition
|
||||
int def_in() { int c = 10; return c+1;}
|
||||
|
||||
// default parameters
|
||||
int fun_default(int a, int b = 10, int c = 20) {return a+b+c;}
|
||||
//static function
|
||||
//static int get_fun() {return 1;}
|
||||
};
|
||||
|
||||
int A::fun(int a, int b, int c) {
|
||||
//using class members
|
||||
//fun(a,b);
|
||||
}
|
||||
|
||||
int A::fun(int a, int b) {
|
||||
int c = a + b + 1;
|
||||
//using class members
|
||||
//member1 = c;
|
||||
return c*c;
|
||||
}
|
||||
|
||||
int A::AIn::fun(int a, int b) {
|
||||
return a+b;
|
||||
}
|
||||
|
||||
int A::add(const A& other) {
|
||||
//member1 += other.member1;
|
||||
//return member1;
|
||||
}
|
||||
|
||||
void call_method() {
|
||||
// constructing objects
|
||||
//A a;
|
||||
//a.fun(1,2);
|
||||
|
||||
A *a_ptr;
|
||||
// calling methods
|
||||
a_ptr->fun(10,20);
|
||||
a_ptr->fun_default(1,2,3);
|
||||
}
|
||||
|
||||
void call_method_with_default_parameters() {
|
||||
A *a_ptr;
|
||||
a_ptr->fun_default(1,2);
|
||||
a_ptr->fun_default(1);
|
||||
}
|
||||
|
||||
/*
|
||||
void call_static_method {
|
||||
A *a_ptr;
|
||||
A::get_fun();
|
||||
a_ptr->get_fun();
|
||||
}
|
||||
*/
|
@ -1,109 +0,0 @@
|
||||
digraph iCFG {
|
||||
29 [label="29: Call _fun_A_fun_default \n n$2=*&a_ptr:class A * [line 59]\n n$3=_fun_A_fun_default(n$2:class A ,1:int ,2:int ,20:int ) [line 59]\n REMOVE_TEMPS(n$2,n$3); [line 59]\n " shape="box"]
|
||||
|
||||
|
||||
29 -> 28 ;
|
||||
28 [label="28: Call _fun_A_fun_default \n n$0=*&a_ptr:class A * [line 60]\n n$1=_fun_A_fun_default(n$0:class A ,1:int ,10:int ,20:int ) [line 60]\n REMOVE_TEMPS(n$0,n$1); [line 60]\n NULLIFY(&a_ptr,false); [line 60]\n APPLY_ABSTRACTION; [line 60]\n " shape="box"]
|
||||
|
||||
|
||||
28 -> 27 ;
|
||||
27 [label="27: Exit call_method_with_default_parameters \n " color=yellow style=filled]
|
||||
|
||||
|
||||
26 [label="26: Start call_method_with_default_parameters\nFormals: \nLocals: a_ptr:class A * \n DECLARE_LOCALS(&return,&a_ptr); [line 57]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
26 -> 29 ;
|
||||
25 [label="25: Call _fun_A_fun \n n$2=*&a_ptr:class A * [line 53]\n n$3=_fun_A_fun(n$2:class A ,10:int ,20:int ) [line 53]\n REMOVE_TEMPS(n$2,n$3); [line 53]\n " shape="box"]
|
||||
|
||||
|
||||
25 -> 24 ;
|
||||
24 [label="24: Call _fun_A_fun_default \n n$0=*&a_ptr:class A * [line 54]\n n$1=_fun_A_fun_default(n$0:class A ,1:int ,2:int ,3:int ) [line 54]\n REMOVE_TEMPS(n$0,n$1); [line 54]\n NULLIFY(&a_ptr,false); [line 54]\n APPLY_ABSTRACTION; [line 54]\n " shape="box"]
|
||||
|
||||
|
||||
24 -> 23 ;
|
||||
23 [label="23: Exit call_method \n " color=yellow style=filled]
|
||||
|
||||
|
||||
22 [label="22: Start call_method\nFormals: \nLocals: a_ptr:class A * \n DECLARE_LOCALS(&return,&a_ptr); [line 46]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
22 -> 25 ;
|
||||
21 [label="21: Exit A_add \n " color=yellow style=filled]
|
||||
|
||||
|
||||
20 [label="20: Start A_add\nFormals: this:class A other:class A &\nLocals: \n DECLARE_LOCALS(&return); [line 41]\n NULLIFY(&other,false); [line 41]\n NULLIFY(&this,false); [line 41]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
20 -> 21 ;
|
||||
19 [label="19: Return Stmt \n n$0=*&a:int [line 38]\n n$1=*&b:int [line 38]\n *&return:int =(n$0 + n$1) [line 38]\n REMOVE_TEMPS(n$0,n$1); [line 38]\n NULLIFY(&a,false); [line 38]\n NULLIFY(&b,false); [line 38]\n APPLY_ABSTRACTION; [line 38]\n " shape="box"]
|
||||
|
||||
|
||||
19 -> 18 ;
|
||||
18 [label="18: Exit A::AIn_fun \n " color=yellow style=filled]
|
||||
|
||||
|
||||
17 [label="17: Start A::AIn_fun\nFormals: this:class A::AIn a:int b:int \nLocals: \n DECLARE_LOCALS(&return); [line 37]\n NULLIFY(&this,false); [line 37]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
17 -> 19 ;
|
||||
16 [label="16: DeclStmt \n n$2=*&a:int [line 31]\n n$3=*&b:int [line 31]\n *&c:int =((n$2 + n$3) + 1) [line 31]\n REMOVE_TEMPS(n$2,n$3); [line 31]\n NULLIFY(&a,false); [line 31]\n NULLIFY(&b,false); [line 31]\n " shape="box"]
|
||||
|
||||
|
||||
16 -> 15 ;
|
||||
15 [label="15: Return Stmt \n n$0=*&c:int [line 34]\n n$1=*&c:int [line 34]\n *&return:int =(n$0 * n$1) [line 34]\n REMOVE_TEMPS(n$0,n$1); [line 34]\n NULLIFY(&c,false); [line 34]\n APPLY_ABSTRACTION; [line 34]\n " shape="box"]
|
||||
|
||||
|
||||
15 -> 14 ;
|
||||
14 [label="14: Exit A_fun \n " color=yellow style=filled]
|
||||
|
||||
|
||||
13 [label="13: Start A_fun\nFormals: this:class A a:int b:int \nLocals: c:int \n DECLARE_LOCALS(&return,&c); [line 30]\n NULLIFY(&c,false); [line 30]\n NULLIFY(&this,false); [line 30]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
13 -> 16 ;
|
||||
12 [label="12: Exit A_fun \n " color=yellow style=filled]
|
||||
|
||||
|
||||
11 [label="11: Start A_fun\nFormals: this:class A a:int b:int c:int \nLocals: \n DECLARE_LOCALS(&return); [line 25]\n NULLIFY(&a,false); [line 25]\n NULLIFY(&b,false); [line 25]\n NULLIFY(&c,false); [line 25]\n NULLIFY(&this,false); [line 25]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
11 -> 12 ;
|
||||
10 [label="10: Return Stmt \n n$0=*&a:int [line 20]\n n$1=*&b:int [line 20]\n n$2=*&c:int [line 20]\n *&return:int =((n$0 + n$1) + n$2) [line 20]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 20]\n NULLIFY(&a,false); [line 20]\n NULLIFY(&b,false); [line 20]\n NULLIFY(&c,false); [line 20]\n APPLY_ABSTRACTION; [line 20]\n " shape="box"]
|
||||
|
||||
|
||||
10 -> 9 ;
|
||||
9 [label="9: Exit A_fun_default \n " color=yellow style=filled]
|
||||
|
||||
|
||||
8 [label="8: Start A_fun_default\nFormals: this:class A a:int b:int c:int \nLocals: \n DECLARE_LOCALS(&return); [line 20]\n NULLIFY(&this,false); [line 20]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
8 -> 10 ;
|
||||
7 [label="7: DeclStmt \n *&c:int =10 [line 17]\n " shape="box"]
|
||||
|
||||
|
||||
7 -> 6 ;
|
||||
6 [label="6: Return Stmt \n n$0=*&c:int [line 17]\n *&return:int =(n$0 + 1) [line 17]\n REMOVE_TEMPS(n$0); [line 17]\n NULLIFY(&c,false); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"]
|
||||
|
||||
|
||||
6 -> 5 ;
|
||||
5 [label="5: Exit A_def_in \n " color=yellow style=filled]
|
||||
|
||||
|
||||
4 [label="4: Start A_def_in\nFormals: this:class A \nLocals: c:int \n DECLARE_LOCALS(&return,&c); [line 17]\n NULLIFY(&c,false); [line 17]\n NULLIFY(&this,false); [line 17]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
4 -> 7 ;
|
||||
3 [label="3: Return Stmt \n *&return:int =1 [line 13]\n APPLY_ABSTRACTION; [line 13]\n " shape="box"]
|
||||
|
||||
|
||||
3 -> 2 ;
|
||||
2 [label="2: Exit A::AIn_fun1 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 [label="1: Start A::AIn_fun1\nFormals: this:class A::AIn \nLocals: \n DECLARE_LOCALS(&return); [line 13]\n NULLIFY(&this,false); [line 13]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
1 -> 3 ;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2015 - 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 utils;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static utils.matchers.DotFilesEqual.dotFileEqualTo;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import utils.DebuggableTemporaryFolder;
|
||||
import utils.InferException;
|
||||
import utils.InferRunner;
|
||||
|
||||
public class ClangFrontendUtils {
|
||||
public static void createAndCompareCppDotFiles(DebuggableTemporaryFolder folder, String pathToSrcFile)
|
||||
throws InterruptedException, IOException, InferException {
|
||||
|
||||
String test_src = pathToSrcFile;
|
||||
String test_dotty = pathToSrcFile + ".dot";
|
||||
ImmutableList<String> inferCmd =
|
||||
InferRunner.createCPPInferCommandFrontend(
|
||||
folder,
|
||||
test_src);
|
||||
File newDotFile = InferRunner.runInferFrontend(inferCmd);
|
||||
assertThat(
|
||||
"In the capture of " + test_src +
|
||||
" the dotty files should be the same.",
|
||||
newDotFile, dotFileEqualTo(test_dotty));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue