Skip to content

Commit 3155199

Browse files
committed
Thread safety analysis: Eliminate unneeded const_cast, NFC
1 parent 93a4244 commit 3155199

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,11 +1363,7 @@ class Terminator : public SExpr {
13631363
}
13641364

13651365
/// Return the list of basic blocks that this terminator can branch to.
1366-
ArrayRef<BasicBlock *> successors();
1367-
1368-
ArrayRef<BasicBlock *> successors() const {
1369-
return const_cast<Terminator*>(this)->successors();
1370-
}
1366+
ArrayRef<BasicBlock *> successors() const;
13711367
};
13721368

13731369
/// Jump to another basic block.
@@ -1391,7 +1387,7 @@ class Goto : public Terminator {
13911387
unsigned index() const { return Index; }
13921388

13931389
/// Return the list of basic blocks that this terminator can branch to.
1394-
ArrayRef<BasicBlock *> successors() { return TargetBlock; }
1390+
ArrayRef<BasicBlock *> successors() const { return TargetBlock; }
13951391

13961392
template <class V>
13971393
typename V::R_SExpr traverse(V &Vs, typename V::R_Ctx Ctx) {
@@ -1439,7 +1435,7 @@ class Branch : public Terminator {
14391435
BasicBlock *elseBlock() { return Branches[1]; }
14401436

14411437
/// Return the list of basic blocks that this terminator can branch to.
1442-
ArrayRef<BasicBlock *> successors() { return llvm::ArrayRef(Branches); }
1438+
ArrayRef<BasicBlock *> successors() const { return llvm::ArrayRef(Branches); }
14431439

14441440
template <class V>
14451441
typename V::R_SExpr traverse(V &Vs, typename V::R_Ctx Ctx) {
@@ -1470,7 +1466,7 @@ class Return : public Terminator {
14701466
static bool classof(const SExpr *E) { return E->opcode() == COP_Return; }
14711467

14721468
/// Return an empty list.
1473-
ArrayRef<BasicBlock *> successors() { return {}; }
1469+
ArrayRef<BasicBlock *> successors() const { return {}; }
14741470

14751471
SExpr *returnValue() { return Retval; }
14761472
const SExpr *returnValue() const { return Retval; }
@@ -1490,7 +1486,7 @@ class Return : public Terminator {
14901486
SExpr* Retval;
14911487
};
14921488

1493-
inline ArrayRef<BasicBlock*> Terminator::successors() {
1489+
inline ArrayRef<BasicBlock *> Terminator::successors() const {
14941490
switch (opcode()) {
14951491
case COP_Goto: return cast<Goto>(this)->successors();
14961492
case COP_Branch: return cast<Branch>(this)->successors();

0 commit comments

Comments
 (0)