[clang] Revert "[clang analysis][NFCI] Preparatory work for D153131. (#67420)" (PR #67523)

2023-09-27 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff a904bb464fe46052803e49b99ec255d2078c3c3b 
c4904f5c3304d0117a21ec6650a260639901dcf9 -- clang/lib/Analysis/ThreadSafety.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Analysis/ThreadSafety.cpp 
b/clang/lib/Analysis/ThreadSafety.cpp
index 3e6ceb7d54c4..41926b576d5d 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -1591,20 +1591,20 @@ void BuildLockset::warnIfMutexNotHeld(const NamedDecl 
*D, const Expr *Exp,
 // Negative capabilities act like locks excluded
 const FactEntry *LDat = FSet.findLock(Analyzer->FactMan, !Cp);
 if (LDat) {
-  Analyzer->Handler.handleFunExcludesLock(
-  Cp.getKind(), D->getNameAsString(), (!Cp).toString(), Loc);
-  return;
+Analyzer->Handler.handleFunExcludesLock(
+Cp.getKind(), D->getNameAsString(), (!Cp).toString(), Loc);
+return;
 }
 
 // If this does not refer to a negative capability in the same class,
 // then stop here.
 if (!Analyzer->inCurrentScope(Cp))
-  return;
+return;
 
 // Otherwise the negative requirement must be propagated to the caller.
 LDat = FSet.findLock(Analyzer->FactMan, Cp);
 if (!LDat) {
-  Analyzer->Handler.handleNegativeNotHeld(D, Cp.toString(), Loc);
+Analyzer->Handler.handleNegativeNotHeld(D, Cp.toString(), Loc);
 }
 return;
   }

``




https://github.com/llvm/llvm-project/pull/67523
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "[clang analysis][NFCI] Preparatory work for D153131. (#67420)" (PR #67523)

2023-09-27 Thread Clement Courbet via cfe-commits

https://github.com/legrosbuffle closed 
https://github.com/llvm/llvm-project/pull/67523
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "[clang analysis][NFCI] Preparatory work for D153131. (#67420)" (PR #67523)

2023-09-27 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang


Changes

There was a misunderstanding as to whether we wanted those base NFC changes or 
not.

This reverts commit 166074eff2e9a5f79b791f1cc9b641a4e2968616.

---
Full diff: https://github.com/llvm/llvm-project/pull/67523.diff


1 Files Affected:

- (modified) clang/lib/Analysis/ThreadSafety.cpp (+61-72) 


``diff
diff --git a/clang/lib/Analysis/ThreadSafety.cpp 
b/clang/lib/Analysis/ThreadSafety.cpp
index f160cf4d013c78d..3e6ceb7d54c427a 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -1015,19 +1015,6 @@ class ThreadSafetyAnalyzer {
 
   BeforeSet *GlobalBeforeSet;
 
-  void warnIfMutexNotHeld(const FactSet , const NamedDecl *D,
-  const Expr *Exp, AccessKind AK, Expr *MutexExp,
-  ProtectedOperationKind POK, til::LiteralPtr *Self,
-  SourceLocation Loc);
-  void warnIfMutexHeld(const FactSet , const NamedDecl *D, const Expr 
*Exp,
-   Expr *MutexExp, til::LiteralPtr *Self,
-   SourceLocation Loc);
-
-  void checkAccess(const FactSet , const Expr *Exp, AccessKind AK,
-   ProtectedOperationKind POK);
-  void checkPtAccess(const FactSet , const Expr *Exp, AccessKind AK,
- ProtectedOperationKind POK);
-
 public:
   ThreadSafetyAnalyzer(ThreadSafetyHandler , BeforeSet* Bset)
   : Arena(), SxBuilder(Arena), Handler(H), GlobalBeforeSet(Bset) {}
@@ -1547,15 +1534,16 @@ class BuildLockset : public 
ConstStmtVisitor {
   unsigned CtxIndex;
 
   // helper functions
+  void warnIfMutexNotHeld(const NamedDecl *D, const Expr *Exp, AccessKind AK,
+  Expr *MutexExp, ProtectedOperationKind POK,
+  til::LiteralPtr *Self, SourceLocation Loc);
+  void warnIfMutexHeld(const NamedDecl *D, const Expr *Exp, Expr *MutexExp,
+   til::LiteralPtr *Self, SourceLocation Loc);
 
   void checkAccess(const Expr *Exp, AccessKind AK,
-   ProtectedOperationKind POK = POK_VarAccess) {
-Analyzer->checkAccess(FSet, Exp, AK, POK);
-  }
+   ProtectedOperationKind POK = POK_VarAccess);
   void checkPtAccess(const Expr *Exp, AccessKind AK,
- ProtectedOperationKind POK = POK_VarAccess) {
-Analyzer->checkPtAccess(FSet, Exp, AK, POK);
-  }
+ ProtectedOperationKind POK = POK_VarAccess);
 
   void handleCall(const Expr *Exp, const NamedDecl *D,
   til::LiteralPtr *Self = nullptr,
@@ -1583,14 +1571,17 @@ class BuildLockset : public 
ConstStmtVisitor {
 
 /// Warn if the LSet does not contain a lock sufficient to protect access
 /// of at least the passed in AccessKind.
-void ThreadSafetyAnalyzer::warnIfMutexNotHeld(
-const FactSet , const NamedDecl *D, const Expr *Exp, AccessKind AK,
-Expr *MutexExp, ProtectedOperationKind POK, til::LiteralPtr *Self,
-SourceLocation Loc) {
+void BuildLockset::warnIfMutexNotHeld(const NamedDecl *D, const Expr *Exp,
+  AccessKind AK, Expr *MutexExp,
+  ProtectedOperationKind POK,
+  til::LiteralPtr *Self,
+  SourceLocation Loc) {
   LockKind LK = getLockKindFromAccessKind(AK);
-  CapabilityExpr Cp = SxBuilder.translateAttrExpr(MutexExp, D, Exp, Self);
+
+  CapabilityExpr Cp =
+  Analyzer->SxBuilder.translateAttrExpr(MutexExp, D, Exp, Self);
   if (Cp.isInvalid()) {
-warnInvalidLock(Handler, MutexExp, D, Exp, Cp.getKind());
+warnInvalidLock(Analyzer->Handler, MutexExp, D, Exp, Cp.getKind());
 return;
   } else if (Cp.shouldIgnore()) {
 return;
@@ -1598,67 +1589,68 @@ void ThreadSafetyAnalyzer::warnIfMutexNotHeld(
 
   if (Cp.negative()) {
 // Negative capabilities act like locks excluded
-const FactEntry *LDat = FSet.findLock(FactMan, !Cp);
+const FactEntry *LDat = FSet.findLock(Analyzer->FactMan, !Cp);
 if (LDat) {
-Handler.handleFunExcludesLock(Cp.getKind(), D->getNameAsString(),
-  (!Cp).toString(), Loc);
-return;
+  Analyzer->Handler.handleFunExcludesLock(
+  Cp.getKind(), D->getNameAsString(), (!Cp).toString(), Loc);
+  return;
 }
 
 // If this does not refer to a negative capability in the same class,
 // then stop here.
-if (!inCurrentScope(Cp))
-return;
+if (!Analyzer->inCurrentScope(Cp))
+  return;
 
 // Otherwise the negative requirement must be propagated to the caller.
-LDat = FSet.findLock(FactMan, Cp);
+LDat = FSet.findLock(Analyzer->FactMan, Cp);
 if (!LDat) {
-Handler.handleNegativeNotHeld(D, Cp.toString(), Loc);
+  Analyzer->Handler.handleNegativeNotHeld(D, Cp.toString(), Loc);
 }
 return;
   }
 
-  const FactEntry *LDat = FSet.findLockUniv(FactMan, Cp);
+  const FactEntry 

[clang] Revert "[clang analysis][NFCI] Preparatory work for D153131. (#67420)" (PR #67523)

2023-09-27 Thread Clement Courbet via cfe-commits

https://github.com/legrosbuffle created 
https://github.com/llvm/llvm-project/pull/67523

There was a misunderstanding as to whether we wanted those base NFC changes or 
not.

This reverts commit 166074eff2e9a5f79b791f1cc9b641a4e2968616.

>From c4904f5c3304d0117a21ec6650a260639901dcf9 Mon Sep 17 00:00:00 2001
From: Clement Courbet 
Date: Wed, 27 Sep 2023 09:43:46 +0200
Subject: [PATCH] Revert "[clang analysis][NFCI] Preparatory work for D153131.
 (#67420)"

There was a misunderstanding as to whether we wanted those base NFC changes or 
not.

This reverts commit 166074eff2e9a5f79b791f1cc9b641a4e2968616.
---
 clang/lib/Analysis/ThreadSafety.cpp | 133 +---
 1 file changed, 61 insertions(+), 72 deletions(-)

diff --git a/clang/lib/Analysis/ThreadSafety.cpp 
b/clang/lib/Analysis/ThreadSafety.cpp
index f160cf4d013c78d..3e6ceb7d54c427a 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -1015,19 +1015,6 @@ class ThreadSafetyAnalyzer {
 
   BeforeSet *GlobalBeforeSet;
 
-  void warnIfMutexNotHeld(const FactSet , const NamedDecl *D,
-  const Expr *Exp, AccessKind AK, Expr *MutexExp,
-  ProtectedOperationKind POK, til::LiteralPtr *Self,
-  SourceLocation Loc);
-  void warnIfMutexHeld(const FactSet , const NamedDecl *D, const Expr 
*Exp,
-   Expr *MutexExp, til::LiteralPtr *Self,
-   SourceLocation Loc);
-
-  void checkAccess(const FactSet , const Expr *Exp, AccessKind AK,
-   ProtectedOperationKind POK);
-  void checkPtAccess(const FactSet , const Expr *Exp, AccessKind AK,
- ProtectedOperationKind POK);
-
 public:
   ThreadSafetyAnalyzer(ThreadSafetyHandler , BeforeSet* Bset)
   : Arena(), SxBuilder(Arena), Handler(H), GlobalBeforeSet(Bset) {}
@@ -1547,15 +1534,16 @@ class BuildLockset : public 
ConstStmtVisitor {
   unsigned CtxIndex;
 
   // helper functions
+  void warnIfMutexNotHeld(const NamedDecl *D, const Expr *Exp, AccessKind AK,
+  Expr *MutexExp, ProtectedOperationKind POK,
+  til::LiteralPtr *Self, SourceLocation Loc);
+  void warnIfMutexHeld(const NamedDecl *D, const Expr *Exp, Expr *MutexExp,
+   til::LiteralPtr *Self, SourceLocation Loc);
 
   void checkAccess(const Expr *Exp, AccessKind AK,
-   ProtectedOperationKind POK = POK_VarAccess) {
-Analyzer->checkAccess(FSet, Exp, AK, POK);
-  }
+   ProtectedOperationKind POK = POK_VarAccess);
   void checkPtAccess(const Expr *Exp, AccessKind AK,
- ProtectedOperationKind POK = POK_VarAccess) {
-Analyzer->checkPtAccess(FSet, Exp, AK, POK);
-  }
+ ProtectedOperationKind POK = POK_VarAccess);
 
   void handleCall(const Expr *Exp, const NamedDecl *D,
   til::LiteralPtr *Self = nullptr,
@@ -1583,14 +1571,17 @@ class BuildLockset : public 
ConstStmtVisitor {
 
 /// Warn if the LSet does not contain a lock sufficient to protect access
 /// of at least the passed in AccessKind.
-void ThreadSafetyAnalyzer::warnIfMutexNotHeld(
-const FactSet , const NamedDecl *D, const Expr *Exp, AccessKind AK,
-Expr *MutexExp, ProtectedOperationKind POK, til::LiteralPtr *Self,
-SourceLocation Loc) {
+void BuildLockset::warnIfMutexNotHeld(const NamedDecl *D, const Expr *Exp,
+  AccessKind AK, Expr *MutexExp,
+  ProtectedOperationKind POK,
+  til::LiteralPtr *Self,
+  SourceLocation Loc) {
   LockKind LK = getLockKindFromAccessKind(AK);
-  CapabilityExpr Cp = SxBuilder.translateAttrExpr(MutexExp, D, Exp, Self);
+
+  CapabilityExpr Cp =
+  Analyzer->SxBuilder.translateAttrExpr(MutexExp, D, Exp, Self);
   if (Cp.isInvalid()) {
-warnInvalidLock(Handler, MutexExp, D, Exp, Cp.getKind());
+warnInvalidLock(Analyzer->Handler, MutexExp, D, Exp, Cp.getKind());
 return;
   } else if (Cp.shouldIgnore()) {
 return;
@@ -1598,67 +1589,68 @@ void ThreadSafetyAnalyzer::warnIfMutexNotHeld(
 
   if (Cp.negative()) {
 // Negative capabilities act like locks excluded
-const FactEntry *LDat = FSet.findLock(FactMan, !Cp);
+const FactEntry *LDat = FSet.findLock(Analyzer->FactMan, !Cp);
 if (LDat) {
-Handler.handleFunExcludesLock(Cp.getKind(), D->getNameAsString(),
-  (!Cp).toString(), Loc);
-return;
+  Analyzer->Handler.handleFunExcludesLock(
+  Cp.getKind(), D->getNameAsString(), (!Cp).toString(), Loc);
+  return;
 }
 
 // If this does not refer to a negative capability in the same class,
 // then stop here.
-if (!inCurrentScope(Cp))
-return;
+if (!Analyzer->inCurrentScope(Cp))
+  return;
 
 // Otherwise the negative requirement must be