]> granicus.if.org Git - clang/commitdiff
Thread safety analysis: fix bug related to lock_returned attribute
authorDeLesley Hutchins <delesley@google.com>
Tue, 11 Sep 2012 18:27:46 +0000 (18:27 +0000)
committerDeLesley Hutchins <delesley@google.com>
Tue, 11 Sep 2012 18:27:46 +0000 (18:27 +0000)
on templates.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163642 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclAttr.cpp
test/SemaCXX/warn-thread-safety-analysis.cpp

index 119ce7dfff7be5037f7d6f323676929ac289ed6b..3b0820a5eb3600c999aa33c2a295a672112d0554 100644 (file)
@@ -872,9 +872,6 @@ static void handleLockReturnedAttr(Sema &S, Decl *D,
     return;
   }
 
-  if (Arg->isTypeDependent())
-    return;
-
   // check that the argument is lockable object
   SmallVector<Expr*, 1> Args;
   checkAttrArgsAreLockableObjs(S, D, Attr, Args);
index 7637b774057288bb5e5384f9608cec688118d97c..463dd7d05ba01376c7d3156e209bc41ceac36ebf 100644 (file)
@@ -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 T>
+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<int> {
+public:
+  void baseMethod() EXCLUSIVE_LOCKS_REQUIRED(get_mutex()) {
+    a = 0;
+  }
+};
+
+}  // end namespace TemplateLockReturned
+
+