Reviewed By: jberdine Differential Revision: D4954391 fbshipit-source-id: 26685c0master
parent
1b0ee6fbc3
commit
aefbbe8680
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2017 - 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 implicit_cast_with_const {
|
||||
|
||||
struct Base {
|
||||
int* f{nullptr};
|
||||
};
|
||||
|
||||
struct Derived : public Base {};
|
||||
|
||||
int deref(const Base& b) { return *b.f; }
|
||||
|
||||
int BaseDerefNPE() {
|
||||
Base b;
|
||||
return deref(b);
|
||||
}
|
||||
|
||||
int DerivedDerefNPE() {
|
||||
Derived d;
|
||||
return deref(d);
|
||||
}
|
||||
|
||||
int DerivedDerefNoNpe() {
|
||||
Derived d;
|
||||
int x;
|
||||
d.f = &x;
|
||||
return deref(d);
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2017 - 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.
|
||||
*/
|
||||
int const_in_param1(int const* p) { return *p; }
|
||||
|
||||
int const_in_param2(int const* const p) { return *p; }
|
||||
|
||||
int call_const_params_with_address() {
|
||||
int x = 1;
|
||||
const_in_param1(&x);
|
||||
const_in_param2(&x);
|
||||
|
||||
const int cx = 0;
|
||||
|
||||
const_in_param1(&cx);
|
||||
const_in_param2(&cx);
|
||||
}
|
||||
|
||||
int call_const_params_with_pointer1() {
|
||||
int* p = nullptr;
|
||||
const_in_param1(p);
|
||||
}
|
||||
int call_const_params_with_pointer2() {
|
||||
int* p = nullptr;
|
||||
const_in_param2(p);
|
||||
}
|
||||
|
||||
int call_const_params_with_pointer3() {
|
||||
int* const cp = nullptr;
|
||||
const_in_param2(cp);
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
/* @generated */
|
||||
digraph iCFG {
|
||||
"call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_1" [label="1: Start call_const_params_with_address\nFormals: \nLocals: cx:int x:int \n DECLARE_LOCALS(&return,&cx,&x); [line 13]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
"call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_1" -> "call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_8" ;
|
||||
"call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_2" [label="2: Exit call_const_params_with_address \n " color=yellow style=filled]
|
||||
|
||||
|
||||
"call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_3" [label="3: Call _fun_const_in_param2 \n n$0=_fun_const_in_param2(&cx:int*) [line 21]\n " shape="box"]
|
||||
|
||||
|
||||
"call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_3" -> "call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_2" ;
|
||||
"call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_4" [label="4: Call _fun_const_in_param1 \n n$1=_fun_const_in_param1(&cx:int*) [line 20]\n " shape="box"]
|
||||
|
||||
|
||||
"call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_4" -> "call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_3" ;
|
||||
"call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_5" [label="5: DeclStmt \n *&cx:int=0 [line 18]\n " shape="box"]
|
||||
|
||||
|
||||
"call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_5" -> "call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_4" ;
|
||||
"call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_6" [label="6: Call _fun_const_in_param2 \n n$2=_fun_const_in_param2(&x:int*) [line 16]\n " shape="box"]
|
||||
|
||||
|
||||
"call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_6" -> "call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_5" ;
|
||||
"call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_7" [label="7: Call _fun_const_in_param1 \n n$3=_fun_const_in_param1(&x:int*) [line 15]\n " shape="box"]
|
||||
|
||||
|
||||
"call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_7" -> "call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_6" ;
|
||||
"call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_8" [label="8: DeclStmt \n *&x:int=1 [line 14]\n " shape="box"]
|
||||
|
||||
|
||||
"call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_8" -> "call_const_params_with_address#_Z30call_const_params_with_addressv.e754c92d7d89808473eac017465662b5_7" ;
|
||||
"call_const_params_with_pointer1#_Z31call_const_params_with_pointer1v.95229883c9127e312980c9ae25c8da43_1" [label="1: Start call_const_params_with_pointer1\nFormals: \nLocals: p:int* \n DECLARE_LOCALS(&return,&p); [line 24]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
"call_const_params_with_pointer1#_Z31call_const_params_with_pointer1v.95229883c9127e312980c9ae25c8da43_1" -> "call_const_params_with_pointer1#_Z31call_const_params_with_pointer1v.95229883c9127e312980c9ae25c8da43_4" ;
|
||||
"call_const_params_with_pointer1#_Z31call_const_params_with_pointer1v.95229883c9127e312980c9ae25c8da43_2" [label="2: Exit call_const_params_with_pointer1 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
"call_const_params_with_pointer1#_Z31call_const_params_with_pointer1v.95229883c9127e312980c9ae25c8da43_3" [label="3: Call _fun_const_in_param1 \n n$0=*&p:int* [line 26]\n n$1=_fun_const_in_param1(n$0:int*) [line 26]\n " shape="box"]
|
||||
|
||||
|
||||
"call_const_params_with_pointer1#_Z31call_const_params_with_pointer1v.95229883c9127e312980c9ae25c8da43_3" -> "call_const_params_with_pointer1#_Z31call_const_params_with_pointer1v.95229883c9127e312980c9ae25c8da43_2" ;
|
||||
"call_const_params_with_pointer1#_Z31call_const_params_with_pointer1v.95229883c9127e312980c9ae25c8da43_4" [label="4: DeclStmt \n *&p:int*=null [line 25]\n " shape="box"]
|
||||
|
||||
|
||||
"call_const_params_with_pointer1#_Z31call_const_params_with_pointer1v.95229883c9127e312980c9ae25c8da43_4" -> "call_const_params_with_pointer1#_Z31call_const_params_with_pointer1v.95229883c9127e312980c9ae25c8da43_3" ;
|
||||
"call_const_params_with_pointer2#_Z31call_const_params_with_pointer2v.d36c25662191fdac9d4028112e2d7d51_1" [label="1: Start call_const_params_with_pointer2\nFormals: \nLocals: p:int* \n DECLARE_LOCALS(&return,&p); [line 28]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
"call_const_params_with_pointer2#_Z31call_const_params_with_pointer2v.d36c25662191fdac9d4028112e2d7d51_1" -> "call_const_params_with_pointer2#_Z31call_const_params_with_pointer2v.d36c25662191fdac9d4028112e2d7d51_4" ;
|
||||
"call_const_params_with_pointer2#_Z31call_const_params_with_pointer2v.d36c25662191fdac9d4028112e2d7d51_2" [label="2: Exit call_const_params_with_pointer2 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
"call_const_params_with_pointer2#_Z31call_const_params_with_pointer2v.d36c25662191fdac9d4028112e2d7d51_3" [label="3: Call _fun_const_in_param2 \n n$0=*&p:int* [line 30]\n n$1=_fun_const_in_param2(n$0:int*) [line 30]\n " shape="box"]
|
||||
|
||||
|
||||
"call_const_params_with_pointer2#_Z31call_const_params_with_pointer2v.d36c25662191fdac9d4028112e2d7d51_3" -> "call_const_params_with_pointer2#_Z31call_const_params_with_pointer2v.d36c25662191fdac9d4028112e2d7d51_2" ;
|
||||
"call_const_params_with_pointer2#_Z31call_const_params_with_pointer2v.d36c25662191fdac9d4028112e2d7d51_4" [label="4: DeclStmt \n *&p:int*=null [line 29]\n " shape="box"]
|
||||
|
||||
|
||||
"call_const_params_with_pointer2#_Z31call_const_params_with_pointer2v.d36c25662191fdac9d4028112e2d7d51_4" -> "call_const_params_with_pointer2#_Z31call_const_params_with_pointer2v.d36c25662191fdac9d4028112e2d7d51_3" ;
|
||||
"call_const_params_with_pointer3#_Z31call_const_params_with_pointer3v.3e5ec1065082911e42d0566ebc0bf6ed_1" [label="1: Start call_const_params_with_pointer3\nFormals: \nLocals: cp:int* \n DECLARE_LOCALS(&return,&cp); [line 33]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
"call_const_params_with_pointer3#_Z31call_const_params_with_pointer3v.3e5ec1065082911e42d0566ebc0bf6ed_1" -> "call_const_params_with_pointer3#_Z31call_const_params_with_pointer3v.3e5ec1065082911e42d0566ebc0bf6ed_4" ;
|
||||
"call_const_params_with_pointer3#_Z31call_const_params_with_pointer3v.3e5ec1065082911e42d0566ebc0bf6ed_2" [label="2: Exit call_const_params_with_pointer3 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
"call_const_params_with_pointer3#_Z31call_const_params_with_pointer3v.3e5ec1065082911e42d0566ebc0bf6ed_3" [label="3: Call _fun_const_in_param2 \n n$0=*&cp:int* [line 35]\n n$1=_fun_const_in_param2(n$0:int*) [line 35]\n " shape="box"]
|
||||
|
||||
|
||||
"call_const_params_with_pointer3#_Z31call_const_params_with_pointer3v.3e5ec1065082911e42d0566ebc0bf6ed_3" -> "call_const_params_with_pointer3#_Z31call_const_params_with_pointer3v.3e5ec1065082911e42d0566ebc0bf6ed_2" ;
|
||||
"call_const_params_with_pointer3#_Z31call_const_params_with_pointer3v.3e5ec1065082911e42d0566ebc0bf6ed_4" [label="4: DeclStmt \n *&cp:int*=null [line 34]\n " shape="box"]
|
||||
|
||||
|
||||
"call_const_params_with_pointer3#_Z31call_const_params_with_pointer3v.3e5ec1065082911e42d0566ebc0bf6ed_4" -> "call_const_params_with_pointer3#_Z31call_const_params_with_pointer3v.3e5ec1065082911e42d0566ebc0bf6ed_3" ;
|
||||
"const_in_param1#_Z15const_in_param1PKi.1071f2f253e69ef9bc570605af35bf83_1" [label="1: Start const_in_param1\nFormals: p:int*\nLocals: \n DECLARE_LOCALS(&return); [line 9]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
"const_in_param1#_Z15const_in_param1PKi.1071f2f253e69ef9bc570605af35bf83_1" -> "const_in_param1#_Z15const_in_param1PKi.1071f2f253e69ef9bc570605af35bf83_3" ;
|
||||
"const_in_param1#_Z15const_in_param1PKi.1071f2f253e69ef9bc570605af35bf83_2" [label="2: Exit const_in_param1 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
"const_in_param1#_Z15const_in_param1PKi.1071f2f253e69ef9bc570605af35bf83_3" [label="3: Return Stmt \n n$0=*&p:int* [line 9]\n n$1=*n$0:int [line 9]\n *&return:int=n$1 [line 9]\n " shape="box"]
|
||||
|
||||
|
||||
"const_in_param1#_Z15const_in_param1PKi.1071f2f253e69ef9bc570605af35bf83_3" -> "const_in_param1#_Z15const_in_param1PKi.1071f2f253e69ef9bc570605af35bf83_2" ;
|
||||
"const_in_param2#_Z15const_in_param2PKi.659d05c79678837da803a1f8b1bc46c1_1" [label="1: Start const_in_param2\nFormals: p:int*\nLocals: \n DECLARE_LOCALS(&return); [line 11]\n " color=yellow style=filled]
|
||||
|
||||
|
||||
"const_in_param2#_Z15const_in_param2PKi.659d05c79678837da803a1f8b1bc46c1_1" -> "const_in_param2#_Z15const_in_param2PKi.659d05c79678837da803a1f8b1bc46c1_3" ;
|
||||
"const_in_param2#_Z15const_in_param2PKi.659d05c79678837da803a1f8b1bc46c1_2" [label="2: Exit const_in_param2 \n " color=yellow style=filled]
|
||||
|
||||
|
||||
"const_in_param2#_Z15const_in_param2PKi.659d05c79678837da803a1f8b1bc46c1_3" [label="3: Return Stmt \n n$0=*&p:int* [line 11]\n n$1=*n$0:int [line 11]\n *&return:int=n$1 [line 11]\n " shape="box"]
|
||||
|
||||
|
||||
"const_in_param2#_Z15const_in_param2PKi.659d05c79678837da803a1f8b1bc46c1_3" -> "const_in_param2#_Z15const_in_param2PKi.659d05c79678837da803a1f8b1bc46c1_2" ;
|
||||
}
|
Loading…
Reference in new issue