@@ -60,6 +60,20 @@ class SCOPED_LOCKABLE ReleasableMutexLock {
6060 void Release () UNLOCK_FUNCTION();
6161};
6262
63+ template <typename T>
64+ struct lock_guard {
65+ lock_guard<T>(T) {}
66+ ~lock_guard<T>() {}
67+ };
68+ template <typename T>
69+ struct unique_lock {
70+ unique_lock<T>(T) {}
71+ ~unique_lock<T>() {}
72+ };
73+
74+ template <class T , class ... Ts>
75+ void LockMutexes (T &m, Ts &...ms) __attribute__((exclusive_lock_function(m, ms...)));
76+
6377
6478// The universal lock, written "*", allows checking to be selectively turned
6579// off for a particular piece of code.
@@ -316,10 +330,6 @@ void sls_fun_bad_12() {
316330 expected-warning{{releasing mutex 'sls_mu' that was not held}}
317331}
318332
319-
320- template <class T , class ... Ts>
321- void LockMutexes (T &m, Ts &...ms) __attribute__((exclusive_lock_function(m, ms...)));
322-
323333Mutex m0, m1;
324334void non_local_mutex_held () {
325335 LockMutexes (m0, m1); // expected-note {{mutex acquired here}} \
@@ -333,4 +343,10 @@ void no_local_mutex_held_warning() {
333343 LockMutexes (local_m0, local_m1);
334344} // No warnings expected at end of function scope as the mutexes are function local.
335345
346+ void no_local_unique_locks_held_warning () {
347+ unique_lock<Mutex> ul0 (m0);
348+ unique_lock<Mutex> ul1 (m1);
349+ LockMutexes (ul0, ul1);
350+ } // No warnings expected at end of function scope as the unique_locks held are function local.
351+
336352#endif
0 commit comments