r244714 - [modules] Fix thread safety analysis to cope with merging of FieldDecls across modules.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 11 19:17:52 PDT 2015
Author: rsmith
Date: Tue Aug 11 21:17:52 2015
New Revision: 244714
URL: http://llvm.org/viewvc/llvm-project?rev=244714&view=rev
Log:
[modules] Fix thread safety analysis to cope with merging of FieldDecls across modules.
Added:
cfe/trunk/test/Modules/Inputs/thread-safety/
cfe/trunk/test/Modules/Inputs/thread-safety/a.h
cfe/trunk/test/Modules/Inputs/thread-safety/b.h
cfe/trunk/test/Modules/Inputs/thread-safety/c.h
cfe/trunk/test/Modules/Inputs/thread-safety/module.map
cfe/trunk/test/Modules/thread-safety.cpp
Modified:
cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp
Modified: cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp?rev=244714&r1=244713&r2=244714&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp (original)
+++ cfe/trunk/lib/Analysis/ThreadSafetyCommon.cpp Tue Aug 11 21:17:52 2015
@@ -344,7 +344,8 @@ til::SExpr *SExprBuilder::translateMembe
til::SExpr *BE = translate(ME->getBase(), Ctx);
til::SExpr *E = new (Arena) til::SApply(BE);
- const ValueDecl *D = ME->getMemberDecl();
+ const ValueDecl *D =
+ cast<ValueDecl>(ME->getMemberDecl()->getCanonicalDecl());
if (auto *VD = dyn_cast<CXXMethodDecl>(D))
D = getFirstVirtualDecl(VD);
Added: cfe/trunk/test/Modules/Inputs/thread-safety/a.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/thread-safety/a.h?rev=244714&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/thread-safety/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/thread-safety/a.h Tue Aug 11 21:17:52 2015
@@ -0,0 +1,4 @@
+struct __attribute__((lockable)) mutex {
+ void lock() __attribute__((exclusive_lock_function));
+ void unlock() __attribute__((unlock_function));
+};
Added: cfe/trunk/test/Modules/Inputs/thread-safety/b.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/thread-safety/b.h?rev=244714&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/thread-safety/b.h (added)
+++ cfe/trunk/test/Modules/Inputs/thread-safety/b.h Tue Aug 11 21:17:52 2015
@@ -0,0 +1,8 @@
+#include "a.h"
+
+struct X {
+ mutex m;
+ int n __attribute__((guarded_by(m)));
+
+ void f();
+};
Added: cfe/trunk/test/Modules/Inputs/thread-safety/c.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/thread-safety/c.h?rev=244714&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/thread-safety/c.h (added)
+++ cfe/trunk/test/Modules/Inputs/thread-safety/c.h Tue Aug 11 21:17:52 2015
@@ -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(); }
Added: cfe/trunk/test/Modules/Inputs/thread-safety/module.map
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/thread-safety/module.map?rev=244714&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/thread-safety/module.map (added)
+++ cfe/trunk/test/Modules/Inputs/thread-safety/module.map Tue Aug 11 21:17:52 2015
@@ -0,0 +1,3 @@
+module a { header "a.h" }
+module b { header "b.h" export * }
+module c { header "c.h" export * }
Added: cfe/trunk/test/Modules/thread-safety.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/thread-safety.cpp?rev=244714&view=auto
==============================================================================
--- cfe/trunk/test/Modules/thread-safety.cpp (added)
+++ cfe/trunk/test/Modules/thread-safety.cpp Tue Aug 11 21:17:52 2015
@@ -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);
+}
More information about the cfe-commits
mailing list