diff --git a/infer/src/clang/cTrans.ml b/infer/src/clang/cTrans.ml index 5dffc3cc3..59a09fd11 100644 --- a/infer/src/clang/cTrans.ml +++ b/infer/src/clang/cTrans.ml @@ -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 = diff --git a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main.cpp.dot b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main.cpp.dot index e074a283b..08ab4f295 100644 --- a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main.cpp.dot +++ b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main.cpp.dot @@ -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_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_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#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_3" -> "shared_ptr#shared_ptr#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_2" ; -"shared_ptr#shared_ptr#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_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#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_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#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_4" -> "shared_ptr#shared_ptr#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_3" ; diff --git a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_root.cpp.dot b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_root.cpp.dot index e074a283b..08ab4f295 100644 --- a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_root.cpp.dot +++ b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_root.cpp.dot @@ -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_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_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#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_3" -> "shared_ptr#shared_ptr#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_2" ; -"shared_ptr#shared_ptr#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_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#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_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#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_4" -> "shared_ptr#shared_ptr#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_3" ; diff --git a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_symlink.cpp.dot b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_symlink.cpp.dot index e074a283b..08ab4f295 100644 --- a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_symlink.cpp.dot +++ b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_default_symlink.cpp.dot @@ -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_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_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#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_3" -> "shared_ptr#shared_ptr#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_2" ; -"shared_ptr#shared_ptr#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_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#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_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#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_4" -> "shared_ptr#shared_ptr#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_3" ; diff --git a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_symlink.cpp.dot b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_symlink.cpp.dot index e074a283b..08ab4f295 100644 --- a/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_symlink.cpp.dot +++ b/infer/tests/build_systems/codetoanalyze/clang_translation/src/main_symlink.cpp.dot @@ -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_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_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#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_3" -> "shared_ptr#shared_ptr#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_2" ; -"shared_ptr#shared_ptr#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_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#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_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#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_4" -> "shared_ptr#shared_ptr#std#{8741815665871862164|constexpr}.f88ab7f65e0cffeda975c68f431824d1_3" ; diff --git a/infer/tests/codetoanalyze/cpp/errors/issues.exp b/infer/tests/codetoanalyze/cpp/errors/issues.exp index 337f85dc6..1bc68d49c 100644 --- a/infer/tests/codetoanalyze/cpp/errors/issues.exp +++ b/infer/tests/codetoanalyze/cpp/errors/issues.exp @@ -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] diff --git a/infer/tests/codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp b/infer/tests/codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp index 29369dcc2..cb1a49c1e 100644 --- a/infer/tests/codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp +++ b/infer/tests/codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp @@ -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(&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(&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(&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(&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(&v); auto s = safeGet(fromSharedDerivedAssign(b)); b->f1 = nullptr; diff --git a/infer/tests/codetoanalyze/cpp/shared/attributes/annotate.cpp.dot b/infer/tests/codetoanalyze/cpp/shared/attributes/annotate.cpp.dot index fac3f89e5..a45db1a0e 100644 --- a/infer/tests/codetoanalyze/cpp/shared/attributes/annotate.cpp.dot +++ b/infer/tests/codetoanalyze/cpp/shared/attributes/annotate.cpp.dot @@ -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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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_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" ;