[IR] utility function for detecting when Var appears in source code

Summary:
We frequently want to treat such vars differently than true program variables.

Used in only one place now, but will be used in a successor.

Reviewed By: mbouaziz, jvillard

Differential Revision: D7067882

fbshipit-source-id: 90e0348
master
Sam Blackshear 7 years ago committed by Facebook Github Bot
parent 56db965738
commit ddc354df39

@ -29,6 +29,12 @@ let is_return = function ProgramVar pvar -> Pvar.is_return pvar | LogicalVar _ -
let is_footprint = function ProgramVar _ -> false | LogicalVar id -> Ident.is_footprint id
let appears_in_source_code = function
| LogicalVar _ ->
false
| ProgramVar pvar ->
not (Pvar.is_frontend_tmp pvar)
let pp fmt = function ProgramVar pv -> Pvar.pp Pp.text fmt pv | LogicalVar id -> Ident.pp fmt id
let get_footprint_index t =

@ -30,6 +30,10 @@ val is_return : t -> bool
val is_footprint : t -> bool
val appears_in_source_code : t -> bool
(** return true if this variable appears in source code (i.e., is not a LogicalVar or a
frontend-generated ProgramVar) *)
val get_footprint_index : t -> int option
val pp : Format.formatter -> t -> unit

@ -1014,12 +1014,8 @@ let report_thread_safety_violation tenv pdesc ~make_description ~report_kind acc
let is_full_trace = TraceElem.is_direct final_sink in
let is_pvar_base initial_sink =
let access_path = Access.get_access_path (PathDomain.Sink.kind initial_sink) in
Option.value_map ~default:false access_path ~f:(fun ap ->
match ap with
| (Var.LogicalVar _, _), _ ->
false
| (Var.ProgramVar pvar, _), _ ->
not (Pvar.is_frontend_tmp pvar) )
Option.value_map ~default:false access_path ~f:(fun ((var, _), _) ->
Var.appears_in_source_code var )
in
(* Traces can be truncated due to limitations of our Buck integration. If we have a truncated
trace, it's probably going to be too confusing to be actionable. Skip it.

Loading…
Cancel
Save