[PATCH] D139905: [NFC] Cleanup: BasicBlock::getInstList() is now private.
Vasileios Porpodas via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 12 18:55:52 PST 2022
vporpo created this revision.
vporpo added reviewers: aeubanks, asbirlea.
Herald added a subscriber: hiraditya.
Herald added a project: All.
vporpo requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
We now have an adequate set of API functions that we shouldn't need access
to the underlying instruction list.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D139905
Files:
llvm/include/llvm/IR/BasicBlock.h
llvm/lib/IR/BasicBlock.cpp
Index: llvm/lib/IR/BasicBlock.cpp
===================================================================
--- llvm/lib/IR/BasicBlock.cpp
+++ llvm/lib/IR/BasicBlock.cpp
@@ -482,7 +482,7 @@
BasicBlock::iterator BasicBlock::erase(BasicBlock::iterator FromIt,
BasicBlock::iterator ToIt) {
- return getInstList().erase(FromIt, ToIt);
+ return InstList.erase(FromIt, ToIt);
}
void BasicBlock::replacePhiUsesWith(BasicBlock *Old, BasicBlock *New) {
Index: llvm/include/llvm/IR/BasicBlock.h
===================================================================
--- llvm/include/llvm/IR/BasicBlock.h
+++ llvm/include/llvm/IR/BasicBlock.h
@@ -89,6 +89,12 @@
using reverse_iterator = InstListType::reverse_iterator;
using const_reverse_iterator = InstListType::const_reverse_iterator;
+ // These functions need access to the instructin list.
+ friend void Instruction::removeFromParent();
+ friend iplist<Instruction>::iterator Instruction::eraseFromParent();
+ friend BasicBlock::iterator Instruction::insertAt(BasicBlock *BB,
+ BasicBlock::iterator It);
+
/// Creates a new BasicBlock.
///
/// If the Parent parameter is specified, the basic block is automatically
@@ -366,15 +372,17 @@
}
iterator_range<phi_iterator> phis();
+private:
/// Return the underlying instruction list container.
- ///
- /// Currently you need to access the underlying instruction list container
- /// directly if you want to modify it.
+ /// This is deliberately private because we have implemented an adequate set
+ /// of functions to modify the list, including BasicBlock::splice(),
+ /// BasicBlock::erase, Instruction::insertAt() etc.
const InstListType &getInstList() const { return InstList; }
- InstListType &getInstList() { return InstList; }
+ InstListType &getInstList() { return InstList; }
+public:
/// Returns a pointer to a member of the instruction list.
- static InstListType BasicBlock::*getSublistAccess(Instruction*) {
+ static InstListType BasicBlock::*getSublistAccess(Instruction *) {
return &BasicBlock::InstList;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139905.482336.patch
Type: text/x-patch
Size: 2181 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221213/e7ea49d4/attachment.bin>
More information about the llvm-commits
mailing list