[thread-safety][c++] Do not record accesses to static locals

Summary:
The clang frontend translates static locals incorrectly, in the sense
that the initializer is executed many times instead of once. This
leads to false alarms in the concurrency analysis. This diff
suppresses these by ignoring accesses to static locals.

Reviewed By: sblackshear

Differential Revision: D6182644

fbshipit-source-id: d8ca4c0
master
Josh Berdine 7 years ago committed by Facebook Github Bot
parent 149deb97ed
commit c2a67bb300

@ -375,6 +375,9 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
| _ -> | _ ->
false false
in in
let is_static_access ((base: Var.t), _) =
match base with ProgramVar pvar -> Pvar.is_static_local pvar | _ -> false
in
let rec add_field_accesses pre prefix_path access_acc = function let rec add_field_accesses pre prefix_path access_acc = function
| [] -> | [] ->
access_acc access_acc
@ -394,7 +397,9 @@ module TransferFunctions (CFG : ProcCfg.S) = struct
in in
let add_access_ acc (base, accesses) = let add_access_ acc (base, accesses) =
let base_access_path = (base, []) in let base_access_path = (base, []) in
if List.is_empty accesses || OwnershipDomain.is_owned base_access_path ownership then acc if List.is_empty accesses || OwnershipDomain.is_owned base_access_path ownership
|| is_static_access base
then acc
else else
let pre = let pre =
match AccessPrecondition.make locks threads proc_data.pdesc with match AccessPrecondition.make locks threads proc_data.pdesc with
@ -1908,3 +1913,4 @@ let file_analysis {Callbacks.procedures} =
else (module MayAliasQuotientedAccessListMap) ) else (module MayAliasQuotientedAccessListMap) )
class_env)) class_env))
(aggregate_by_class procedures) (aggregate_by_class procedures)

Loading…
Cancel
Save