mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-21 03:05:26 -04:00
IR: Remove implicit iterator conversions from lib/IR, NFC
Stop converting implicitly between iterators and pointers/references in lib/IR. For convenience, I've added a `getIterator()` accessor to `ilist_node` so that callers don't need to know how to spell the iterator class (i.e., they can use `X.getIterator()` instead of `Function::iterator(X)`). I'll eventually disallow these implicit conversions entirely, but there's a lot of code, so it doesn't make sense to do it all in one patch. One library or so at a time. Why? To root out cases of `getNextNode()` and `getPrevNode()` being used in iterator logic. The design of `ilist` makes that invalid when the current node could be at the back of the list, but it happens to "work" right now because of a bug where those functions never return `nullptr` if you're using a half-node sentinel. Before I can fix the function, I have to remove uses of it that rely on it misbehaving. (Maybe the function should just be deleted anyway? But I don't want deleting it -- potentially a huge project -- to block fixing ilist/iplist.) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@249782 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -56,7 +56,7 @@ void BasicBlock::insertInto(Function *NewParent, BasicBlock *InsertBefore) {
|
||||
assert(!Parent && "Already has a parent");
|
||||
|
||||
if (InsertBefore)
|
||||
NewParent->getBasicBlockList().insert(InsertBefore, this);
|
||||
NewParent->getBasicBlockList().insert(InsertBefore->getIterator(), this);
|
||||
else
|
||||
NewParent->getBasicBlockList().push_back(this);
|
||||
}
|
||||
@@ -91,26 +91,26 @@ void BasicBlock::setParent(Function *parent) {
|
||||
}
|
||||
|
||||
void BasicBlock::removeFromParent() {
|
||||
getParent()->getBasicBlockList().remove(this);
|
||||
getParent()->getBasicBlockList().remove(getIterator());
|
||||
}
|
||||
|
||||
iplist<BasicBlock>::iterator BasicBlock::eraseFromParent() {
|
||||
return getParent()->getBasicBlockList().erase(this);
|
||||
return getParent()->getBasicBlockList().erase(getIterator());
|
||||
}
|
||||
|
||||
/// Unlink this basic block from its current function and
|
||||
/// insert it into the function that MovePos lives in, right before MovePos.
|
||||
void BasicBlock::moveBefore(BasicBlock *MovePos) {
|
||||
MovePos->getParent()->getBasicBlockList().splice(MovePos,
|
||||
getParent()->getBasicBlockList(), this);
|
||||
MovePos->getParent()->getBasicBlockList().splice(
|
||||
MovePos->getIterator(), getParent()->getBasicBlockList(), getIterator());
|
||||
}
|
||||
|
||||
/// Unlink this basic block from its current function and
|
||||
/// insert it into the function that MovePos lives in, right after MovePos.
|
||||
void BasicBlock::moveAfter(BasicBlock *MovePos) {
|
||||
Function::iterator I = MovePos;
|
||||
MovePos->getParent()->getBasicBlockList().splice(++I,
|
||||
getParent()->getBasicBlockList(), this);
|
||||
MovePos->getParent()->getBasicBlockList().splice(
|
||||
++MovePos->getIterator(), getParent()->getBasicBlockList(),
|
||||
getIterator());
|
||||
}
|
||||
|
||||
const Module *BasicBlock::getModule() const {
|
||||
@@ -196,7 +196,7 @@ BasicBlock::iterator BasicBlock::getFirstInsertionPt() {
|
||||
if (!FirstNonPHI)
|
||||
return end();
|
||||
|
||||
iterator InsertPt = FirstNonPHI;
|
||||
iterator InsertPt = FirstNonPHI->getIterator();
|
||||
if (InsertPt->isEHPad()) ++InsertPt;
|
||||
return InsertPt;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user