[stack variable address escape] Do not report on temporary variables

Summary: Errors that include temporary variables are difficult to understand. Do not report stack variable address escape on temporary variables.

Reviewed By: jvillard

Differential Revision: D9117517

fbshipit-source-id: 9ebd75ecc
master
Daiva Naudziuniene 6 years ago committed by Facebook Github Bot
parent c7cbeee093
commit ba4f33089e

@ -518,11 +518,12 @@ let remove_locals_formals_and_check tenv proc_cfg p =
let pname = Procdesc.get_proc_name pdesc in let pname = Procdesc.get_proc_name pdesc in
let pvars, p' = PropUtil.remove_locals_formals tenv pdesc p in let pvars, p' = PropUtil.remove_locals_formals tenv pdesc p in
let check_pvar pvar = let check_pvar pvar =
let loc = ProcCfg.Exceptional.Node.loc (ProcCfg.Exceptional.exit_node proc_cfg) in if not (Pvar.is_frontend_tmp pvar) then
let dexp_opt, _ = Errdesc.vpath_find tenv p (Exp.Lvar pvar) in let loc = ProcCfg.Exceptional.Node.loc (ProcCfg.Exceptional.exit_node proc_cfg) in
let desc = Errdesc.explain_stack_variable_address_escape loc pvar dexp_opt in let dexp_opt, _ = Errdesc.vpath_find tenv p (Exp.Lvar pvar) in
let exn = Exceptions.Stack_variable_address_escape (desc, __POS__) in let desc = Errdesc.explain_stack_variable_address_escape loc pvar dexp_opt in
Reporting.log_warning_deprecated pname exn let exn = Exceptions.Stack_variable_address_escape (desc, __POS__) in
Reporting.log_warning_deprecated pname exn
in in
List.iter ~f:check_pvar pvars ; p' List.iter ~f:check_pvar pvars ; p'

@ -161,7 +161,6 @@ codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_observers::shared_stil
codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_observers::use_count_after_reset_bad, 5, use_count after weak_ptr reset is 0, no_bucket, ERROR, [start of procedure weak_ptr_observers::use_count_after_reset_bad(),Taking true branch,return from a call to weak_ptr_observers::use_count_after_reset_bad] codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_observers::use_count_after_reset_bad, 5, use_count after weak_ptr reset is 0, no_bucket, ERROR, [start of procedure weak_ptr_observers::use_count_after_reset_bad(),Taking true branch,return from a call to weak_ptr_observers::use_count_after_reset_bad]
codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_observers::use_count_empty_bad, 5, use_count on empty weak_ptr is 0, no_bucket, ERROR, [start of procedure weak_ptr_observers::use_count_empty_bad(),Taking true branch,return from a call to weak_ptr_observers::use_count_empty_bad] codetoanalyze/cpp/errors/smart_ptr/weak_ptr.cpp, weak_ptr_observers::use_count_empty_bad, 5, use_count on empty weak_ptr is 0, no_bucket, ERROR, [start of procedure weak_ptr_observers::use_count_empty_bad(),Taking true branch,return from a call to weak_ptr_observers::use_count_empty_bad]
codetoanalyze/cpp/errors/smart_ptr/weak_ptr_compil.cpp, weak_ptr_lock_repro_large::RDC::create::lambda_smart_ptr_weak_ptr_compil.cpp:59:13_operator(), 2, Cannot_star, no_bucket, ERROR, [start of procedure operator(),Taking true branch,Skipping function: method has no implementation] codetoanalyze/cpp/errors/smart_ptr/weak_ptr_compil.cpp, weak_ptr_lock_repro_large::RDC::create::lambda_smart_ptr_weak_ptr_compil.cpp:59:13_operator(), 2, Cannot_star, no_bucket, ERROR, [start of procedure operator(),Taking true branch,Skipping function: method has no implementation]
codetoanalyze/cpp/errors/stack_escape/basic.cpp, B_return_ref, 0, STACK_VARIABLE_ADDRESS_ESCAPE, no_bucket, ERROR, [start of procedure return_ref,start of procedure A,return from a call to A_A,return from a call to B_return_ref]
codetoanalyze/cpp/errors/stack_escape/basic.cpp, basic_escape_local_bad, 3, STACK_VARIABLE_ADDRESS_ESCAPE, no_bucket, ERROR, [start of procedure basic_escape_local_bad(),return from a call to basic_escape_local_bad] codetoanalyze/cpp/errors/stack_escape/basic.cpp, basic_escape_local_bad, 3, STACK_VARIABLE_ADDRESS_ESCAPE, no_bucket, ERROR, [start of procedure basic_escape_local_bad(),return from a call to basic_escape_local_bad]
codetoanalyze/cpp/errors/stack_escape/basic.cpp, basic_escape_param_bad, 0, STACK_VARIABLE_ADDRESS_ESCAPE, no_bucket, ERROR, [start of procedure basic_escape_param_bad(),return from a call to basic_escape_param_bad] codetoanalyze/cpp/errors/stack_escape/basic.cpp, basic_escape_param_bad, 0, STACK_VARIABLE_ADDRESS_ESCAPE, no_bucket, ERROR, [start of procedure basic_escape_param_bad(),return from a call to basic_escape_param_bad]
codetoanalyze/cpp/errors/stack_escape/basic.cpp, escape_local_struct_member_bad, 3, STACK_VARIABLE_ADDRESS_ESCAPE, no_bucket, ERROR, [start of procedure escape_local_struct_member_bad(),start of procedure EscapeTest,return from a call to EscapeTest_EscapeTest,return from a call to escape_local_struct_member_bad] codetoanalyze/cpp/errors/stack_escape/basic.cpp, escape_local_struct_member_bad, 3, STACK_VARIABLE_ADDRESS_ESCAPE, no_bucket, ERROR, [start of procedure escape_local_struct_member_bad(),start of procedure EscapeTest,return from a call to EscapeTest_EscapeTest,return from a call to escape_local_struct_member_bad]

@ -26,5 +26,5 @@ struct A {
}; };
struct B { struct B {
const A& return_ref() { return A(); } const A& FN_return_ref_bad() { return A(); }
}; };

Loading…
Cancel
Save