[clang] Thread Safety Analysis: Support passing scoped locks between functions with appropriate annotations (PR #110523)

Aaron Puchert via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 29 15:04:20 PST 2024


================
@@ -336,6 +336,40 @@ Improvements to Clang's diagnostics
   local variables passed to function calls using the ``[[clang::musttail]]``
   attribute.
 
+- The Thread Safety Analysis (#GH110523) now supports passing scoped capabilities into functions:
+  an attribute on the scoped capability parameter indicates both the expected associated capabilities and,
+  like in the case of attributes on the function declaration itself, their state before and after the call.
+
+  .. code-block:: c++
+
+    #include "mutex.h"
+
+    class MutexUnlocker {
+      Mutex* mu;
+
+    public:
+      MutexUnlocker(Mutex* m) RELEASE(m) : mu(m)  { mu->Unlock(); }
+      ~MutexUnlocker() ACQUIRE(mu) { mu->Lock(); }
+    };
----------------
aaronpuchert wrote:

This seems to be unused, did you add it by accident?

https://github.com/llvm/llvm-project/pull/110523


More information about the cfe-commits mailing list