summaryrefslogtreecommitdiffstats
path: root/clang/test/Modules
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2015-08-12 02:17:52 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2015-08-12 02:17:52 +0000
commitdd55b95fb2c2d3d65cf37c3cd8173380a97dd673 (patch)
tree3e3083e814672c88bd71ab5483adf5ab21909d30 /clang/test/Modules
parent9e5f2a96f1c2e0ba2456b86102d5f558bcfc01dc (diff)
downloadbcm5719-llvm-dd55b95fb2c2d3d65cf37c3cd8173380a97dd673.tar.gz
bcm5719-llvm-dd55b95fb2c2d3d65cf37c3cd8173380a97dd673.zip
[modules] Fix thread safety analysis to cope with merging of FieldDecls across modules.
llvm-svn: 244714
Diffstat (limited to 'clang/test/Modules')
-rw-r--r--clang/test/Modules/Inputs/thread-safety/a.h4
-rw-r--r--clang/test/Modules/Inputs/thread-safety/b.h8
-rw-r--r--clang/test/Modules/Inputs/thread-safety/c.h10
-rw-r--r--clang/test/Modules/Inputs/thread-safety/module.map3
-rw-r--r--clang/test/Modules/thread-safety.cpp18
5 files changed, 43 insertions, 0 deletions
diff --git a/clang/test/Modules/Inputs/thread-safety/a.h b/clang/test/Modules/Inputs/thread-safety/a.h
new file mode 100644
index 00000000000..879c038cf97
--- /dev/null
+++ b/clang/test/Modules/Inputs/thread-safety/a.h
@@ -0,0 +1,4 @@
+struct __attribute__((lockable)) mutex {
+ void lock() __attribute__((exclusive_lock_function));
+ void unlock() __attribute__((unlock_function));
+};
diff --git a/clang/test/Modules/Inputs/thread-safety/b.h b/clang/test/Modules/Inputs/thread-safety/b.h
new file mode 100644
index 00000000000..c8ed23738f1
--- /dev/null
+++ b/clang/test/Modules/Inputs/thread-safety/b.h
@@ -0,0 +1,8 @@
+#include "a.h"
+
+struct X {
+ mutex m;
+ int n __attribute__((guarded_by(m)));
+
+ void f();
+};
diff --git a/clang/test/Modules/Inputs/thread-safety/c.h b/clang/test/Modules/Inputs/thread-safety/c.h
new file mode 100644
index 00000000000..ec849c2250a
--- /dev/null
+++ b/clang/test/Modules/Inputs/thread-safety/c.h
@@ -0,0 +1,10 @@
+#include "a.h"
+
+struct X {
+ mutex m;
+ int n __attribute__((guarded_by(m)));
+
+ void f();
+};
+
+inline void unlock(X &x) __attribute__((unlock_function(x.m))) { x.m.unlock(); }
diff --git a/clang/test/Modules/Inputs/thread-safety/module.map b/clang/test/Modules/Inputs/thread-safety/module.map
new file mode 100644
index 00000000000..bd6ea830c2d
--- /dev/null
+++ b/clang/test/Modules/Inputs/thread-safety/module.map
@@ -0,0 +1,3 @@
+module a { header "a.h" }
+module b { header "b.h" export * }
+module c { header "c.h" export * }
diff --git a/clang/test/Modules/thread-safety.cpp b/clang/test/Modules/thread-safety.cpp
new file mode 100644
index 00000000000..e6e85d284c8
--- /dev/null
+++ b/clang/test/Modules/thread-safety.cpp
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -fimplicit-module-maps \
+// RUN: -I%S/Inputs/thread-safety -std=c++11 -Wthread-safety \
+// RUN: -verify %s
+//
+// expected-no-diagnostics
+
+#include "b.h"
+#include "c.h"
+
+bool g();
+void X::f() {
+ m.lock();
+ if (g())
+ m.unlock();
+ else
+ unlock(*this);
+}
OpenPOWER on IntegriCloud