[dead stores] recognize lambdas with `auto` parameter

Summary:
When a lambda has an `auto` parameter, the inferred type of the parameter because part of the name.
Our heuristic for identifying lambda was checking if the lambda's name was exactly `operator()`, which won't catch this case.

Reviewed By: jvillard

Differential Revision: D5753323

fbshipit-source-id: 85ff75a
master
Sam Blackshear 7 years ago committed by Facebook Github Bot
parent 14fa4aa7d9
commit 4065b1d120

@ -66,7 +66,7 @@ let checker {Callbacks.tenv; summary; proc_desc} : Specs.summary =
in
let procname = Procdesc.get_proc_name proc_desc in
let is_cpp_lambda =
match Typ.Procname.get_method procname with "operator()" -> true | _ -> false
String.is_substring ~substring:"operator()" (Typ.Procname.get_method procname)
in
let is_captured_var pvar =
let pvar_name = Pvar.get_name pvar in

@ -122,6 +122,12 @@ void by_ref1_ok(int& ref) { ref = 7; }
void by_ref2_ok(int& ref) { ref++; }
int capture_by_ref3_ok() {
int x = 0;
[&](auto y) { x += y; }(3);
return x;
}
int plus_plus_ok() {
int x = 0;
return ++x;

@ -4,7 +4,7 @@ codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::dead_then_live_bad, 1,
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::easy_bad, 0, DEAD_STORE, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::init_capture_no_call_bad, 1, DEAD_STORE, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::init_capture_reassign_bad, 1, DEAD_STORE, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::lambda_bad::lambda_dead_stores.cpp:139:11_operator(), 1, DEAD_STORE, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::lambda_bad::lambda_dead_stores.cpp:145:11_operator(), 1, DEAD_STORE, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::plus_plus1_bad, 2, DEAD_STORE, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::plus_plus2_bad, 2, DEAD_STORE, [Write of unused value]
codetoanalyze/cpp/liveness/dead_stores.cpp, dead_stores::plus_plus3_bad, 2, DEAD_STORE, [Write of unused value]

Loading…
Cancel
Save