[modules] Fix thread safety analysis to cope with merging of FieldDecls across modules.

llvm-svn: 244714
This commit is contained in:
Richard Smith
2015-08-12 02:17:52 +00:00
parent 9e5f2a96f1
commit dd55b95fb2
6 changed files with 45 additions and 1 deletions

View File

@@ -344,7 +344,8 @@ til::SExpr *SExprBuilder::translateMemberExpr(const MemberExpr *ME,
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);

View File

@@ -0,0 +1,4 @@
struct __attribute__((lockable)) mutex {
void lock() __attribute__((exclusive_lock_function));
void unlock() __attribute__((unlock_function));
};

View File

@@ -0,0 +1,8 @@
#include "a.h"
struct X {
mutex m;
int n __attribute__((guarded_by(m)));
void f();
};

View File

@@ -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(); }

View File

@@ -0,0 +1,3 @@
module a { header "a.h" }
module b { header "b.h" export * }
module c { header "c.h" export * }

View File

@@ -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);
}