Skip to content

Commit 529eec3

Browse files
committed
[gardening] Use const_cast rather than implement SILBasicBlock::getSingleSuccessor() twice for const/non-const.
1 parent 5a1650f commit 529eec3

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

include/swift/SIL/SILBasicBlock.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,7 @@ public llvm::ilist_node<SILBasicBlock>, public SILAllocated<SILBasicBlock> {
216216
}
217217

218218
const SILBasicBlock *getSingleSuccessor() const {
219-
if (succ_empty() || std::next(succ_begin()) != succ_end())
220-
return nullptr;
221-
return *succ_begin();
219+
return const_cast<SILBasicBlock *>(this)->getSingleSuccessor();
222220
}
223221

224222
/// \brief Returns true if \p BB is a successor of this block.

0 commit comments

Comments
 (0)