From bc99e3b38d380199f8ed138f5166fb8162eb5a82 Mon Sep 17 00:00:00 2001 From: Nikos Gorogiannis Date: Wed, 28 Jul 2021 09:18:09 -0700 Subject: [PATCH] [concurrency][c++] don't generate errors on guards without mutex Summary: `std::unique_lock<...> bla()` is a valid call but which associates the guard object with no mutex. Silence the errors on such calls. Reviewed By: da319 Differential Revision: D29937496 fbshipit-source-id: 7600200db --- infer/src/absint/ConcurrencyModels.ml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/infer/src/absint/ConcurrencyModels.ml b/infer/src/absint/ConcurrencyModels.ml index 463ff9f13..495680e3d 100644 --- a/infer/src/absint/ConcurrencyModels.ml +++ b/infer/src/absint/ConcurrencyModels.ml @@ -33,12 +33,15 @@ let make_unlock = make_lock_action "release" (fun a -> Unlock a) let make_trylock = make_lock_action "conditionally acquire" (fun a -> LockedIfTrue a) let make_guard_construct procname = function + | [_guard] -> + (* constructor is called without a mutex *) + NoEffect | [guard; lock] -> GuardConstruct {guard; lock; acquire_now= true} | [guard; lock; _defer_lock] -> GuardConstruct {guard; lock; acquire_now= false} | actuals -> - L.internal_error "Cannot parse guard constructor call %a(%a)" Procname.pp procname + L.internal_error "Cannot parse guard constructor call %a(%a)@\n" Procname.pp procname (PrettyPrintable.pp_collection ~pp_item:HilExp.pp) actuals ; NoEffect @@ -48,7 +51,7 @@ let make_guard_action type_str action procname = function | [guard] -> action guard | actuals -> - L.internal_error "Cannot parse guard %s call %a(%a)" type_str Procname.pp procname + L.internal_error "Cannot parse guard %s call %a(%a)@\n" type_str Procname.pp procname (PrettyPrintable.pp_collection ~pp_item:HilExp.pp) actuals ; NoEffect @@ -148,8 +151,8 @@ end = struct let qname_str = QualifiedCppName.to_qual_string qname in match List.find lock_models ~f:(fun mdl -> String.equal qname_str mdl.classname) with | None -> - L.internal_error "is_recursive_lock_type: Could not find lock type %a@." QualifiedCppName.pp - qname ; + L.internal_error "is_recursive_lock_type: Could not find lock type %a@\n" + QualifiedCppName.pp qname ; true | Some mdl -> mdl.recursive