[PATCH] D104649: Thread safety analysis: Rename parameters of ThreadSafetyAnalyzer::intersectAndWarn (NFC)

2021-06-29 Thread Aaron Puchert via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe0b90771c318: Thread safety analysis: Rename parameters of 
ThreadSafetyAnalyzer… (authored by aaronpuchert).

Changed prior to commit:
  https://reviews.llvm.org/D104649?vs=353380=355374#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104649/new/

https://reviews.llvm.org/D104649

Files:
  clang/lib/Analysis/ThreadSafety.cpp


Index: clang/lib/Analysis/ThreadSafety.cpp
===
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -1052,13 +1052,13 @@
 
   bool join(const FactEntry , const FactEntry );
 
-  void intersectAndWarn(FactSet , const FactSet ,
-SourceLocation JoinLoc, LockErrorKind LEK1,
-LockErrorKind LEK2);
+  void intersectAndWarn(FactSet , const FactSet ,
+SourceLocation JoinLoc, LockErrorKind EntryLEK,
+LockErrorKind ExitLEK);
 
-  void intersectAndWarn(FactSet , const FactSet ,
-SourceLocation JoinLoc, LockErrorKind LEK1) {
-intersectAndWarn(FSet1, FSet2, JoinLoc, LEK1, LEK1);
+  void intersectAndWarn(FactSet , const FactSet ,
+SourceLocation JoinLoc, LockErrorKind LEK) {
+intersectAndWarn(EntrySet, ExitSet, JoinLoc, LEK, LEK);
   }
 
   void runAnalysis(AnalysisDeclContext );
@@ -2219,43 +2219,44 @@
 /// are the same. In the event of a difference, 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 ,
-const FactSet ,
+/// \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 ,
+const FactSet ,
 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  : FSet2) {
-const FactEntry  = 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  : ExitSet) {
+const FactEntry  = 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  : FSet1Orig) {
-const FactEntry *LDat1 = [Fact];
-const FactEntry *LDat2 = FSet2.findLock(FactMan, *LDat1);
+  // Find locks in EntrySet that are not in ExitSet, and remove them.
+  for (const auto  : EntrySetOrig) {
+const FactEntry *EntryFact = [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, 

[PATCH] D104649: Thread safety analysis: Rename parameters of ThreadSafetyAnalyzer::intersectAndWarn (NFC)

2021-06-25 Thread Delesley Hutchins via Phabricator via cfe-commits
delesley accepted this revision.
delesley added a comment.

Looks good.  Thanks!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104649/new/

https://reviews.llvm.org/D104649

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


[PATCH] D104649: Thread safety analysis: Rename parameters of ThreadSafetyAnalyzer::intersectAndWarn (NFC)

2021-06-22 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM! Thank you for the terminology cleanup.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104649/new/

https://reviews.llvm.org/D104649

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


[PATCH] D104649: Thread safety analysis: Rename parameters of ThreadSafetyAnalyzer::intersectAndWarn (NFC)

2021-06-21 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added reviewers: aaron.ballman, delesley.
Herald added subscribers: manas, steakhal, ASDenysPetrov, dkrupp, donat.nagy, 
Szelethus, a.sidorin, baloghadamsoftware.
aaronpuchert requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D104649

Files:
  clang/lib/Analysis/ThreadSafety.cpp


Index: clang/lib/Analysis/ThreadSafety.cpp
===
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -1052,13 +1052,13 @@
 
   bool join(const FactEntry , const FactEntry );
 
-  void intersectAndWarn(FactSet , const FactSet ,
-SourceLocation JoinLoc, LockErrorKind LEK1,
-LockErrorKind LEK2);
+  void intersectAndWarn(FactSet , const FactSet ,
+SourceLocation JoinLoc, LockErrorKind EntryLEK,
+LockErrorKind ExitLEK);
 
-  void intersectAndWarn(FactSet , const FactSet ,
-SourceLocation JoinLoc, LockErrorKind LEK1) {
-intersectAndWarn(FSet1, FSet2, JoinLoc, LEK1, LEK1);
+  void intersectAndWarn(FactSet , const FactSet ,
+SourceLocation JoinLoc, LockErrorKind LEK) {
+intersectAndWarn(EntrySet, ExitSet, JoinLoc, LEK, LEK);
   }
 
   void runAnalysis(AnalysisDeclContext );
@@ -2219,43 +2219,44 @@
 /// are the same. In the event of a difference, 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 ,
-const FactSet ,
+/// \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 ,
+const FactSet ,
 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  : FSet2) {
-const FactEntry  = 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  : ExitSet) {
+const FactEntry  = 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  : FSet1Orig) {
-const FactEntry *LDat1 = [Fact];
-const FactEntry *LDat2 = FSet2.findLock(FactMan, *LDat1);
+  // Find locks in EntrySet that are not in ExitSet, and remove them.
+  for (const auto  : EntrySetOrig) {
+const FactEntry *EntryFact = [Fact];
+const FactEntry *ExitFact = ExitSet.findLock(FactMan, *EntryFact);
 
-if (!LDat2) {
-  if (!LDat1->managed() || LEK1 == LEK_LockedSomeLoopIterations)
-LDat1->handleRemovalFromIntersection(FSet1Orig, FactMan, JoinLoc, LEK2,
- Handler);
-  if (LEK2 == LEK_LockedSomePredecessors)
-