X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=include%2Fllvm%2FADT%2Filist.h;h=6aeaa91f1b1671db292ca0bfaf595c251ee9a97f;hb=553e40036af29f9e8dee46812cd2ad90d97225f0;hp=e4d26ddfa50189a1954c1c84e3e0174836938591;hpb=eb751d8c2da1a9b0d84139e19e20288d9b978451;p=oota-llvm.git diff --git a/include/llvm/ADT/ilist.h b/include/llvm/ADT/ilist.h index e4d26ddfa50..6aeaa91f1b1 100644 --- a/include/llvm/ADT/ilist.h +++ b/include/llvm/ADT/ilist.h @@ -38,7 +38,10 @@ #ifndef LLVM_ADT_ILIST_H #define LLVM_ADT_ILIST_H +#include "llvm/Support/Compiler.h" +#include #include +#include #include namespace llvm { @@ -231,17 +234,17 @@ public: pointer getNodePtrUnchecked() const { return NodePtr; } }; -// do not implement. this is to catch errors when people try to use -// them as random access iterators +// These are to catch errors when people try to use them as random access +// iterators. template -void operator-(int, ilist_iterator); +void operator-(int, ilist_iterator) LLVM_DELETED_FUNCTION; template -void operator-(ilist_iterator,int); +void operator-(ilist_iterator,int) LLVM_DELETED_FUNCTION; template -void operator+(int, ilist_iterator); +void operator+(int, ilist_iterator) LLVM_DELETED_FUNCTION; template -void operator+(ilist_iterator,int); +void operator+(ilist_iterator,int) LLVM_DELETED_FUNCTION; // operator!=/operator== - Allow mixed comparisons without dereferencing // the iterator, which could very likely be pointing to end(). @@ -271,12 +274,12 @@ template struct simplify_type; template struct simplify_type > { typedef NodeTy* SimpleType; - static SimpleType getSimplifiedValue(const ilist_iterator &Node) { + static SimpleType getSimplifiedValue(ilist_iterator &Node) { return &*Node; } }; template struct simplify_type > { - typedef NodeTy* SimpleType; + typedef /*const*/ NodeTy* SimpleType; static SimpleType getSimplifiedValue(const ilist_iterator &Node) { return &*Node; @@ -287,7 +290,7 @@ template struct simplify_type > { //===----------------------------------------------------------------------===// // /// iplist - The subset of list functionality that can safely be used on nodes -/// of polymorphic types, i.e. a heterogenous list with a common base class that +/// of polymorphic types, i.e. a heterogeneous list with a common base class that /// holds the next/prev pointers. The only state of the list itself is a single /// pointer to the head of the list. /// @@ -329,8 +332,8 @@ class iplist : public Traits { // No fundamental reason why iplist can't be copyable, but the default // copy/copy-assign won't do. - iplist(const iplist &); // do not implement - void operator=(const iplist &); // do not implement + iplist(const iplist &) LLVM_DELETED_FUNCTION; + void operator=(const iplist &) LLVM_DELETED_FUNCTION; public: typedef NodeTy *pointer; @@ -379,7 +382,9 @@ public: // Miscellaneous inspection routines. size_type max_size() const { return size_type(-1); } - bool empty() const { return Head == 0 || Head == getTail(); } + bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const { + return Head == 0 || Head == getTail(); + } // Front and back accessor functions... reference front() { @@ -462,6 +467,17 @@ public: return where; } + /// Remove all nodes from the list like clear(), but do not call + /// removeNodeFromList() or deleteNode(). + /// + /// This should only be used immediately before freeing nodes in bulk to + /// avoid traversing the list and bringing all the nodes into cache. + void clearAndLeakNodesUnsafely() { + if (Head) { + Head = getTail(); + this->setPrev(Head, Head); + } + } private: // transfer - The heart of the splice function. Move linked list nodes from @@ -469,6 +485,10 @@ private: // void transfer(iterator position, iplist &L2, iterator first, iterator last) { assert(first != last && "Should be checked by callers"); + // Position cannot be contained in the range to be transferred. + // Check for the most common mistake. + assert(position != first && + "Insertion point can't be one of the transferred nodes"); if (position != last) { // Note: we have to be careful about the case when we move the first node @@ -516,7 +536,7 @@ public: // Functionality derived from other functions defined above... // - size_type size() const { + size_type LLVM_ATTRIBUTE_UNUSED_RESULT size() const { if (Head == 0) return 0; // Don't require construction of sentinel if empty. return std::distance(begin(), end()); } @@ -613,7 +633,6 @@ public: template void sort(Pr3 pred); void sort() { sort(op_less); } - void reverse(); }; @@ -651,10 +670,6 @@ struct ilist : public iplist { void push_front(const NodeTy &val) { insert(this->begin(), val); } void push_back(const NodeTy &val) { insert(this->end(), val); } - // Special forms of insert... - template void insert(iterator where, InIt first, InIt last) { - for (; first != last; ++first) insert(where, *first); - } void insert(iterator where, size_type count, const NodeTy &val) { for (; count != 0; --count) insert(where, val); }