[clang] do not add extra dereferences

Summary:
The purpose these serve is unclear to me. From the comment I *think*
they were used to hint to the biabduction backend that smart pointers
are just pointers. That said, The tests still mostly pass even without
that (just a few `weak_ptr` tests changed from `NULL_DEREFERENCE` to
`Bad_footprint`).

Moreover, this extra dereference was added unreliably. For instance,
this piece of code:

```
auto x = std::make_unique<X>(some_X);
```

would either get the extra dereference or not depending on which headers
were picked for the C++ stdlib.

The extra dereference was tripping up the liveness checker (see later in
the stack), and probably most checkers too.

Reviewed By: mbouaziz

Differential Revision: D13991130

fbshipit-source-id: 462923595
master
Jules Villard 6 years ago committed by Facebook Github Bot
parent 5cee92941a
commit 41abbe363d

@ -1133,9 +1133,6 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
and cxxConstructExpr_trans trans_state si params_stmt ei cxx_constr_info ~is_inherited_ctor =
let context = trans_state.context in
let trans_state_pri = PriorityNode.try_claim_priority_node trans_state si in
let sil_loc =
CLocation.location_of_stmt_info context.translation_unit_context.source_file si
in
let decl_ref = cxx_constr_info.Clang_ast_t.xcei_decl_ref in
let var_exp, class_type =
match trans_state.var_exp_typ with
@ -1156,33 +1153,14 @@ module CTrans_funct (F : CModule_type.CFrontend) : CModule_type.CTranslation = s
mk_trans_result (var_exp, this_type) {empty_control with initd_exps= [var_exp]}
in
let tmp_res_trans = mk_trans_result (var_exp, class_type) empty_control in
(* When class type is translated as pointer (std::shared_ptr for example), there needs
to be extra Load instruction before returning the trans_result of constructorExpr.
There is no LValueToRvalue cast in the AST afterwards since clang doesn't know
that class type is translated as pointer type. It gets added here instead. *)
let extra_res_trans =
let do_extra_deref =
match class_type.desc with
| Typ.Tptr _ ->
(* do not inject the extra dereference for procedures generated to record the
initialization code of globals *)
Procdesc.get_proc_name trans_state.context.procdesc
|> Typ.Procname.get_global_name_of_initializer |> Option.is_none
| _ ->
false
in
if do_extra_deref then
dereference_value_from_result si.Clang_ast_t.si_source_range sil_loc tmp_res_trans
else tmp_res_trans
in
let res_trans_callee =
decl_ref_trans ~context:(MemberOrIvar this_res_trans) trans_state si decl_ref
in
let res_trans =
cxx_method_construct_call_trans trans_state_pri res_trans_callee params_stmt si
(Typ.mk Tvoid) false (Some extra_res_trans) ~is_inherited_ctor
(Typ.mk Tvoid) false (Some tmp_res_trans) ~is_inherited_ctor
in
{res_trans with return= extra_res_trans.return}
{res_trans with return= tmp_res_trans.return}
and cxx_destructor_call_trans trans_state si this_res_trans class_type_ptr ~is_inner_destructor =

@ -128,19 +128,19 @@ digraph cfg {
"main.fad58de7366495db4650cfefac2fcd61_4" -> "main.fad58de7366495db4650cfefac2fcd61_3" ;
"main.fad58de7366495db4650cfefac2fcd61_5" [label="5: DeclStmt \n n$9=_fun___variable_initialization(&x:int*) assign_last [line 19, column 3]\n n$8=_fun_std::shared_ptr<int>_shared_ptr(&x:int**) [line 19, column 24]\n n$7=*&x:int* [line 19, column 24]\n EXIT_SCOPE(n$7,n$8,n$9); [line 19, column 24]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_5" [label="5: DeclStmt \n n$8=_fun___variable_initialization(&x:int*) assign_last [line 19, column 3]\n n$7=_fun_std::shared_ptr<int>_shared_ptr(&x:int**) [line 19, column 24]\n EXIT_SCOPE(n$7,n$8); [line 19, column 24]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_5" -> "main.fad58de7366495db4650cfefac2fcd61_4" ;
"main.fad58de7366495db4650cfefac2fcd61_6" [label="6: Call _fun_external::fun \n n$10=_fun_external::fun(1:int) [line 18, column 3]\n EXIT_SCOPE(n$10); [line 18, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_6" [label="6: Call _fun_external::fun \n n$9=_fun_external::fun(1:int) [line 18, column 3]\n EXIT_SCOPE(n$9); [line 18, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_6" -> "main.fad58de7366495db4650cfefac2fcd61_5" ;
"main.fad58de7366495db4650cfefac2fcd61_7" [label="7: Call _fun_internal_exclude::fun \n n$11=_fun_internal_exclude::fun(1:int) [line 17, column 3]\n EXIT_SCOPE(n$11); [line 17, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_7" [label="7: Call _fun_internal_exclude::fun \n n$10=_fun_internal_exclude::fun(1:int) [line 17, column 3]\n EXIT_SCOPE(n$10); [line 17, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_7" -> "main.fad58de7366495db4650cfefac2fcd61_6" ;
"main.fad58de7366495db4650cfefac2fcd61_8" [label="8: Call _fun_internal::fun \n n$12=_fun_internal::fun(1:int) [line 16, column 3]\n EXIT_SCOPE(n$12); [line 16, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_8" [label="8: Call _fun_internal::fun \n n$11=_fun_internal::fun(1:int) [line 16, column 3]\n EXIT_SCOPE(n$11); [line 16, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_8" -> "main.fad58de7366495db4650cfefac2fcd61_7" ;
@ -747,7 +747,7 @@ digraph cfg {
"shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_3" -> "shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_2" ;
"shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_4" [label="4: Constructor Init \n n$4=*&this:int** [line 97, column 42]\n n$6=_fun_std::std__shared_ptr<int>_std__shared_ptr(n$4:int**) [line 96, column 13]\n n$5=*n$4:int* [line 96, column 13]\n EXIT_SCOPE(n$4,n$5,n$6); [line 96, column 13]\n " shape="box"]
"shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_4" [label="4: Constructor Init \n n$4=*&this:int** [line 97, column 42]\n n$5=_fun_std::std__shared_ptr<int>_std__shared_ptr(n$4:int**) [line 96, column 13]\n EXIT_SCOPE(n$4,n$5); [line 96, column 13]\n " shape="box"]
"shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_4" -> "shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_3" ;

@ -128,19 +128,19 @@ digraph cfg {
"main.fad58de7366495db4650cfefac2fcd61_4" -> "main.fad58de7366495db4650cfefac2fcd61_3" ;
"main.fad58de7366495db4650cfefac2fcd61_5" [label="5: DeclStmt \n n$9=_fun___variable_initialization(&x:int*) assign_last [line 19, column 3]\n n$8=_fun_std::shared_ptr<int>_shared_ptr(&x:int**) [line 19, column 24]\n n$7=*&x:int* [line 19, column 24]\n EXIT_SCOPE(n$7,n$8,n$9); [line 19, column 24]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_5" [label="5: DeclStmt \n n$8=_fun___variable_initialization(&x:int*) assign_last [line 19, column 3]\n n$7=_fun_std::shared_ptr<int>_shared_ptr(&x:int**) [line 19, column 24]\n EXIT_SCOPE(n$7,n$8); [line 19, column 24]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_5" -> "main.fad58de7366495db4650cfefac2fcd61_4" ;
"main.fad58de7366495db4650cfefac2fcd61_6" [label="6: Call _fun_external::fun \n n$10=_fun_external::fun(1:int) [line 18, column 3]\n EXIT_SCOPE(n$10); [line 18, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_6" [label="6: Call _fun_external::fun \n n$9=_fun_external::fun(1:int) [line 18, column 3]\n EXIT_SCOPE(n$9); [line 18, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_6" -> "main.fad58de7366495db4650cfefac2fcd61_5" ;
"main.fad58de7366495db4650cfefac2fcd61_7" [label="7: Call _fun_internal_exclude::fun \n n$11=_fun_internal_exclude::fun(1:int) [line 17, column 3]\n EXIT_SCOPE(n$11); [line 17, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_7" [label="7: Call _fun_internal_exclude::fun \n n$10=_fun_internal_exclude::fun(1:int) [line 17, column 3]\n EXIT_SCOPE(n$10); [line 17, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_7" -> "main.fad58de7366495db4650cfefac2fcd61_6" ;
"main.fad58de7366495db4650cfefac2fcd61_8" [label="8: Call _fun_internal::fun \n n$12=_fun_internal::fun(1:int) [line 16, column 3]\n EXIT_SCOPE(n$12); [line 16, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_8" [label="8: Call _fun_internal::fun \n n$11=_fun_internal::fun(1:int) [line 16, column 3]\n EXIT_SCOPE(n$11); [line 16, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_8" -> "main.fad58de7366495db4650cfefac2fcd61_7" ;
@ -747,7 +747,7 @@ digraph cfg {
"shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_3" -> "shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_2" ;
"shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_4" [label="4: Constructor Init \n n$4=*&this:int** [line 97, column 42]\n n$6=_fun_std::std__shared_ptr<int>_std__shared_ptr(n$4:int**) [line 96, column 13]\n n$5=*n$4:int* [line 96, column 13]\n EXIT_SCOPE(n$4,n$5,n$6); [line 96, column 13]\n " shape="box"]
"shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_4" [label="4: Constructor Init \n n$4=*&this:int** [line 97, column 42]\n n$5=_fun_std::std__shared_ptr<int>_std__shared_ptr(n$4:int**) [line 96, column 13]\n EXIT_SCOPE(n$4,n$5); [line 96, column 13]\n " shape="box"]
"shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_4" -> "shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_3" ;

@ -128,19 +128,19 @@ digraph cfg {
"main.fad58de7366495db4650cfefac2fcd61_4" -> "main.fad58de7366495db4650cfefac2fcd61_3" ;
"main.fad58de7366495db4650cfefac2fcd61_5" [label="5: DeclStmt \n n$9=_fun___variable_initialization(&x:int*) assign_last [line 19, column 3]\n n$8=_fun_std::shared_ptr<int>_shared_ptr(&x:int**) [line 19, column 24]\n n$7=*&x:int* [line 19, column 24]\n EXIT_SCOPE(n$7,n$8,n$9); [line 19, column 24]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_5" [label="5: DeclStmt \n n$8=_fun___variable_initialization(&x:int*) assign_last [line 19, column 3]\n n$7=_fun_std::shared_ptr<int>_shared_ptr(&x:int**) [line 19, column 24]\n EXIT_SCOPE(n$7,n$8); [line 19, column 24]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_5" -> "main.fad58de7366495db4650cfefac2fcd61_4" ;
"main.fad58de7366495db4650cfefac2fcd61_6" [label="6: Call _fun_external::fun \n n$10=_fun_external::fun(1:int) [line 18, column 3]\n EXIT_SCOPE(n$10); [line 18, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_6" [label="6: Call _fun_external::fun \n n$9=_fun_external::fun(1:int) [line 18, column 3]\n EXIT_SCOPE(n$9); [line 18, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_6" -> "main.fad58de7366495db4650cfefac2fcd61_5" ;
"main.fad58de7366495db4650cfefac2fcd61_7" [label="7: Call _fun_internal_exclude::fun \n n$11=_fun_internal_exclude::fun(1:int) [line 17, column 3]\n EXIT_SCOPE(n$11); [line 17, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_7" [label="7: Call _fun_internal_exclude::fun \n n$10=_fun_internal_exclude::fun(1:int) [line 17, column 3]\n EXIT_SCOPE(n$10); [line 17, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_7" -> "main.fad58de7366495db4650cfefac2fcd61_6" ;
"main.fad58de7366495db4650cfefac2fcd61_8" [label="8: Call _fun_internal::fun \n n$12=_fun_internal::fun(1:int) [line 16, column 3]\n EXIT_SCOPE(n$12); [line 16, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_8" [label="8: Call _fun_internal::fun \n n$11=_fun_internal::fun(1:int) [line 16, column 3]\n EXIT_SCOPE(n$11); [line 16, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_8" -> "main.fad58de7366495db4650cfefac2fcd61_7" ;
@ -747,7 +747,7 @@ digraph cfg {
"shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_3" -> "shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_2" ;
"shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_4" [label="4: Constructor Init \n n$4=*&this:int** [line 97, column 42]\n n$6=_fun_std::std__shared_ptr<int>_std__shared_ptr(n$4:int**) [line 96, column 13]\n n$5=*n$4:int* [line 96, column 13]\n EXIT_SCOPE(n$4,n$5,n$6); [line 96, column 13]\n " shape="box"]
"shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_4" [label="4: Constructor Init \n n$4=*&this:int** [line 97, column 42]\n n$5=_fun_std::std__shared_ptr<int>_std__shared_ptr(n$4:int**) [line 96, column 13]\n EXIT_SCOPE(n$4,n$5); [line 96, column 13]\n " shape="box"]
"shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_4" -> "shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_3" ;

@ -128,19 +128,19 @@ digraph cfg {
"main.fad58de7366495db4650cfefac2fcd61_4" -> "main.fad58de7366495db4650cfefac2fcd61_3" ;
"main.fad58de7366495db4650cfefac2fcd61_5" [label="5: DeclStmt \n n$9=_fun___variable_initialization(&x:int*) assign_last [line 19, column 3]\n n$8=_fun_std::shared_ptr<int>_shared_ptr(&x:int**) [line 19, column 24]\n n$7=*&x:int* [line 19, column 24]\n EXIT_SCOPE(n$7,n$8,n$9); [line 19, column 24]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_5" [label="5: DeclStmt \n n$8=_fun___variable_initialization(&x:int*) assign_last [line 19, column 3]\n n$7=_fun_std::shared_ptr<int>_shared_ptr(&x:int**) [line 19, column 24]\n EXIT_SCOPE(n$7,n$8); [line 19, column 24]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_5" -> "main.fad58de7366495db4650cfefac2fcd61_4" ;
"main.fad58de7366495db4650cfefac2fcd61_6" [label="6: Call _fun_external::fun \n n$10=_fun_external::fun(1:int) [line 18, column 3]\n EXIT_SCOPE(n$10); [line 18, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_6" [label="6: Call _fun_external::fun \n n$9=_fun_external::fun(1:int) [line 18, column 3]\n EXIT_SCOPE(n$9); [line 18, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_6" -> "main.fad58de7366495db4650cfefac2fcd61_5" ;
"main.fad58de7366495db4650cfefac2fcd61_7" [label="7: Call _fun_internal_exclude::fun \n n$11=_fun_internal_exclude::fun(1:int) [line 17, column 3]\n EXIT_SCOPE(n$11); [line 17, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_7" [label="7: Call _fun_internal_exclude::fun \n n$10=_fun_internal_exclude::fun(1:int) [line 17, column 3]\n EXIT_SCOPE(n$10); [line 17, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_7" -> "main.fad58de7366495db4650cfefac2fcd61_6" ;
"main.fad58de7366495db4650cfefac2fcd61_8" [label="8: Call _fun_internal::fun \n n$12=_fun_internal::fun(1:int) [line 16, column 3]\n EXIT_SCOPE(n$12); [line 16, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_8" [label="8: Call _fun_internal::fun \n n$11=_fun_internal::fun(1:int) [line 16, column 3]\n EXIT_SCOPE(n$11); [line 16, column 3]\n " shape="box"]
"main.fad58de7366495db4650cfefac2fcd61_8" -> "main.fad58de7366495db4650cfefac2fcd61_7" ;
@ -747,7 +747,7 @@ digraph cfg {
"shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_3" -> "shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_2" ;
"shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_4" [label="4: Constructor Init \n n$4=*&this:int** [line 97, column 42]\n n$6=_fun_std::std__shared_ptr<int>_std__shared_ptr(n$4:int**) [line 96, column 13]\n n$5=*n$4:int* [line 96, column 13]\n EXIT_SCOPE(n$4,n$5,n$6); [line 96, column 13]\n " shape="box"]
"shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_4" [label="4: Constructor Init \n n$4=*&this:int** [line 97, column 42]\n n$5=_fun_std::std__shared_ptr<int>_std__shared_ptr(n$4:int**) [line 96, column 13]\n EXIT_SCOPE(n$4,n$5); [line 96, column 13]\n " shape="box"]
"shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_4" -> "shared_ptr#shared_ptr<int>#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_3" ;

@ -134,11 +134,11 @@ codetoanalyze/cpp/errors/smart_ptr/unique_ptr_deref.cpp, unique_ptr::unique_ptr_
codetoanalyze/cpp/errors/smart_ptr/unique_ptr_deref.cpp, unique_ptr::unique_ptr_copy_null_deref, 3, NULL_DEREFERENCE, B1, ERROR, [start of procedure unique_ptr::unique_ptr_copy_null_deref()]
codetoanalyze/cpp/errors/smart_ptr/unique_ptr_deref.cpp, unique_ptr::unique_ptr_move_null_deref, 3, NULL_DEREFERENCE, B1, ERROR, [start of procedure unique_ptr::unique_ptr_move_null_deref()]
codetoanalyze/cpp/errors/smart_ptr/unique_ptr_deref.cpp, unique_ptr::unique_ptr_move_ok_deref, 3, MEMORY_LEAK, CPP, ERROR, [start of procedure unique_ptr::unique_ptr_move_ok_deref()]
codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::safeGetFromSharedBaseAssign_bad, 4, NULL_DEREFERENCE, B1, ERROR, [start of procedure weak_ptr_derefs::safeGetFromSharedBaseAssign_bad(),start of procedure weak_ptr_constructors::fromSharedBaseAssign(),return from a call to weak_ptr_constructors::fromSharedBaseAssign,start of procedure weak_ptr_derefs::safeGet(),Loop condition is false. Leaving loop,return from a call to weak_ptr_derefs::safeGet]
codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::safeGetFromSharedBaseConstr_bad, 4, NULL_DEREFERENCE, B1, ERROR, [start of procedure weak_ptr_derefs::safeGetFromSharedBaseConstr_bad(),start of procedure weak_ptr_constructors::fromSharedBaseConstr(),return from a call to weak_ptr_constructors::fromSharedBaseConstr,start of procedure weak_ptr_derefs::safeGet(),Loop condition is false. Leaving loop,return from a call to weak_ptr_derefs::safeGet]
codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::safeGetFromSharedDerivedAssign_bad, 4, NULL_DEREFERENCE, B1, ERROR, [start of procedure weak_ptr_derefs::safeGetFromSharedDerivedAssign_bad(),start of procedure weak_ptr_constructors::fromSharedDerivedAssign(),return from a call to weak_ptr_constructors::fromSharedDerivedAssign,start of procedure weak_ptr_derefs::safeGet(),Loop condition is false. Leaving loop,return from a call to weak_ptr_derefs::safeGet]
codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::safeGetFromSharedDerivedConstr2_bad, 4, NULL_DEREFERENCE, B1, ERROR, [start of procedure weak_ptr_derefs::safeGetFromSharedDerivedConstr2_bad(),start of procedure weak_ptr_constructors::fromSharedDerivedConstr2(),return from a call to weak_ptr_constructors::fromSharedDerivedConstr2,start of procedure weak_ptr_derefs::safeGet(),Loop condition is false. Leaving loop,return from a call to weak_ptr_derefs::safeGet]
codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::safeGetFromSharedDerivedConstr_bad, 4, NULL_DEREFERENCE, B1, ERROR, [start of procedure weak_ptr_derefs::safeGetFromSharedDerivedConstr_bad(),start of procedure weak_ptr_constructors::fromSharedDerivedConstr(),return from a call to weak_ptr_constructors::fromSharedDerivedConstr,start of procedure weak_ptr_derefs::safeGet(),Loop condition is false. Leaving loop,return from a call to weak_ptr_derefs::safeGet]
codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::FN_safeGetFromSharedBaseAssign_bad, 4, Bad_footprint, no_bucket, ERROR, [start of procedure weak_ptr_derefs::FN_safeGetFromSharedBaseAssign_bad(),start of procedure weak_ptr_constructors::fromSharedBaseAssign(),return from a call to weak_ptr_constructors::fromSharedBaseAssign,start of procedure weak_ptr_derefs::safeGet(),Loop condition is false. Leaving loop,return from a call to weak_ptr_derefs::safeGet]
codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::FN_safeGetFromSharedBaseConstr_bad, 4, Bad_footprint, no_bucket, ERROR, [start of procedure weak_ptr_derefs::FN_safeGetFromSharedBaseConstr_bad(),start of procedure weak_ptr_constructors::fromSharedBaseConstr(),return from a call to weak_ptr_constructors::fromSharedBaseConstr,start of procedure weak_ptr_derefs::safeGet(),Loop condition is false. Leaving loop,return from a call to weak_ptr_derefs::safeGet]
codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::FN_safeGetFromSharedDerivedAssign_bad, 4, Bad_footprint, no_bucket, ERROR, [start of procedure weak_ptr_derefs::FN_safeGetFromSharedDerivedAssign_bad(),start of procedure weak_ptr_constructors::fromSharedDerivedAssign(),return from a call to weak_ptr_constructors::fromSharedDerivedAssign,start of procedure weak_ptr_derefs::safeGet(),Loop condition is false. Leaving loop,return from a call to weak_ptr_derefs::safeGet]
codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::FN_safeGetFromSharedDerivedConstr2_bad, 4, Bad_footprint, no_bucket, ERROR, [start of procedure weak_ptr_derefs::FN_safeGetFromSharedDerivedConstr2_bad(),start of procedure weak_ptr_constructors::fromSharedDerivedConstr2(),return from a call to weak_ptr_constructors::fromSharedDerivedConstr2,start of procedure weak_ptr_derefs::safeGet(),Loop condition is false. Leaving loop,return from a call to weak_ptr_derefs::safeGet]
codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::FN_safeGetFromSharedDerivedConstr_bad, 4, Bad_footprint, no_bucket, ERROR, [start of procedure weak_ptr_derefs::FN_safeGetFromSharedDerivedConstr_bad(),start of procedure weak_ptr_constructors::fromSharedDerivedConstr(),return from a call to weak_ptr_constructors::fromSharedDerivedConstr,start of procedure weak_ptr_derefs::safeGet(),Loop condition is false. Leaving loop,return from a call to weak_ptr_derefs::safeGet]
codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::safeGetFromWeakBaseAssign_bad, 4, NULL_DEREFERENCE, B1, ERROR, [start of procedure weak_ptr_derefs::safeGetFromWeakBaseAssign_bad(),start of procedure weak_ptr_constructors::fromWeakBaseAssign(),return from a call to weak_ptr_constructors::fromWeakBaseAssign,start of procedure weak_ptr_derefs::safeGet(),Loop condition is false. Leaving loop,return from a call to weak_ptr_derefs::safeGet]
codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::safeGetFromWeakBaseConstr_bad, 4, NULL_DEREFERENCE, B1, ERROR, [start of procedure weak_ptr_derefs::safeGetFromWeakBaseConstr_bad(),start of procedure weak_ptr_constructors::fromWeakBaseConstr(),return from a call to weak_ptr_constructors::fromWeakBaseConstr,start of procedure weak_ptr_derefs::safeGet(),Loop condition is false. Leaving loop,return from a call to weak_ptr_derefs::safeGet]
codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_derefs::safeGetFromWeakDerivedAssign_bad, 4, NULL_DEREFERENCE, B1, ERROR, [start of procedure weak_ptr_derefs::safeGetFromWeakDerivedAssign_bad(),start of procedure weak_ptr_constructors::fromWeakDerivedAssign(),return from a call to weak_ptr_constructors::fromWeakDerivedAssign,start of procedure weak_ptr_derefs::safeGet(),Loop condition is false. Leaving loop,return from a call to weak_ptr_derefs::safeGet]

@ -118,35 +118,35 @@ int safeGetFromWeakDerivedAssign_bad(int v) {
return *s->f1;
}
int safeGetFromSharedBaseConstr_bad(int v) {
int FN_safeGetFromSharedBaseConstr_bad(int v) {
auto b = std::make_shared<Base>(&v);
auto s = safeGet(fromSharedBaseConstr(b));
b->f1 = nullptr;
return *s->f1;
}
int safeGetFromSharedBaseAssign_bad(int v) {
int FN_safeGetFromSharedBaseAssign_bad(int v) {
auto b = std::make_shared<Base>(&v);
auto s = safeGet(fromSharedBaseAssign(b));
b->f1 = nullptr;
return *s->f1;
}
int safeGetFromSharedDerivedConstr_bad(int v) {
int FN_safeGetFromSharedDerivedConstr_bad(int v) {
auto b = std::make_shared<Derived>(&v);
auto s = safeGet(fromSharedDerivedConstr(b));
b->f1 = nullptr;
return *s->f1;
}
int safeGetFromSharedDerivedConstr2_bad(int v) {
int FN_safeGetFromSharedDerivedConstr2_bad(int v) {
auto b = std::make_shared<Derived>(&v);
auto s = safeGet(fromSharedDerivedConstr2(b));
b->f1 = nullptr;
return *s->f1;
}
int safeGetFromSharedDerivedAssign_bad(int v) {
int FN_safeGetFromSharedDerivedAssign_bad(int v) {
auto b = std::make_shared<Derived>(&v);
auto s = safeGet(fromSharedDerivedAssign(b));
b->f1 = nullptr;

@ -134,7 +134,7 @@ digraph cfg {
"getPtr_null_deref1#10685326586135592861.d05a7735c36f759fec001951cdc51035_4" -> "getPtr_null_deref1#10685326586135592861.d05a7735c36f759fec001951cdc51035_3" ;
"getPtr_null_deref1#10685326586135592861.d05a7735c36f759fec001951cdc51035_5" [label="5: DeclStmt \n n$8=_fun___variable_initialization(&t:int*) assign_last [line 88, column 3]\n n$7=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 88, column 23]\n n$6=*&t:int* [line 88, column 23]\n EXIT_SCOPE(n$6,n$7,n$8); [line 88, column 23]\n " shape="box"]
"getPtr_null_deref1#10685326586135592861.d05a7735c36f759fec001951cdc51035_5" [label="5: DeclStmt \n n$7=_fun___variable_initialization(&t:int*) assign_last [line 88, column 3]\n n$6=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 88, column 23]\n EXIT_SCOPE(n$6,n$7); [line 88, column 23]\n " shape="box"]
"getPtr_null_deref1#10685326586135592861.d05a7735c36f759fec001951cdc51035_5" -> "getPtr_null_deref1#10685326586135592861.d05a7735c36f759fec001951cdc51035_4" ;
@ -153,7 +153,7 @@ digraph cfg {
"getPtr_null_deref2#10682492045158632578.de31216813faa493761802feb6f997f2_4" -> "getPtr_null_deref2#10682492045158632578.de31216813faa493761802feb6f997f2_3" ;
"getPtr_null_deref2#10682492045158632578.de31216813faa493761802feb6f997f2_5" [label="5: DeclStmt \n n$8=_fun___variable_initialization(&t:int*) assign_last [line 94, column 3]\n n$7=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 94, column 23]\n n$6=*&t:int* [line 94, column 23]\n EXIT_SCOPE(n$6,n$7,n$8); [line 94, column 23]\n " shape="box"]
"getPtr_null_deref2#10682492045158632578.de31216813faa493761802feb6f997f2_5" [label="5: DeclStmt \n n$7=_fun___variable_initialization(&t:int*) assign_last [line 94, column 3]\n n$6=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 94, column 23]\n EXIT_SCOPE(n$6,n$7); [line 94, column 23]\n " shape="box"]
"getPtr_null_deref2#10682492045158632578.de31216813faa493761802feb6f997f2_5" -> "getPtr_null_deref2#10682492045158632578.de31216813faa493761802feb6f997f2_4" ;
@ -172,11 +172,11 @@ digraph cfg {
"getPtr_ok_deref#15608473391071478730.49e56fac5bd82269c2093a9c1e438200_4" -> "getPtr_ok_deref#15608473391071478730.49e56fac5bd82269c2093a9c1e438200_3" ;
"getPtr_ok_deref#15608473391071478730.49e56fac5bd82269c2093a9c1e438200_5" [label="5: DeclStmt \n n$8=_fun___variable_initialization(&t:int*) assign_last [line 101, column 3]\n n$7=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 101, column 23]\n n$6=*&t:int* [line 101, column 23]\n EXIT_SCOPE(n$6,n$7,n$8); [line 101, column 23]\n " shape="box"]
"getPtr_ok_deref#15608473391071478730.49e56fac5bd82269c2093a9c1e438200_5" [label="5: DeclStmt \n n$7=_fun___variable_initialization(&t:int*) assign_last [line 101, column 3]\n n$6=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 101, column 23]\n EXIT_SCOPE(n$6,n$7); [line 101, column 23]\n " shape="box"]
"getPtr_ok_deref#15608473391071478730.49e56fac5bd82269c2093a9c1e438200_5" -> "getPtr_ok_deref#15608473391071478730.49e56fac5bd82269c2093a9c1e438200_4" ;
"getPtr_ok_deref#15608473391071478730.49e56fac5bd82269c2093a9c1e438200_6" [label="6: DeclStmt \n n$9=_fun___variable_initialization(&a:int) assign_last [line 100, column 3]\n *&a:int=0 [line 100, column 3]\n EXIT_SCOPE(n$9); [line 100, column 3]\n " shape="box"]
"getPtr_ok_deref#15608473391071478730.49e56fac5bd82269c2093a9c1e438200_6" [label="6: DeclStmt \n n$8=_fun___variable_initialization(&a:int) assign_last [line 100, column 3]\n *&a:int=0 [line 100, column 3]\n EXIT_SCOPE(n$8); [line 100, column 3]\n " shape="box"]
"getPtr_ok_deref#15608473391071478730.49e56fac5bd82269c2093a9c1e438200_6" -> "getPtr_ok_deref#15608473391071478730.49e56fac5bd82269c2093a9c1e438200_5" ;
@ -195,7 +195,7 @@ digraph cfg {
"getRef_null_deref1#4264296374417396044.654d24b6c4af017d90a5ceff83c121c2_4" -> "getRef_null_deref1#4264296374417396044.654d24b6c4af017d90a5ceff83c121c2_3" ;
"getRef_null_deref1#4264296374417396044.654d24b6c4af017d90a5ceff83c121c2_5" [label="5: DeclStmt \n n$8=_fun___variable_initialization(&t:int*) assign_last [line 126, column 3]\n n$7=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 126, column 23]\n n$6=*&t:int* [line 126, column 23]\n EXIT_SCOPE(n$6,n$7,n$8); [line 126, column 23]\n " shape="box"]
"getRef_null_deref1#4264296374417396044.654d24b6c4af017d90a5ceff83c121c2_5" [label="5: DeclStmt \n n$7=_fun___variable_initialization(&t:int*) assign_last [line 126, column 3]\n n$6=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 126, column 23]\n EXIT_SCOPE(n$6,n$7); [line 126, column 23]\n " shape="box"]
"getRef_null_deref1#4264296374417396044.654d24b6c4af017d90a5ceff83c121c2_5" -> "getRef_null_deref1#4264296374417396044.654d24b6c4af017d90a5ceff83c121c2_4" ;
@ -214,7 +214,7 @@ digraph cfg {
"getRef_null_deref2#4263471740696427019.45bed1239309132cabf29f4cdd81f3cc_4" -> "getRef_null_deref2#4263471740696427019.45bed1239309132cabf29f4cdd81f3cc_3" ;
"getRef_null_deref2#4263471740696427019.45bed1239309132cabf29f4cdd81f3cc_5" [label="5: DeclStmt \n n$8=_fun___variable_initialization(&t:int*) assign_last [line 132, column 3]\n n$7=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 132, column 23]\n n$6=*&t:int* [line 132, column 23]\n EXIT_SCOPE(n$6,n$7,n$8); [line 132, column 23]\n " shape="box"]
"getRef_null_deref2#4263471740696427019.45bed1239309132cabf29f4cdd81f3cc_5" [label="5: DeclStmt \n n$7=_fun___variable_initialization(&t:int*) assign_last [line 132, column 3]\n n$6=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 132, column 23]\n EXIT_SCOPE(n$6,n$7); [line 132, column 23]\n " shape="box"]
"getRef_null_deref2#4263471740696427019.45bed1239309132cabf29f4cdd81f3cc_5" -> "getRef_null_deref2#4263471740696427019.45bed1239309132cabf29f4cdd81f3cc_4" ;
@ -233,11 +233,11 @@ digraph cfg {
"getRef_ok_deref#10111201054364386601.e514c65ac6978a31376e6032d81b3d16_4" -> "getRef_ok_deref#10111201054364386601.e514c65ac6978a31376e6032d81b3d16_3" ;
"getRef_ok_deref#10111201054364386601.e514c65ac6978a31376e6032d81b3d16_5" [label="5: DeclStmt \n n$8=_fun___variable_initialization(&t:int*) assign_last [line 139, column 3]\n n$7=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 139, column 23]\n n$6=*&t:int* [line 139, column 23]\n EXIT_SCOPE(n$6,n$7,n$8); [line 139, column 23]\n " shape="box"]
"getRef_ok_deref#10111201054364386601.e514c65ac6978a31376e6032d81b3d16_5" [label="5: DeclStmt \n n$7=_fun___variable_initialization(&t:int*) assign_last [line 139, column 3]\n n$6=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 139, column 23]\n EXIT_SCOPE(n$6,n$7); [line 139, column 23]\n " shape="box"]
"getRef_ok_deref#10111201054364386601.e514c65ac6978a31376e6032d81b3d16_5" -> "getRef_ok_deref#10111201054364386601.e514c65ac6978a31376e6032d81b3d16_4" ;
"getRef_ok_deref#10111201054364386601.e514c65ac6978a31376e6032d81b3d16_6" [label="6: DeclStmt \n n$9=_fun___variable_initialization(&a:int) assign_last [line 138, column 3]\n *&a:int=0 [line 138, column 3]\n EXIT_SCOPE(n$9); [line 138, column 3]\n " shape="box"]
"getRef_ok_deref#10111201054364386601.e514c65ac6978a31376e6032d81b3d16_6" [label="6: DeclStmt \n n$8=_fun___variable_initialization(&a:int) assign_last [line 138, column 3]\n *&a:int=0 [line 138, column 3]\n EXIT_SCOPE(n$8); [line 138, column 3]\n " shape="box"]
"getRef_ok_deref#10111201054364386601.e514c65ac6978a31376e6032d81b3d16_6" -> "getRef_ok_deref#10111201054364386601.e514c65ac6978a31376e6032d81b3d16_5" ;
@ -256,7 +256,7 @@ digraph cfg {
"operator_star_null_deref1#14187169119337849630.74372e24230903d2d4cacecae74f498d_4" -> "operator_star_null_deref1#14187169119337849630.74372e24230903d2d4cacecae74f498d_3" ;
"operator_star_null_deref1#14187169119337849630.74372e24230903d2d4cacecae74f498d_5" [label="5: DeclStmt \n n$8=_fun___variable_initialization(&t:int*) assign_last [line 107, column 3]\n n$7=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 107, column 23]\n n$6=*&t:int* [line 107, column 23]\n EXIT_SCOPE(n$6,n$7,n$8); [line 107, column 23]\n " shape="box"]
"operator_star_null_deref1#14187169119337849630.74372e24230903d2d4cacecae74f498d_5" [label="5: DeclStmt \n n$7=_fun___variable_initialization(&t:int*) assign_last [line 107, column 3]\n n$6=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 107, column 23]\n EXIT_SCOPE(n$6,n$7); [line 107, column 23]\n " shape="box"]
"operator_star_null_deref1#14187169119337849630.74372e24230903d2d4cacecae74f498d_5" -> "operator_star_null_deref1#14187169119337849630.74372e24230903d2d4cacecae74f498d_4" ;
@ -275,7 +275,7 @@ digraph cfg {
"operator_star_null_deref2#14189968475942707161.6f6b808f2059b0f1bd8edd63f3e0c27b_4" -> "operator_star_null_deref2#14189968475942707161.6f6b808f2059b0f1bd8edd63f3e0c27b_3" ;
"operator_star_null_deref2#14189968475942707161.6f6b808f2059b0f1bd8edd63f3e0c27b_5" [label="5: DeclStmt \n n$8=_fun___variable_initialization(&t:int*) assign_last [line 113, column 3]\n n$7=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 113, column 23]\n n$6=*&t:int* [line 113, column 23]\n EXIT_SCOPE(n$6,n$7,n$8); [line 113, column 23]\n " shape="box"]
"operator_star_null_deref2#14189968475942707161.6f6b808f2059b0f1bd8edd63f3e0c27b_5" [label="5: DeclStmt \n n$7=_fun___variable_initialization(&t:int*) assign_last [line 113, column 3]\n n$6=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 113, column 23]\n EXIT_SCOPE(n$6,n$7); [line 113, column 23]\n " shape="box"]
"operator_star_null_deref2#14189968475942707161.6f6b808f2059b0f1bd8edd63f3e0c27b_5" -> "operator_star_null_deref2#14189968475942707161.6f6b808f2059b0f1bd8edd63f3e0c27b_4" ;
@ -294,7 +294,7 @@ digraph cfg {
"operator_star_ok_deref#11345277927099423171.138b78e88dab5887cd2f20f2590c779f_4" -> "operator_star_ok_deref#11345277927099423171.138b78e88dab5887cd2f20f2590c779f_3" ;
"operator_star_ok_deref#11345277927099423171.138b78e88dab5887cd2f20f2590c779f_5" [label="5: DeclStmt \n n$8=_fun___variable_initialization(&t:int*) assign_last [line 120, column 3]\n n$7=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 120, column 23]\n n$6=*&t:int* [line 120, column 23]\n EXIT_SCOPE(n$6,n$7,n$8); [line 120, column 23]\n " shape="box"]
"operator_star_ok_deref#11345277927099423171.138b78e88dab5887cd2f20f2590c779f_5" [label="5: DeclStmt \n n$7=_fun___variable_initialization(&t:int*) assign_last [line 120, column 3]\n n$6=_fun_TranslateAsPtr<int>_TranslateAsPtr(&t:int**,null:int*) [line 120, column 23]\n EXIT_SCOPE(n$6,n$7); [line 120, column 23]\n " shape="box"]
"operator_star_ok_deref#11345277927099423171.138b78e88dab5887cd2f20f2590c779f_5" -> "operator_star_ok_deref#11345277927099423171.138b78e88dab5887cd2f20f2590c779f_4" ;

Loading…
Cancel
Save