From 52888a673859a5047acd08d60b43f173d126c8e7 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Thu, 8 Oct 2015 23:49:46 +0000 Subject: 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 --- llvm/lib/IR/Module.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/IR/Module.cpp') diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp index 21dfb0912fc..2b9adad44ba 100644 --- a/llvm/lib/IR/Module.cpp +++ b/llvm/lib/IR/Module.cpp @@ -277,7 +277,7 @@ NamedMDNode *Module::getOrInsertNamedMetadata(StringRef Name) { /// delete it. void Module::eraseNamedMetadata(NamedMDNode *NMD) { static_cast *>(NamedMDSymTab)->erase(NMD->getName()); - NamedMDList.erase(NMD); + NamedMDList.erase(NMD->getIterator()); } bool Module::isValidModFlagBehavior(Metadata *MD, ModFlagBehavior &MFB) { -- cgit v1.2.3