@@ -320,7 +320,7 @@ public:
320320};
321321
322322template <class _L0 , class _L1 >
323- _LIBCPP_HIDE_FROM_ABI int try_lock (_L0& __l0, _L1& __l1) {
323+ _LIBCPP_NO_THREAD_SAFETY_ANALYSIS _LIBCPP_HIDE_FROM_ABI int try_lock (_L0& __l0, _L1& __l1) {
324324 unique_lock<_L0> __u0 (__l0, try_to_lock_t ());
325325 if (__u0.owns_lock ()) {
326326 if (__l1.try_lock ()) {
@@ -335,7 +335,7 @@ _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1) {
335335# ifndef _LIBCPP_CXX03_LANG
336336
337337template <class _L0 , class _L1 , class _L2 , class ... _L3>
338- _LIBCPP_HIDE_FROM_ABI int try_lock (_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
338+ _LIBCPP_NO_THREAD_SAFETY_ANALYSIS _LIBCPP_HIDE_FROM_ABI int try_lock (_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
339339 int __r = 0 ;
340340 unique_lock<_L0> __u0 (__l0, try_to_lock);
341341 if (__u0.owns_lock ()) {
@@ -350,8 +350,11 @@ _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3
350350
351351# endif // _LIBCPP_CXX03_LANG
352352
353+ // We're using unique_lock to implement the functions, which thread annotations don't support. So we have to disable
354+ // the analysis inside the function.
353355template <class _L0 , class _L1 >
354- _LIBCPP_HIDE_FROM_ABI void lock (_L0& __l0, _L1& __l1) {
356+ _LIBCPP_NO_THREAD_SAFETY_ANALYSIS _LIBCPP_HIDE_FROM_ABI void lock (_L0& __l0, _L1& __l1)
357+ _LIBCPP_ACQUIRE_CAPABILITY(__l0, __l1) {
355358 while (true ) {
356359 {
357360 unique_lock<_L0> __u0 (__l0);
@@ -375,7 +378,7 @@ _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1) {
375378# ifndef _LIBCPP_CXX03_LANG
376379
377380template <class _L0 , class _L1 , class _L2 , class ... _L3>
378- void __lock_first (int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
381+ _LIBCPP_NO_THREAD_SAFETY_ANALYSIS void __lock_first (int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
379382 while (true ) {
380383 switch (__i) {
381384 case 0 : {
@@ -410,8 +413,14 @@ void __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
410413 }
411414}
412415
416+ // We're using unique_lock to implement the functions, which thread annotations don't support. So we have to disable
417+ // the analysis inside the function.
413418template <class _L0 , class _L1 , class _L2 , class ... _L3>
414- inline _LIBCPP_HIDE_FROM_ABI void lock (_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
419+ _LIBCPP_NO_THREAD_SAFETY_ANALYSIS inline _LIBCPP_HIDE_FROM_ABI void lock (_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3)
420+ # if defined(_LIBCPP_CLANG_VER) && _LIBCPP_CLANG_VER >= 2101
421+ _LIBCPP_ACQUIRE_CAPABILITY (__l0, __l1, __l2, __l3...)
422+ # endif
423+ {
415424 std::__lock_first (0 , __l0, __l1, __l2, __l3...);
416425}
417426
0 commit comments