[clang][lex] NFCI: Use DirectoryEntryRef in ModuleMap::inferFrameworkModule()
[llvm-project.git] / clang / test / SemaTemplate / warn-thread-safety-analysis.cpp
blob710f424c17dc71b5b1c5734989513216aa8b9567
1 // RUN: %clang_cc1 -std=c++11 %s -verify -Wthread-safety-analysis
3 class Mutex {
4 public:
5 void Lock() __attribute__((exclusive_lock_function()));
6 void Unlock() __attribute__((unlock_function()));
7 };
9 class A {
10 public:
11 Mutex mu1, mu2;
13 void foo() __attribute__((exclusive_locks_required(mu1))) __attribute__((exclusive_locks_required(mu2))) {}
15 template <class T> void bar() __attribute__((exclusive_locks_required(mu1))) __attribute__((exclusive_locks_required(mu2))) {
16 foo();
20 void f() {
21 A a;
22 a.mu1.Lock();
23 a.mu2.Lock();
24 a.bar<int>();
25 a.mu2.Unlock();
26 a.bar<int>(); // expected-warning {{calling function 'bar<int>' requires holding mutex 'a.mu2' exclusively}}
27 a.mu1.Unlock();
28 a.bar<int>(); // expected-warning {{calling function 'bar<int>' requires holding mutex 'a.mu1' exclusively}} \
29 expected-warning {{calling function 'bar<int>' requires holding mutex 'a.mu2' exclusively}}