From 4d1abb0eeb4db1583c6f25a78aba8361edd91c07 Mon Sep 17 00:00:00 2001 From: Daiva Naudziuniene Date: Wed, 18 Jul 2018 03:36:01 -0700 Subject: [PATCH] [ownership] Do not report on temporary variables. Reviewed By: mbouaziz, ngorogiannis Differential Revision: D8874806 fbshipit-source-id: a977f4224 --- infer/src/checkers/Ownership.ml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/infer/src/checkers/Ownership.ml b/infer/src/checkers/Ownership.ml index ab267879e..0aef233a9 100644 --- a/infer/src/checkers/Ownership.ml +++ b/infer/src/checkers/Ownership.ml @@ -109,15 +109,16 @@ module Domain = struct let report_use_after_lifetime (var, _) ~use_loc ~invalidated_loc summary = - let message = - F.asprintf "Variable %a is used at line %a after its lifetime ended at %a" Var.pp var - Location.pp use_loc Location.pp invalidated_loc - in - let ltr = - [ Errlog.make_trace_element 0 invalidated_loc "End of variable lifetime" [] - ; Errlog.make_trace_element 0 use_loc "Use of invalid variable" [] ] - in - report message use_loc ltr summary + if Var.appears_in_source_code var then + let message = + F.asprintf "Variable %a is used at line %a after its lifetime ended at %a" Var.pp var + Location.pp use_loc Location.pp invalidated_loc + in + let ltr = + [ Errlog.make_trace_element 0 invalidated_loc "End of variable lifetime" [] + ; Errlog.make_trace_element 0 use_loc "Use of invalid variable" [] ] + in + report message use_loc ltr summary (* complain if we do not have the right capability to access [var] *)