diff options
author | Aaron Puchert <aaronpuchert@alice-dsl.net> | 2018-10-09 23:42:29 +0000 |
---|---|---|
committer | Aaron Puchert <aaronpuchert@alice-dsl.net> | 2018-10-09 23:42:29 +0000 |
commit | 7f208f02dbea6225db15dbdbf0e8d4778cc36fc5 (patch) | |
tree | 941a50e49592b50029dd050fbb6d5c6b7a830238 | |
parent | e5f47bbeaccb3778bc604d29f8768ccbc400ceca (diff) | |
download | bcm5719-llvm-7f208f02dbea6225db15dbdbf0e8d4778cc36fc5.tar.gz bcm5719-llvm-7f208f02dbea6225db15dbdbf0e8d4778cc36fc5.zip |
Annotate scoped_lock as with scoped_lockable attribute
Summary:
Scoped capabilities need to be annotated as such, otherwise the thread
safety analysis won't work as intended.
Fixes PR39234.
Reviewers: ldionne
Reviewed By: ldionne
Subscribers: christof, libcxx-commits
Differential Revision: https://reviews.llvm.org/D53049
llvm-svn: 344096
-rw-r--r-- | libcxx/include/mutex | 2 | ||||
-rw-r--r-- | libcxx/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/libcxx/include/mutex b/libcxx/include/mutex index 9c55c7cc164..6d2de2b460e 100644 --- a/libcxx/include/mutex +++ b/libcxx/include/mutex @@ -489,7 +489,7 @@ public: }; template <class _Mutex> -class _LIBCPP_TEMPLATE_VIS scoped_lock<_Mutex> { +class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable) scoped_lock<_Mutex> { public: typedef _Mutex mutex_type; private: diff --git a/libcxx/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp b/libcxx/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp index 6024d997843..bd015feedb3 100644 --- a/libcxx/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp +++ b/libcxx/test/libcxx/thread/thread.mutex/thread_safety_lock_guard.pass.cpp @@ -24,7 +24,13 @@ std::mutex m; int foo __attribute__((guarded_by(m))); +static void scoped() { + std::scoped_lock<std::mutex> lock(m); + foo++; +} + int main() { + scoped(); std::lock_guard<std::mutex> lock(m); foo++; } |