clangsa: Fix lock_guard annotations for libc++ (#64085)
libc++ in macOS SDK 26 and later marks std::lock_guard scoped_lockable
whenever Clang supports the attribute. The
acquire_capability(jl_notsafepoint) that julia_locks.h adds to its
constructor then becomes part of the guard, whose destructor releases
it, and the release_capability(jl_notsafepoint) added to that
destructor releases it a second time. Every lock_guard<std::mutex>
scope exit thus fails clang-safety with "releasing notsafepoint
'jl_notsafepoint' that was not held", in codegen.cpp, jitlayers.cpp
and aotcompile.cpp. libstdc++ does not annotate lock_guard, so Linux
is unaffected.
Annotate only the constructor when libc++ defines
_LIBCPP_SCOPED_LOCKABLE. Older libc++ annotates only on opt-in and
lacks that macro.
Assisted-by: Claude Code (Opus 5.5)
(cherry picked from commit 782787900acd90929982db54111169d06a94b1dc)