[llvm] r261499 - ADT: Disallow == and != between pointers and ilist iterators

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 21 12:46:37 PST 2016


Author: dexonsmith
Date: Sun Feb 21 14:46:37 2016
New Revision: 261499

URL: http://llvm.org/viewvc/llvm-project?rev=261499&view=rev
Log:
ADT: Disallow == and != between pointers and ilist iterators

I completely missed these non-class operators when I removed the
implicit conversions in r252380.  Remove them now.  r261498 should have
already removed all uses.

Note (repeated from r252380): if you have out-of-tree code, it should be
fairly easy to revert this patch downstream while you update your
out-of-tree call sites.  Note that these conversions are occasionally
latent bugs (that may happen to "work" now, but only because of getting
lucky with UB; follow-ups will change your luck).  When they are valid,
I suggest using `->getIterator()` to go from pointer to iterator, and
`&*` to go from iterator to pointer.

Modified:
    llvm/trunk/include/llvm/ADT/ilist.h

Modified: llvm/trunk/include/llvm/ADT/ilist.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/ilist.h?rev=261499&r1=261498&r2=261499&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/ilist.h (original)
+++ llvm/trunk/include/llvm/ADT/ilist.h Sun Feb 21 14:46:37 2016
@@ -263,26 +263,6 @@ public:
   pointer getNodePtrUnchecked() const { return NodePtr; }
 };
 
-// operator!=/operator== - Allow mixed comparisons without dereferencing
-// the iterator, which could very likely be pointing to end().
-template<typename T>
-bool operator!=(const T* LHS, const ilist_iterator<const T> &RHS) {
-  return LHS != RHS.getNodePtrUnchecked();
-}
-template<typename T>
-bool operator==(const T* LHS, const ilist_iterator<const T> &RHS) {
-  return LHS == RHS.getNodePtrUnchecked();
-}
-template<typename T>
-bool operator!=(T* LHS, const ilist_iterator<T> &RHS) {
-  return LHS != RHS.getNodePtrUnchecked();
-}
-template<typename T>
-bool operator==(T* LHS, const ilist_iterator<T> &RHS) {
-  return LHS == RHS.getNodePtrUnchecked();
-}
-
-
 // Allow ilist_iterators to convert into pointers to a node automatically when
 // used by the dyn_cast, cast, isa mechanisms...
 




More information about the llvm-commits mailing list