From 24a6c9459a50248e502884f129c789d452f70acc Mon Sep 17 00:00:00 2001 From: DeLesley Hutchins Date: Tue, 11 Sep 2012 18:27:46 +0000 Subject: [PATCH] Thread safety analysis: fix bug related to lock_returned attribute on templates. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163642 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclAttr.cpp | 3 -- test/SemaCXX/warn-thread-safety-analysis.cpp | 29 ++++++++++++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 119ce7dfff..3b0820a5eb 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -872,9 +872,6 @@ static void handleLockReturnedAttr(Sema &S, Decl *D, return; } - if (Arg->isTypeDependent()) - return; - // check that the argument is lockable object SmallVector Args; checkAttrArgsAreLockableObjs(S, D, Attr, Args); diff --git a/test/SemaCXX/warn-thread-safety-analysis.cpp b/test/SemaCXX/warn-thread-safety-analysis.cpp index 7637b77405..463dd7d05b 100644 --- a/test/SemaCXX/warn-thread-safety-analysis.cpp +++ b/test/SemaCXX/warn-thread-safety-analysis.cpp @@ -3241,7 +3241,7 @@ static void test() { lt->mu_.Unlock(); } -} +} // end namespace TrylockWithCleanups namespace UniversalLock { @@ -3315,4 +3315,29 @@ class Foo { } }; -} +} // end namespace UniversalLock + + +namespace TemplateLockReturned { + +template +class BaseT { +public: + virtual void baseMethod() = 0; + Mutex* get_mutex() LOCK_RETURNED(mutex_) { return &mutex_; } + + Mutex mutex_; + int a GUARDED_BY(mutex_); +}; + + +class Derived : public BaseT { +public: + void baseMethod() EXCLUSIVE_LOCKS_REQUIRED(get_mutex()) { + a = 0; + } +}; + +} // end namespace TemplateLockReturned + + -- 2.40.0