[clang] 3155199 - Thread safety analysis: Eliminate unneeded const_cast, NFC

Aaron Puchert via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 17 13:41:52 PST 2024


Author: Aaron Puchert
Date: 2024-11-17T22:40:09+01:00
New Revision: 315519917368dce841f1cb1e7b296846d13497c3

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

LOG: Thread safety analysis: Eliminate unneeded const_cast, NFC

Added: 
    

Modified: 
    clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h b/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
index 2f202607bd3fa9..9f365d1a3b6557 100644
--- a/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
+++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
@@ -1363,11 +1363,7 @@ class Terminator : public SExpr {
   }
 
   /// Return the list of basic blocks that this terminator can branch to.
-  ArrayRef<BasicBlock *> successors();
-
-  ArrayRef<BasicBlock *> successors() const {
-    return const_cast<Terminator*>(this)->successors();
-  }
+  ArrayRef<BasicBlock *> successors() const;
 };
 
 /// Jump to another basic block.
@@ -1391,7 +1387,7 @@ class Goto : public Terminator {
   unsigned index() const { return Index; }
 
   /// Return the list of basic blocks that this terminator can branch to.
-  ArrayRef<BasicBlock *> successors() { return TargetBlock; }
+  ArrayRef<BasicBlock *> successors() const { return TargetBlock; }
 
   template <class V>
   typename V::R_SExpr traverse(V &Vs, typename V::R_Ctx Ctx) {
@@ -1439,7 +1435,7 @@ class Branch : public Terminator {
   BasicBlock *elseBlock() { return Branches[1]; }
 
   /// Return the list of basic blocks that this terminator can branch to.
-  ArrayRef<BasicBlock *> successors() { return llvm::ArrayRef(Branches); }
+  ArrayRef<BasicBlock *> successors() const { return llvm::ArrayRef(Branches); }
 
   template <class V>
   typename V::R_SExpr traverse(V &Vs, typename V::R_Ctx Ctx) {
@@ -1470,7 +1466,7 @@ class Return : public Terminator {
   static bool classof(const SExpr *E) { return E->opcode() == COP_Return; }
 
   /// Return an empty list.
-  ArrayRef<BasicBlock *> successors() { return {}; }
+  ArrayRef<BasicBlock *> successors() const { return {}; }
 
   SExpr *returnValue() { return Retval; }
   const SExpr *returnValue() const { return Retval; }
@@ -1490,7 +1486,7 @@ class Return : public Terminator {
   SExpr* Retval;
 };
 
-inline ArrayRef<BasicBlock*> Terminator::successors() {
+inline ArrayRef<BasicBlock *> Terminator::successors() const {
   switch (opcode()) {
     case COP_Goto:   return cast<Goto>(this)->successors();
     case COP_Branch: return cast<Branch>(this)->successors();


        


More information about the cfe-commits mailing list