@@ -320,7 +320,7 @@ public:
320
320
};
321
321
322
322
template <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) {
324
324
unique_lock<_L0> __u0 (__l0, try_to_lock_t ());
325
325
if (__u0.owns_lock ()) {
326
326
if (__l1.try_lock ()) {
@@ -335,7 +335,7 @@ _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1) {
335
335
# ifndef _LIBCPP_CXX03_LANG
336
336
337
337
template <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) {
339
339
int __r = 0 ;
340
340
unique_lock<_L0> __u0 (__l0, try_to_lock);
341
341
if (__u0.owns_lock ()) {
@@ -350,8 +350,11 @@ _LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3
350
350
351
351
# endif // _LIBCPP_CXX03_LANG
352
352
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.
353
355
template <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) {
355
358
while (true ) {
356
359
{
357
360
unique_lock<_L0> __u0 (__l0);
@@ -375,7 +378,7 @@ _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1) {
375
378
# ifndef _LIBCPP_CXX03_LANG
376
379
377
380
template <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) {
379
382
while (true ) {
380
383
switch (__i) {
381
384
case 0 : {
@@ -410,8 +413,14 @@ void __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
410
413
}
411
414
}
412
415
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.
413
418
template <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
+ {
415
424
std::__lock_first (0 , __l0, __l1, __l2, __l3...);
416
425
}
417
426
0 commit comments