From 94aae8713ebd307e5c17729b497df8b7a19e5cc4 Mon Sep 17 00:00:00 2001 From: Daiva Naudziuniene Date: Mon, 16 Apr 2018 04:54:55 -0700 Subject: [PATCH] [biabduction] Fix lookup of abduced expression Summary: Currently when we look for already abduced expression and find an assertion [exp|->strexp:typexp], we use typexp rather than strexp. Reviewed By: sblackshear Differential Revision: D7617193 fbshipit-source-id: c089720 --- infer/src/biabduction/SymExec.ml | 2 +- infer/tests/codetoanalyze/cpp/conflicts/issues.exp | 2 +- infer/tests/codetoanalyze/cpp/conflicts/test.cpp | 2 +- infer/tests/codetoanalyze/cpp/errors/issues.exp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/infer/src/biabduction/SymExec.ml b/infer/src/biabduction/SymExec.ml index a10bf10a4..d890446ac 100644 --- a/infer/src/biabduction/SymExec.ml +++ b/infer/src/biabduction/SymExec.ml @@ -885,7 +885,7 @@ let add_constraints_on_retval tenv pdesc prop ret_exp ~has_nonnull_annot typ cal List.find_map ~f:(fun hpred -> match hpred with - | Sil.Hpointsto (Exp.Lvar pv, _, exp) when Pvar.equal pv abduced_ret_pv -> + | Sil.Hpointsto (Exp.Lvar pv, Sil.Eexp (exp, _), _) when Pvar.equal pv abduced_ret_pv -> Some exp | _ -> None ) diff --git a/infer/tests/codetoanalyze/cpp/conflicts/issues.exp b/infer/tests/codetoanalyze/cpp/conflicts/issues.exp index e973f5662..6fff43573 100644 --- a/infer/tests/codetoanalyze/cpp/conflicts/issues.exp +++ b/infer/tests/codetoanalyze/cpp/conflicts/issues.exp @@ -1,3 +1,3 @@ codetoanalyze/cpp/conflicts/test.cpp, test1_bad, 2, NULL_DEREFERENCE, ERROR, [start of procedure test1_bad(),Skipping nullableMethod(): function or method not found] codetoanalyze/cpp/conflicts/test.cpp, test2_bad, 1, NULLABLE_DEREFERENCE, ERROR, [dereferencing the return of nullableMethod(),definition of nullableMethod] -codetoanalyze/cpp/conflicts/test.cpp, test3_bad, 5, NULLABLE_DEREFERENCE, ERROR, [dereference of p,assignment of the nullable value,definition of nullableMethod] +codetoanalyze/cpp/conflicts/test.cpp, test3_bad, 5, NULL_DEREFERENCE, ERROR, [start of procedure test3_bad(),Skipping nullableMethod(): function or method not found,Condition is true,Skipping nullableMethod(): function or method not found,Condition is false] diff --git a/infer/tests/codetoanalyze/cpp/conflicts/test.cpp b/infer/tests/codetoanalyze/cpp/conflicts/test.cpp index 810d4caa8..5af4f91c0 100644 --- a/infer/tests/codetoanalyze/cpp/conflicts/test.cpp +++ b/infer/tests/codetoanalyze/cpp/conflicts/test.cpp @@ -30,5 +30,5 @@ int test3_bad() { for (int i = 0; i < 10; i++) { p = nullableMethod(); } - return p->get(); // not reported by the biabduction analysis + return p->get(); // reported by the biabduction analysis } diff --git a/infer/tests/codetoanalyze/cpp/errors/issues.exp b/infer/tests/codetoanalyze/cpp/errors/issues.exp index f78a3b945..e9fda98c2 100644 --- a/infer/tests/codetoanalyze/cpp/errors/issues.exp +++ b/infer/tests/codetoanalyze/cpp/errors/issues.exp @@ -198,8 +198,8 @@ codetoanalyze/cpp/errors/types/typeid_expr.cpp, template_type_id_person, 2, MEMO codetoanalyze/cpp/errors/types/typeid_expr.cpp, template_type_id_person, 5, DIVIDE_BY_ZERO, ERROR, [start of procedure template_type_id_person(),start of procedure Person,return from a call to Person_Person,Condition is false] codetoanalyze/cpp/errors/types/typeid_expr.cpp, template_typeid, 2, MEMORY_LEAK, ERROR, [start of procedure template_typeid(),start of procedure Person,return from a call to Person_Person,start of procedure Person,return from a call to Person_Person,start of procedure ~Person,start of procedure __infer_inner_destructor_~Person,return from a call to Person___infer_inner_destructor_~Person,return from a call to Person_~Person] codetoanalyze/cpp/errors/use_after_free/foreach_map.cpp, use_after_free::Basic_test_double_delete_bad, 3, USE_AFTER_FREE, ERROR, [start of procedure test_double_delete_bad,Skipping Y: function or method not found] -codetoanalyze/cpp/errors/use_after_free/foreach_map.cpp, use_after_free::Basic_test_for_map_delete_ok_FP, 2, USE_AFTER_FREE, ERROR, [start of procedure test_for_map_delete_ok_FP,Condition is true,Skipping operator*: function or method not found,Condition is true,Skipping operator*: function or method not found,Condition is true,Skipping operator*: function or method not found] -codetoanalyze/cpp/errors/use_after_free/foreach_map.cpp, use_after_free::Basic_test_for_umap_delete_ok_FP, 2, USE_AFTER_FREE, ERROR, [start of procedure test_for_umap_delete_ok_FP,Condition is true,Skipping operator*: function or method not found,Condition is true,Skipping operator*: function or method not found,Condition is true,Skipping operator*: function or method not found] +codetoanalyze/cpp/errors/use_after_free/foreach_map.cpp, use_after_free::Basic_test_for_map_delete_ok_FP, 2, USE_AFTER_FREE, ERROR, [start of procedure test_for_map_delete_ok_FP,Condition is true,Skipping operator*: function or method not found,Condition is true,Skipping operator*: function or method not found] +codetoanalyze/cpp/errors/use_after_free/foreach_map.cpp, use_after_free::Basic_test_for_umap_delete_ok_FP, 2, USE_AFTER_FREE, ERROR, [start of procedure test_for_umap_delete_ok_FP,Condition is true,Skipping operator*: function or method not found,Condition is true,Skipping operator*: function or method not found] codetoanalyze/cpp/errors/vector/access_field_later.cpp, getIntPtr, 2, EMPTY_VECTOR_ACCESS, ERROR, [start of procedure getIntPtr()] codetoanalyze/cpp/errors/vector/access_field_later.cpp, getWithCopy, 2, EMPTY_VECTOR_ACCESS, ERROR, [start of procedure getWithCopy()] codetoanalyze/cpp/errors/vector/access_field_later.cpp, getWithCopyPtr, 2, EMPTY_VECTOR_ACCESS, ERROR, [start of procedure getWithCopyPtr()]