[infer][scheduler] always return None when the method is already being analyzed

Summary: This is to make sure than the analysis produces the same results independently from the order in which the members of a call cycle are analyzed.

Reviewed By: sblackshear, mbouaziz

Differential Revision: D6881971

fbshipit-source-id: 23872e1
master
Jeremy Dubreil 7 years ago committed by Facebook Github Bot
parent 56872d8126
commit b4b901c725

@ -169,37 +169,41 @@ let run_proc_analysis analyze_proc ~caller_pdesc callee_pdesc =
let analyze_proc_desc ?caller_pdesc callee_pdesc =
let cache = Lazy.force cached_results in
let callee_pname = Procdesc.get_proc_name callee_pdesc in
try Typ.Procname.Hash.find cache callee_pname with Not_found ->
let summary_option =
let callbacks = Option.value_exn !callbacks_ref in
let proc_attributes = Procdesc.get_attributes callee_pdesc in
if should_be_analyzed callee_pname proc_attributes then
Some (run_proc_analysis callbacks.analyze_ondemand ~caller_pdesc callee_pdesc)
else Specs.get_summary callee_pname
in
if not (is_active callee_pname) then Typ.Procname.Hash.add cache callee_pname summary_option ;
summary_option
if is_active callee_pname then None
else
let cache = Lazy.force cached_results in
try Typ.Procname.Hash.find cache callee_pname with Not_found ->
let summary_option =
let callbacks = Option.value_exn !callbacks_ref in
let proc_attributes = Procdesc.get_attributes callee_pdesc in
if should_be_analyzed callee_pname proc_attributes then
Some (run_proc_analysis callbacks.analyze_ondemand ~caller_pdesc callee_pdesc)
else Specs.get_summary callee_pname
in
Typ.Procname.Hash.add cache callee_pname summary_option ;
summary_option
(** analyze_proc_name curr_pdesc proc_name performs an on-demand analysis of proc_name triggered
during the analysis of curr_pname *)
let analyze_proc_name ?caller_pdesc callee_pname =
let cache = Lazy.force cached_results in
try Typ.Procname.Hash.find cache callee_pname with Not_found ->
let summary_option =
let callbacks = Option.value_exn !callbacks_ref in
if procedure_should_be_analyzed callee_pname then
match callbacks.get_proc_desc callee_pname with
| Some callee_pdesc ->
analyze_proc_desc ?caller_pdesc callee_pdesc
| None ->
Specs.get_summary callee_pname
else Specs.get_summary callee_pname
in
if not (is_active callee_pname) then Typ.Procname.Hash.add cache callee_pname summary_option ;
summary_option
if is_active callee_pname then None
else
let cache = Lazy.force cached_results in
try Typ.Procname.Hash.find cache callee_pname with Not_found ->
let summary_option =
let callbacks = Option.value_exn !callbacks_ref in
if procedure_should_be_analyzed callee_pname then
match callbacks.get_proc_desc callee_pname with
| Some callee_pdesc ->
analyze_proc_desc ?caller_pdesc callee_pdesc
| None ->
Specs.get_summary callee_pname
else Specs.get_summary callee_pname
in
Typ.Procname.Hash.add cache callee_pname summary_option ;
summary_option
(** Find a proc desc for the procedure, perhaps loading it from disk. *)

@ -68,7 +68,6 @@ codetoanalyze/cpp/errors/npe/npe_added_to_b1.cpp, npe_added_to_b1::causes_npe, 2
codetoanalyze/cpp/errors/npe/npe_added_to_b1.cpp, npe_added_to_b1::causes_npe_person, 2, NULL_DEREFERENCE, [start of procedure npe_added_to_b1::causes_npe_person(),start of procedure Person,return from a call to npe_added_to_b1::Person_Person,start of procedure npe_added_to_b1::deref_person()]
codetoanalyze/cpp/errors/npe/null_returned_by_method.cpp, testNullDeref, 3, NULL_DEREFERENCE, [start of procedure testNullDeref(),Condition is true,start of procedure getNull,return from a call to XFactory_getNull]
codetoanalyze/cpp/errors/npe/object_deref.cpp, object_deref::derefNullField, 2, NULL_DEREFERENCE, [start of procedure object_deref::derefNullField(),start of procedure object_deref::getNull(),return from a call to object_deref::getNull]
codetoanalyze/cpp/errors/npe/recursive_call.cpp, recursive_call::test_rec2_ok_FP, 2, PRECONDITION_NOT_MET, [start of procedure recursive_call::test_rec2_ok_FP(),start of procedure F,return from a call to recursive_call::F_F,start of procedure F,return from a call to recursive_call::F_F]
codetoanalyze/cpp/errors/npe/skip_function_with_const_formals.cpp, FP_const_skip2_then_split_case_ok, 5, MEMORY_LEAK, [start of procedure FP_const_skip2_then_split_case_ok(),Skipping skip_const2(): function or method not found,start of procedure test_pointer(),Condition is true,return from a call to test_pointer]
codetoanalyze/cpp/errors/npe/skip_function_with_const_formals.cpp, FP_const_skip_then_split_case_ok, 6, MEMORY_LEAK, [start of procedure FP_const_skip_then_split_case_ok(),Skipping skip_const(): function or method not found,start of procedure test_pointer(),Condition is true,return from a call to test_pointer]
codetoanalyze/cpp/errors/npe/skip_function_with_const_formals.cpp, FP_typedef_skip_then_split_case_ok, 2, MEMORY_LEAK, [start of procedure FP_typedef_skip_then_split_case_ok(),Skipping skip_typedef(): function or method not found]

@ -44,9 +44,9 @@ A* rec2(F f, A* a = nullptr) {
return a->getptr();
}
int test_rec2_ok_FP() {
int test_rec2_ok() {
F f;
return rec2(f)->f; // PRECONDITION_NOT_MET
return rec2(f)->f;
}
} // namespace recursive_call

Loading…
Cancel
Save