Reviewed By: ddino Differential Revision: D3024744 fb-gh-sync-id: 9e475c5 shipit-source-id: 9e475c5master
parent
63f8a3e709
commit
10a14a7324
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
|
||||||
|
class type_info {
|
||||||
|
|
||||||
|
type_info& operator=(const type_info&);
|
||||||
|
type_info(const type_info&);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
const char* __type_name;
|
||||||
|
|
||||||
|
explicit type_info(const char* __n) : __type_name(__n) {}
|
||||||
|
|
||||||
|
public:
|
||||||
|
virtual ~type_info();
|
||||||
|
|
||||||
|
const char* name() const noexcept { return __type_name; }
|
||||||
|
|
||||||
|
bool operator==(const type_info& __arg) const noexcept {
|
||||||
|
return __type_name == __arg.__type_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const type_info& __arg) const noexcept {
|
||||||
|
return !operator==(__arg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <typeinfo>
|
||||||
|
|
||||||
|
class Person {
|
||||||
|
public:
|
||||||
|
virtual ~Person() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Employee : public Person {};
|
||||||
|
|
||||||
|
int person_typeid() {
|
||||||
|
Person person;
|
||||||
|
int t = 3;
|
||||||
|
if (typeid(t) == typeid(person))
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 1 / 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int person_typeid_name() {
|
||||||
|
Person person;
|
||||||
|
int t = 3;
|
||||||
|
const char* t_type_info = typeid(t).name();
|
||||||
|
const char* person_type_info = typeid(person).name();
|
||||||
|
if (t_type_info == person_type_info)
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return 1 / 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int employee_typeid() {
|
||||||
|
Employee employee;
|
||||||
|
Person* ptr = &employee;
|
||||||
|
if (typeid(employee) == typeid(*ptr))
|
||||||
|
return 1 / 0;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int person_ptr_typeid(Person* ptr) {
|
||||||
|
Person person;
|
||||||
|
if (typeid(*ptr).name() == typeid(person).name())
|
||||||
|
return 1 / 0;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class Tgt>
|
||||||
|
const char* template_typeid(const Tgt& value) {
|
||||||
|
Tgt result = Tgt(value);
|
||||||
|
return typeid(Tgt).name();
|
||||||
|
}
|
||||||
|
|
||||||
|
int template_type_id_person() {
|
||||||
|
Person person;
|
||||||
|
if (template_typeid<Person>(person) == typeid(person).name())
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 1 / 0;
|
||||||
|
}
|
@ -0,0 +1,256 @@
|
|||||||
|
digraph iCFG {
|
||||||
|
65 [label="65: DeclStmt \n _fun_Person_Person(&person:class Person *) [line 63]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
65 -> 60 ;
|
||||||
|
64 [label="64: Return Stmt \n *&return:int =(1 / 0) [line 67]\n NULLIFY(&person,false); [line 67]\n APPLY_ABSTRACTION; [line 67]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
64 -> 58 ;
|
||||||
|
63 [label="63: Return Stmt \n *&return:int =1 [line 65]\n NULLIFY(&person,false); [line 65]\n APPLY_ABSTRACTION; [line 65]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
63 -> 58 ;
|
||||||
|
62 [label="62: Prune (false branch) \n PRUNE(((n$0 == n$3) == 0), false); [line 64]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3); [line 64]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
62 -> 64 ;
|
||||||
|
61 [label="61: Prune (true branch) \n PRUNE(((n$0 == n$3) != 0), true); [line 64]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3); [line 64]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
61 -> 63 ;
|
||||||
|
60 [label="60: BinaryOperatorStmt: EQ \n n$0=_fun_template_typeid<Person>(&person:class Person &) [line 64]\n n$1=_fun___cxx_typeid(sizeof(class std::type_info ):void ,n$1.__type_name:void ,&person:class Person ) [line 64]\n n$2=*n$1:class std::type_info [line 64]\n n$3=_fun_std::type_info_name(n$1:class std::type_info &) [line 64]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
60 -> 61 ;
|
||||||
|
60 -> 62 ;
|
||||||
|
59 [label="59: + \n NULLIFY(&person,false); [line 64]\n " ]
|
||||||
|
|
||||||
|
|
||||||
|
59 -> 58 ;
|
||||||
|
58 [label="58: Exit template_type_id_person \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
57 [label="57: Start template_type_id_person\nFormals: \nLocals: person:class Person \n DECLARE_LOCALS(&return,&person); [line 62]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
57 -> 65 ;
|
||||||
|
56 [label="56: DeclStmt \n n$4=*&value:class Person & [line 58]\n _fun_Person_Person(&SIL_materialize_temp__n$3:class Person *,n$4:class Person &) [line 58]\n _fun_Person_Person(&result:class Person *,&SIL_materialize_temp__n$3:class Person &) [line 58]\n REMOVE_TEMPS(n$4); [line 58]\n NULLIFY(&value,false); [line 58]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
56 -> 55 ;
|
||||||
|
55 [label="55: Return Stmt \n n$0=_fun___cxx_typeid(sizeof(class std::type_info ):void ,n$0.__type_name:void ) [line 59]\n n$1=*n$0:class std::type_info [line 59]\n n$2=_fun_std::type_info_name(n$0:class std::type_info &) [line 59]\n *&return:char *=n$2 [line 59]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 59]\n NULLIFY(&SIL_materialize_temp__n$3,false); [line 59]\n NULLIFY(&result,false); [line 59]\n APPLY_ABSTRACTION; [line 59]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
55 -> 54 ;
|
||||||
|
54 [label="54: Exit template_typeid<Person> \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
53 [label="53: Start template_typeid<Person>\nFormals: value:class Person &\nLocals: result:class Person SIL_materialize_temp__n$3:class Person \n DECLARE_LOCALS(&return,&result,&SIL_materialize_temp__n$3); [line 57]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
53 -> 56 ;
|
||||||
|
52 [label="52: DeclStmt \n _fun_Person_Person(&person:class Person *) [line 49]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
52 -> 47 ;
|
||||||
|
51 [label="51: Return Stmt \n *&return:int =0 [line 53]\n NULLIFY(&person,false); [line 53]\n APPLY_ABSTRACTION; [line 53]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
51 -> 45 ;
|
||||||
|
50 [label="50: Return Stmt \n *&return:int =(1 / 0) [line 51]\n NULLIFY(&person,false); [line 51]\n APPLY_ABSTRACTION; [line 51]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
50 -> 45 ;
|
||||||
|
49 [label="49: Prune (false branch) \n PRUNE(((n$3 == n$6) == 0), false); [line 50]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3,n$4,n$5,n$6); [line 50]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
49 -> 51 ;
|
||||||
|
48 [label="48: Prune (true branch) \n PRUNE(((n$3 == n$6) != 0), true); [line 50]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3,n$4,n$5,n$6); [line 50]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
48 -> 50 ;
|
||||||
|
47 [label="47: BinaryOperatorStmt: EQ \n n$0=*&ptr:class Person * [line 50]\n n$1=_fun___cxx_typeid(sizeof(class std::type_info ):void ,n$1.__type_name:void ,n$0:class Person ) [line 50]\n n$2=*n$1:class std::type_info [line 50]\n n$3=_fun_std::type_info_name(n$1:class std::type_info &) [line 50]\n n$4=_fun___cxx_typeid(sizeof(class std::type_info ):void ,n$4.__type_name:void ,&person:class Person ) [line 50]\n n$5=*n$4:class std::type_info [line 50]\n n$6=_fun_std::type_info_name(n$4:class std::type_info &) [line 50]\n NULLIFY(&ptr,false); [line 50]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
47 -> 48 ;
|
||||||
|
47 -> 49 ;
|
||||||
|
46 [label="46: + \n NULLIFY(&ptr,false); [line 50]\n NULLIFY(&person,false); [line 50]\n " ]
|
||||||
|
|
||||||
|
|
||||||
|
46 -> 45 ;
|
||||||
|
45 [label="45: Exit person_ptr_typeid \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
44 [label="44: Start person_ptr_typeid\nFormals: ptr:class Person *\nLocals: person:class Person \n DECLARE_LOCALS(&return,&person); [line 48]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
44 -> 52 ;
|
||||||
|
43 [label="43: DeclStmt \n _fun_Employee_Employee(&employee:class Employee *) [line 40]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
43 -> 42 ;
|
||||||
|
42 [label="42: DeclStmt \n *&ptr:class Employee *=&employee [line 41]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
42 -> 37 ;
|
||||||
|
41 [label="41: Return Stmt \n *&return:int =0 [line 45]\n NULLIFY(&employee,false); [line 45]\n APPLY_ABSTRACTION; [line 45]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
41 -> 35 ;
|
||||||
|
40 [label="40: Return Stmt \n *&return:int =(1 / 0) [line 43]\n NULLIFY(&employee,false); [line 43]\n APPLY_ABSTRACTION; [line 43]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
40 -> 35 ;
|
||||||
|
39 [label="39: Prune (false branch) \n PRUNE((n$3 == 0), false); [line 42]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3); [line 42]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
39 -> 41 ;
|
||||||
|
38 [label="38: Prune (true branch) \n PRUNE((n$3 != 0), true); [line 42]\n REMOVE_TEMPS(n$0,n$1,n$2,n$3); [line 42]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
38 -> 40 ;
|
||||||
|
37 [label="37: Call _fun_std::type_info_operator== \n n$0=_fun___cxx_typeid(sizeof(class std::type_info ):void ,n$0.__type_name:void ,&employee:class Employee ) [line 42]\n n$1=*&ptr:class Person * [line 42]\n n$2=_fun___cxx_typeid(sizeof(class std::type_info ):void ,n$2.__type_name:void ,n$1:class Person ) [line 42]\n n$3=_fun_std::type_info_operator==(n$0:class std::type_info &,n$2:class std::type_info &) [line 42]\n NULLIFY(&ptr,false); [line 42]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
37 -> 38 ;
|
||||||
|
37 -> 39 ;
|
||||||
|
36 [label="36: + \n NULLIFY(&ptr,false); [line 42]\n NULLIFY(&employee,false); [line 42]\n " ]
|
||||||
|
|
||||||
|
|
||||||
|
36 -> 35 ;
|
||||||
|
35 [label="35: Exit employee_typeid \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
34 [label="34: Start employee_typeid\nFormals: \nLocals: ptr:class Person * employee:class Employee \n DECLARE_LOCALS(&return,&ptr,&employee); [line 39]\n NULLIFY(&ptr,false); [line 39]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
34 -> 43 ;
|
||||||
|
33 [label="33: DeclStmt \n _fun_Person_Person(&person:class Person *) [line 29]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
33 -> 32 ;
|
||||||
|
32 [label="32: DeclStmt \n *&t:int =3 [line 30]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
32 -> 31 ;
|
||||||
|
31 [label="31: DeclStmt \n n$5=_fun___cxx_typeid(sizeof(class std::type_info ):void ,n$5.__type_name:void ,&t:int ) [line 31]\n n$6=*n$5:class std::type_info [line 31]\n n$7=_fun_std::type_info_name(n$5:class std::type_info &) [line 31]\n *&t_type_info:char *=n$7 [line 31]\n REMOVE_TEMPS(n$5,n$6,n$7); [line 31]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
31 -> 30 ;
|
||||||
|
30 [label="30: DeclStmt \n n$2=_fun___cxx_typeid(sizeof(class std::type_info ):void ,n$2.__type_name:void ,&person:class Person ) [line 32]\n n$3=*n$2:class std::type_info [line 32]\n n$4=_fun_std::type_info_name(n$2:class std::type_info &) [line 32]\n *&person_type_info:char *=n$4 [line 32]\n REMOVE_TEMPS(n$2,n$3,n$4); [line 32]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
30 -> 25 ;
|
||||||
|
29 [label="29: Return Stmt \n *&return:int =(1 / 0) [line 36]\n NULLIFY(&person,false); [line 36]\n NULLIFY(&t,false); [line 36]\n APPLY_ABSTRACTION; [line 36]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
29 -> 23 ;
|
||||||
|
28 [label="28: Return Stmt \n *&return:int =0 [line 34]\n NULLIFY(&person,false); [line 34]\n NULLIFY(&t,false); [line 34]\n APPLY_ABSTRACTION; [line 34]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
28 -> 23 ;
|
||||||
|
27 [label="27: Prune (false branch) \n PRUNE(((n$0 == n$1) == 0), false); [line 33]\n REMOVE_TEMPS(n$0,n$1); [line 33]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
27 -> 29 ;
|
||||||
|
26 [label="26: Prune (true branch) \n PRUNE(((n$0 == n$1) != 0), true); [line 33]\n REMOVE_TEMPS(n$0,n$1); [line 33]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
26 -> 28 ;
|
||||||
|
25 [label="25: BinaryOperatorStmt: EQ \n n$0=*&t_type_info:char * [line 33]\n n$1=*&person_type_info:char * [line 33]\n NULLIFY(&person_type_info,false); [line 33]\n NULLIFY(&t_type_info,false); [line 33]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
25 -> 26 ;
|
||||||
|
25 -> 27 ;
|
||||||
|
24 [label="24: + \n NULLIFY(&person_type_info,false); [line 33]\n NULLIFY(&t_type_info,false); [line 33]\n NULLIFY(&person,false); [line 33]\n NULLIFY(&t,false); [line 33]\n " ]
|
||||||
|
|
||||||
|
|
||||||
|
24 -> 23 ;
|
||||||
|
23 [label="23: Exit person_typeid_name \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
22 [label="22: Start person_typeid_name\nFormals: \nLocals: person_type_info:char * t_type_info:char * t:int person:class Person \n DECLARE_LOCALS(&return,&person_type_info,&t_type_info,&t,&person); [line 28]\n NULLIFY(&person_type_info,false); [line 28]\n NULLIFY(&t_type_info,false); [line 28]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
22 -> 33 ;
|
||||||
|
21 [label="21: DeclStmt \n _fun_Person_Person(&person:class Person *) [line 20]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
21 -> 20 ;
|
||||||
|
20 [label="20: DeclStmt \n *&t:int =3 [line 21]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
20 -> 15 ;
|
||||||
|
19 [label="19: Return Stmt \n *&return:int =(1 / 0) [line 25]\n NULLIFY(&person,false); [line 25]\n NULLIFY(&t,false); [line 25]\n APPLY_ABSTRACTION; [line 25]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
19 -> 13 ;
|
||||||
|
18 [label="18: Return Stmt \n *&return:int =1 [line 23]\n NULLIFY(&person,false); [line 23]\n NULLIFY(&t,false); [line 23]\n APPLY_ABSTRACTION; [line 23]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
18 -> 13 ;
|
||||||
|
17 [label="17: Prune (false branch) \n PRUNE((n$2 == 0), false); [line 22]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 22]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
17 -> 19 ;
|
||||||
|
16 [label="16: Prune (true branch) \n PRUNE((n$2 != 0), true); [line 22]\n REMOVE_TEMPS(n$0,n$1,n$2); [line 22]\n " shape="invhouse"]
|
||||||
|
|
||||||
|
|
||||||
|
16 -> 18 ;
|
||||||
|
15 [label="15: Call _fun_std::type_info_operator== \n n$0=_fun___cxx_typeid(sizeof(class std::type_info ):void ,n$0.__type_name:void ,&t:int ) [line 22]\n n$1=_fun___cxx_typeid(sizeof(class std::type_info ):void ,n$1.__type_name:void ,&person:class Person ) [line 22]\n n$2=_fun_std::type_info_operator==(n$0:class std::type_info &,n$1:class std::type_info &) [line 22]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
15 -> 16 ;
|
||||||
|
15 -> 17 ;
|
||||||
|
14 [label="14: + \n NULLIFY(&person,false); [line 22]\n NULLIFY(&t,false); [line 22]\n " ]
|
||||||
|
|
||||||
|
|
||||||
|
14 -> 13 ;
|
||||||
|
13 [label="13: Exit person_typeid \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
12 [label="12: Start person_typeid\nFormals: \nLocals: t:int person:class Person \n DECLARE_LOCALS(&return,&t,&person); [line 19]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
12 -> 21 ;
|
||||||
|
11 [label="11: Constructor Init \n n$0=*&this:class Employee * [line 17]\n _fun_Person_Person(n$0:class Employee *) [line 17]\n REMOVE_TEMPS(n$0); [line 17]\n NULLIFY(&this,false); [line 17]\n APPLY_ABSTRACTION; [line 17]\n " shape="box"]
|
||||||
|
|
||||||
|
|
||||||
|
11 -> 10 ;
|
||||||
|
10 [label="10: Exit Employee_Employee \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
9 [label="9: Start Employee_Employee\nFormals: this:class Employee *\nLocals: \n DECLARE_LOCALS(&return); [line 17]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
9 -> 11 ;
|
||||||
|
8 [label="8: Exit Employee_~Employee \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
7 [label="7: Start Employee_~Employee\nFormals: this:class Employee *\nLocals: \n DECLARE_LOCALS(&return); [line 17]\n NULLIFY(&this,false); [line 17]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
7 -> 8 ;
|
||||||
|
6 [label="6: Exit Person_Person \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
5 [label="5: Start Person_Person\nFormals: this:class Person *\nLocals: \n DECLARE_LOCALS(&return); [line 12]\n NULLIFY(&this,false); [line 12]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
5 -> 6 ;
|
||||||
|
4 [label="4: Exit Person_Person \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
3 [label="3: Start Person_Person\nFormals: this:class Person * __param_0:class Person &\nLocals: \n DECLARE_LOCALS(&return); [line 12]\n NULLIFY(&__param_0,false); [line 12]\n NULLIFY(&this,false); [line 12]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
3 -> 4 ;
|
||||||
|
2 [label="2: Exit Person_~Person \n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
1 [label="1: Start Person_~Person\nFormals: this:class Person *\nLocals: \n DECLARE_LOCALS(&return); [line 14]\n NULLIFY(&this,false); [line 14]\n " color=yellow style=filled]
|
||||||
|
|
||||||
|
|
||||||
|
1 -> 2 ;
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
* 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 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 TypeIdExprTest {
|
||||||
|
|
||||||
|
public static final String FILE =
|
||||||
|
"infer/tests/codetoanalyze/cpp/frontend/types/typeid_expr.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 whenInferRunsOnMethodsDivideByZeroIsFound()
|
||||||
|
throws InterruptedException, IOException, InferException {
|
||||||
|
InferResults inferResults = InferRunner.runInferCPP(inferCmd);
|
||||||
|
String[] procedures = {
|
||||||
|
"person_typeid",
|
||||||
|
"person_typeid_name",
|
||||||
|
"employee_typeid",
|
||||||
|
"person_ptr_typeid",
|
||||||
|
"template_type_id_person"
|
||||||
|
};
|
||||||
|
assertThat(
|
||||||
|
"Results should contain the no null dereference",
|
||||||
|
inferResults,
|
||||||
|
containsExactly(
|
||||||
|
DIVIDE_BY_ZERO,
|
||||||
|
FILE,
|
||||||
|
procedures
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013 - 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 frontend.cpp;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import utils.DebuggableTemporaryFolder;
|
||||||
|
import utils.InferException;
|
||||||
|
import utils.ClangFrontendUtils;
|
||||||
|
|
||||||
|
public class TypesTest {
|
||||||
|
|
||||||
|
String basePath = "infer/tests/codetoanalyze/cpp/frontend/types/";
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public DebuggableTemporaryFolder folder = new DebuggableTemporaryFolder();
|
||||||
|
|
||||||
|
void frontendTest(String fileRelative) throws InterruptedException, IOException, InferException {
|
||||||
|
ClangFrontendUtils.createAndCompareCppDotFiles(folder, basePath + fileRelative);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void typeidExprDotFilesMatch()
|
||||||
|
throws InterruptedException, IOException, InferException {
|
||||||
|
frontendTest("typeid_expr.cpp");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue