[PATCH] D102026: Thread safety analysis: Allow exlusive/shared joins for managed and asserted capabilities

Delesley Hutchins via cfe-commits cfe-commits at lists.llvm.org
Thu May 27 10:18:51 PDT 2021


> - The `assert_capability` attribute is also a bit of a backdoor. Instead
> of statically propagating through the code that a mutex is held, we can
> just get that fact "out of thin air".
>

Assert_capability is not a back door.  It is supposed to be used only on a
function which does a run-time check:  if (!mu_.is_locked()) fail().  This
sort of thing is very common in static analysis.  There are places in the
code where you cannot statically prove that a property holds at
compile-time, so you insert a run-time check into the code, and then
propagate that property to the static analysis on the branch where the
check succeeds.

Of course, you can use assert_capability to create a back door, by putting
it on a function that doesn't actually check anything, just like you can
declare random methods to be lock_functions, even if they don't lock
anything.  :-)

  -DeLesley

-- 
DeLesley Hutchins | Software Engineer | delesley at google.com | 505-206-0315
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210527/11a99fcc/attachment-0001.html>


More information about the cfe-commits mailing list