mirror of
https://github.com/intel/llvm.git
synced 2026-02-04 03:26:06 +08:00
[modules] Fix thread safety analysis to cope with merging of FieldDecls across modules.
llvm-svn: 244714
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
4
clang/test/Modules/Inputs/thread-safety/a.h
Normal file
4
clang/test/Modules/Inputs/thread-safety/a.h
Normal file
@@ -0,0 +1,4 @@
|
||||
struct __attribute__((lockable)) mutex {
|
||||
void lock() __attribute__((exclusive_lock_function));
|
||||
void unlock() __attribute__((unlock_function));
|
||||
};
|
||||
8
clang/test/Modules/Inputs/thread-safety/b.h
Normal file
8
clang/test/Modules/Inputs/thread-safety/b.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "a.h"
|
||||
|
||||
struct X {
|
||||
mutex m;
|
||||
int n __attribute__((guarded_by(m)));
|
||||
|
||||
void f();
|
||||
};
|
||||
10
clang/test/Modules/Inputs/thread-safety/c.h
Normal file
10
clang/test/Modules/Inputs/thread-safety/c.h
Normal 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(); }
|
||||
3
clang/test/Modules/Inputs/thread-safety/module.map
Normal file
3
clang/test/Modules/Inputs/thread-safety/module.map
Normal file
@@ -0,0 +1,3 @@
|
||||
module a { header "a.h" }
|
||||
module b { header "b.h" export * }
|
||||
module c { header "c.h" export * }
|
||||
18
clang/test/Modules/thread-safety.cpp
Normal file
18
clang/test/Modules/thread-safety.cpp
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user