Author: Aaron Puchert
Date: 2021-06-29T23:56:52+02:00
New Revision: e0b90771c318625e51c34c67db3f3dfbbb686df8

URL: 
https://github.com/llvm/llvm-project/commit/e0b90771c318625e51c34c67db3f3dfbbb686df8
DIFF: 
https://github.com/llvm/llvm-project/commit/e0b90771c318625e51c34c67db3f3dfbbb686df8.diff

LOG: Thread safety analysis: Rename parameters of 
ThreadSafetyAnalyzer::intersectAndWarn (NFC)

In D104261 we made the parameters' meaning slightly more specific, this
changes their names accordingly. In all uses we're building a new lock
set by intersecting existing locksets. The first (modifiable) argument
is the new lock set being built, the second (non-modifiable) argument is
the exit set of a preceding block.

Reviewed By: aaron.ballman, delesley

Differential Revision: https://reviews.llvm.org/D104649

Added: 
    

Modified: 
    clang/lib/Analysis/ThreadSafety.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Analysis/ThreadSafety.cpp 
b/clang/lib/Analysis/ThreadSafety.cpp
index b09de2bd71f2..5b2c882c4235 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -1052,13 +1052,13 @@ class ThreadSafetyAnalyzer {
 
   bool join(const FactEntry &a, const FactEntry &b);
 
-  void intersectAndWarn(FactSet &FSet1, const FactSet &FSet2,
-                        SourceLocation JoinLoc, LockErrorKind LEK1,
-                        LockErrorKind LEK2);
+  void intersectAndWarn(FactSet &EntrySet, const FactSet &ExitSet,
+                        SourceLocation JoinLoc, LockErrorKind EntryLEK,
+                        LockErrorKind ExitLEK);
 
-  void intersectAndWarn(FactSet &FSet1, const FactSet &FSet2,
-                        SourceLocation JoinLoc, LockErrorKind LEK1) {
-    intersectAndWarn(FSet1, FSet2, JoinLoc, LEK1, LEK1);
+  void intersectAndWarn(FactSet &EntrySet, const FactSet &ExitSet,
+                        SourceLocation JoinLoc, LockErrorKind LEK) {
+    intersectAndWarn(EntrySet, ExitSet, JoinLoc, LEK, LEK);
   }
 
   void runAnalysis(AnalysisDeclContext &AC);
@@ -2219,43 +2219,44 @@ bool ThreadSafetyAnalyzer::join(const FactEntry &A, 
const FactEntry &B) {
 /// are the same. In the event of a 
diff erence, we use the intersection of these
 /// two locksets at the start of D.
 ///
-/// \param FSet1 The first lockset.
-/// \param FSet2 The second lockset.
+/// \param EntrySet A lockset for entry into a (possibly new) block.
+/// \param ExitSet The lockset on exiting a preceding block.
 /// \param JoinLoc The location of the join point for error reporting
-/// \param LEK1 The error message to report if a mutex is missing from LSet1
-/// \param LEK2 The error message to report if a mutex is missing from Lset2
-void ThreadSafetyAnalyzer::intersectAndWarn(FactSet &FSet1,
-                                            const FactSet &FSet2,
+/// \param EntryLEK The warning if a mutex is missing from \p EntrySet.
+/// \param ExitLEK The warning if a mutex is missing from \p ExitSet.
+void ThreadSafetyAnalyzer::intersectAndWarn(FactSet &EntrySet,
+                                            const FactSet &ExitSet,
                                             SourceLocation JoinLoc,
-                                            LockErrorKind LEK1,
-                                            LockErrorKind LEK2) {
-  FactSet FSet1Orig = FSet1;
-
-  // Find locks in FSet2 that conflict or are not in FSet1, and warn.
-  for (const auto &Fact : FSet2) {
-    const FactEntry &LDat2 = FactMan[Fact];
-
-    FactSet::iterator Iter1 = FSet1.findLockIter(FactMan, LDat2);
-    if (Iter1 != FSet1.end()) {
-      if (join(FactMan[*Iter1], LDat2) && LEK1 == LEK_LockedSomePredecessors)
-        *Iter1 = Fact;
-    } else if (!LDat2.managed()) {
-      LDat2.handleRemovalFromIntersection(FSet2, FactMan, JoinLoc, LEK1,
-                                          Handler);
+                                            LockErrorKind EntryLEK,
+                                            LockErrorKind ExitLEK) {
+  FactSet EntrySetOrig = EntrySet;
+
+  // Find locks in ExitSet that conflict or are not in EntrySet, and warn.
+  for (const auto &Fact : ExitSet) {
+    const FactEntry &ExitFact = FactMan[Fact];
+
+    FactSet::iterator EntryIt = EntrySet.findLockIter(FactMan, ExitFact);
+    if (EntryIt != EntrySet.end()) {
+      if (join(FactMan[*EntryIt], ExitFact) &&
+          EntryLEK == LEK_LockedSomePredecessors)
+        *EntryIt = Fact;
+    } else if (!ExitFact.managed()) {
+      ExitFact.handleRemovalFromIntersection(ExitSet, FactMan, JoinLoc,
+                                             EntryLEK, Handler);
     }
   }
 
-  // Find locks in FSet1 that are not in FSet2, and remove them.
-  for (const auto &Fact : FSet1Orig) {
-    const FactEntry *LDat1 = &FactMan[Fact];
-    const FactEntry *LDat2 = FSet2.findLock(FactMan, *LDat1);
+  // Find locks in EntrySet that are not in ExitSet, and remove them.
+  for (const auto &Fact : EntrySetOrig) {
+    const FactEntry *EntryFact = &FactMan[Fact];
+    const FactEntry *ExitFact = ExitSet.findLock(FactMan, *EntryFact);
 
-    if (!LDat2) {
-      if (!LDat1->managed() || LEK2 == LEK_LockedSomeLoopIterations)
-        LDat1->handleRemovalFromIntersection(FSet1Orig, FactMan, JoinLoc, LEK2,
-                                             Handler);
-      if (LEK2 == LEK_LockedSomePredecessors)
-        FSet1.removeLock(FactMan, *LDat1);
+    if (!ExitFact) {
+      if (!EntryFact->managed() || ExitLEK == LEK_LockedSomeLoopIterations)
+        EntryFact->handleRemovalFromIntersection(EntrySetOrig, FactMan, 
JoinLoc,
+                                                 ExitLEK, Handler);
+      if (ExitLEK == LEK_LockedSomePredecessors)
+        EntrySet.removeLock(FactMan, *EntryFact);
     }
   }
 }


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to