Do not show internal SIL variable name in the error message of temporary address escape

Summary: Title

Reviewed By: jvillard

Differential Revision: D5669502

fbshipit-source-id: 295d485
master
Daiva Naudziuniene 8 years ago committed by Facebook Github Bot
parent 673f2b6917
commit 29aea2d61d

@ -913,7 +913,8 @@ let desc_inherently_dangerous_function proc_name =
Tags.update tags Tags.value proc_name_str ;
{no_desc with descriptions= [MF.monospaced_to_string proc_name_str]; tags= !tags}
let desc_stack_variable_address_escape expr_str addr_dexp_str loc =
let desc_stack_variable_address_escape pvar addr_dexp_str loc =
let expr_str = Pvar.to_string pvar in
let tags = Tags.create () in
Tags.update tags Tags.value expr_str ;
let escape_to_str =
@ -924,9 +925,12 @@ let desc_stack_variable_address_escape expr_str addr_dexp_str loc =
| None
-> ""
in
let variable_str =
if Pvar.is_frontend_tmp pvar then "temporary"
else Format.asprintf "stack variable %a" MF.pp_monospaced expr_str
in
let description =
Format.asprintf "Address of stack variable %a escapes %s%s" MF.pp_monospaced expr_str
escape_to_str (at_line tags loc)
Format.asprintf "Address of %s escapes %s%s" variable_str escape_to_str (at_line tags loc)
in
{no_desc with descriptions= [description]; tags= !tags}

@ -210,7 +210,7 @@ val desc_return_statement_missing : Location.t -> error_desc
val desc_return_value_ignored : Typ.Procname.t -> Location.t -> error_desc
val desc_stack_variable_address_escape : string -> string option -> Location.t -> error_desc
val desc_stack_variable_address_escape : Pvar.t -> string option -> Location.t -> error_desc
val desc_skip_function : Typ.Procname.t -> error_desc

@ -1167,7 +1167,7 @@ let explain_stack_variable_address_escape loc pvar addr_dexp_opt =
| None
-> None
in
Localise.desc_stack_variable_address_escape (Pvar.to_string pvar) addr_dexp_str loc
Localise.desc_stack_variable_address_escape pvar addr_dexp_str loc
(** explain unary minus applied to unsigned expression *)
let explain_unary_minus_applied_to_unsigned_expression tenv exp typ node loc =

@ -172,6 +172,7 @@ 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, [start of procedure weak_ptr_observers::use_count_after_reset_bad(),Condition is true,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, [start of procedure weak_ptr_observers::use_count_empty_bad(),Condition is true,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:62:7_operator(), 2, Cannot_star, [start of procedure operator(),Condition is true]
codetoanalyze/cpp/errors/stack_escape/basic.cpp, B_return_ref, 0, STACK_VARIABLE_ADDRESS_ESCAPE, [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, [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, [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, [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]

@ -6,6 +6,7 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
int* basic_escape_local_bad() {
int a;
return &a;
@ -16,7 +17,16 @@ int* basic_escape_param_bad(int a) { return &a; }
struct EscapeTest {
int x;
};
int* escape_local_struct_member_bad() {
EscapeTest esc;
return &(esc.x);
}
struct A {
A() {}
};
struct B {
const A& return_ref() { return A(); }
};

Loading…
Cancel
Save