]> granicus.if.org Git - clang/commitdiff
Thread safety analysis: handle duplicate assert_lock attributes.
authorDeLesley Hutchins <delesley@google.com>
Thu, 23 Jan 2014 22:35:26 +0000 (22:35 +0000)
committerDeLesley Hutchins <delesley@google.com>
Thu, 23 Jan 2014 22:35:26 +0000 (22:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199949 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/Attr.td
test/SemaCXX/warn-thread-safety-analysis.cpp

index 31435485ef798ea434ef06f5961901ff321fc35c..9e23afcca3614e3506b115ff2e142c3970aa663a 100644 (file)
@@ -1180,6 +1180,7 @@ def AssertExclusiveLock : InheritableAttr {
   let LateParsed = 1;
   let TemplateDependent = 1;
   let ParseArgumentsAsUnevaluated = 1;
+  let DuplicatesAllowedWhileMerging = 1;
   let Subjects = SubjectList<[FunctionDefinition, FunctionTemplate]>;
 }
 
@@ -1189,6 +1190,7 @@ def AssertSharedLock : InheritableAttr {
   let LateParsed = 1;
   let TemplateDependent = 1;
   let ParseArgumentsAsUnevaluated = 1;
+  let DuplicatesAllowedWhileMerging = 1;
   let Subjects = SubjectList<[FunctionDefinition, FunctionTemplate]>;
 }
 
index 6b0159064be4b31ecc43027a99e149db59e7c99a..7c0a73327b827910ec376e819ada8ad5ed94c5e9 100644 (file)
@@ -3616,8 +3616,14 @@ class Foo {
                        EXCLUSIVE_TRYLOCK_FUNCTION(true, mu2_);
   bool readertrylock() SHARED_TRYLOCK_FUNCTION(true, mu1_)
                        SHARED_TRYLOCK_FUNCTION(true, mu2_);
+  void assertBoth() ASSERT_EXCLUSIVE_LOCK(mu1_)
+                    ASSERT_EXCLUSIVE_LOCK(mu2_);
+  void assertShared() ASSERT_SHARED_LOCK(mu1_)
+                      ASSERT_SHARED_LOCK(mu2_);
 
   void test();
+  void testAssert();
+  void testAssertShared();
 };
 
 
@@ -3676,6 +3682,21 @@ void Foo::test() {
   }
 }
 
+// Force duplication of attributes
+void Foo::assertBoth() { }
+void Foo::assertShared() { }
+
+void Foo::testAssert() {
+  assertBoth();
+  a = 0;
+  b = 0;
+}
+
+void Foo::testAssertShared() {
+  assertShared();
+  int zz = a + b;
+}
+
 
 }  // end namespace MultipleAttributeTest