summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Globals.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-10-08 23:49:46 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2015-10-08 23:49:46 +0000
commit52888a673859a5047acd08d60b43f173d126c8e7 (patch)
tree9ef0445b493863e9e6e4a7fa269e91ba8bab0f58 /llvm/lib/IR/Globals.cpp
parent5a9640be324cf3ede6aa6ba714266b3bddf32db4 (diff)
downloadbcm5719-llvm-52888a673859a5047acd08d60b43f173d126c8e7.tar.gz
bcm5719-llvm-52888a673859a5047acd08d60b43f173d126c8e7.zip
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.) llvm-svn: 249782
Diffstat (limited to 'llvm/lib/IR/Globals.cpp')
-rw-r--r--llvm/lib/IR/Globals.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 11ece2ed1b1..8fde4b8e9d7 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -178,7 +178,7 @@ GlobalVariable::GlobalVariable(Module &M, Type *Ty, bool constant,
}
if (Before)
- Before->getParent()->getGlobalList().insert(Before, this);
+ Before->getParent()->getGlobalList().insert(Before->getIterator(), this);
else
M.getGlobalList().push_back(this);
}
@@ -188,11 +188,11 @@ void GlobalVariable::setParent(Module *parent) {
}
void GlobalVariable::removeFromParent() {
- getParent()->getGlobalList().remove(this);
+ getParent()->getGlobalList().remove(getIterator());
}
void GlobalVariable::eraseFromParent() {
- getParent()->getGlobalList().erase(this);
+ getParent()->getGlobalList().erase(getIterator());
}
void GlobalVariable::setInitializer(Constant *InitVal) {
@@ -276,11 +276,11 @@ void GlobalAlias::setParent(Module *parent) {
}
void GlobalAlias::removeFromParent() {
- getParent()->getAliasList().remove(this);
+ getParent()->getAliasList().remove(getIterator());
}
void GlobalAlias::eraseFromParent() {
- getParent()->getAliasList().erase(this);
+ getParent()->getAliasList().erase(getIterator());
}
void GlobalAlias::setAliasee(Constant *Aliasee) {
OpenPOWER on IntegriCloud