[clang] Thread Safety Analysis: Support attributes on function pointers (PR #191187)

Marco Elver via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 29 06:41:55 PDT 2026


================
@@ -300,6 +300,12 @@ Attribute Changes in Clang
   sound because any writer must hold all capabilities, so holding any one
   prevents concurrent writes.
 
+- :doc:`ThreadSafetyAnalysis` attributes like ``acquire_capability``,
+  ``release_capability``, ``requires_capability``, ``locks_excluded``,
+  ``try_acquire_capability``, and ``assert_capability`` can now be applied to
+  function pointer variables and fields.  The analysis checks calls through
----------------
melver wrote:

Neither is supported for now. The release notes and user-manual section now explicitly list pointers-to-member functions, blocks, and wrappers as out-of-scope for now.

With large C codebases wanting to use -Wthread-safety, it's clear that plain function pointers have been the biggest gap.

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


More information about the cfe-commits mailing list