]> granicus.if.org Git - clang/commitdiff
Properly add shared locks to the initial list of locks being tracked, instead of...
authorAaron Ballman <aaron@aaronballman.com>
Fri, 3 Aug 2018 19:37:45 +0000 (19:37 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Fri, 3 Aug 2018 19:37:45 +0000 (19:37 +0000)
Patch by Aaron Puchert.

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

lib/Analysis/ThreadSafety.cpp
test/SemaCXX/warn-thread-safety-analysis.cpp

index 03cc234dce5c3b158766110557b47f7a500d4330..2ebd8270376e5412f3f6c5bd83fbe95919aa3ba4 100644 (file)
@@ -2242,8 +2242,8 @@ void ThreadSafetyAnalyzer::runAnalysis(AnalysisDeclContext &AC) {
         // We must ignore such methods.
         if (A->args_size() == 0)
           return;
-        // FIXME -- deal with exclusive vs. shared unlock functions?
-        getMutexIDs(ExclusiveLocksToAdd, A, nullptr, D);
+        getMutexIDs(A->isShared() ? SharedLocksToAdd : ExclusiveLocksToAdd, A,
+                    nullptr, D);
         getMutexIDs(LocksReleased, A, nullptr, D);
         CapDiagKind = ClassifyDiagnostic(A);
       } else if (const auto *A = dyn_cast<AcquireCapabilityAttr>(Attr)) {
index 51535be97d97e513263949bd6400fb5256becdd6..cd1e479ab51b2841239c7efda434032a5e557ea6 100644 (file)
@@ -4078,6 +4078,14 @@ public:
     mu_.Unlock();
   }
 
+  void unlockExclusive() EXCLUSIVE_UNLOCK_FUNCTION(mu_) {
+    mu_.Unlock();
+  }
+
+  void unlockShared() SHARED_UNLOCK_FUNCTION(mu_) {
+    mu_.ReaderUnlock();
+  }
+
   // Check failure to lock.
   void lockBad() EXCLUSIVE_LOCK_FUNCTION(mu_) {    // expected-note {{mutex acquired here}}
     mu2_.Lock();