summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/IListTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* ADT: Never allocate nodes in iplist<> and ilist<>Duncan P. N. Exon Smith2016-09-111-8/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | Remove createNode() and any API that depending on it, and add HasCreateNode to the list of checks for HasObsoleteCustomizations. Now an ilist *never* allocates (this was already true for iplist). This factors out all the differences between iplist and ilist. I'll aim to rename both to "owning_ilist" eventually, to call out the interesting (not exactly intrusive) ownership semantics. In the meantime, I've left both names around to reduce code churn. One of the deleted APIs is the ilist copy constructor. I've lifted up and tested iplist::cloneFrom (ala simple_ilist::cloneFrom) as a replacement. Users of ilist<> and iplist<> that want the list to allocate nodes have a few options: - use std::list; - use AllocatorList or BumpPtrList (or build a similarly trivial list); - use cloneFrom (which is explicit at the call site); or - allocate at the call site. See r280573, r281177, r281181, and r281182 for examples of what to do if you're updating out-of-tree code. llvm-svn: 281184
* ADT: Move ilist_node_access to ilist_detail::NodeAccess...Duncan P. N. Exon Smith2016-09-101-1/+1
| | | | | | | | | | | | | | | | | ... and make a few ilist-internal API changes, in preparation for changing how ilist_node is templated. The only effect for ilist users should be changing the friend target from llvm::ilist_node_access to llvm::ilist_detail::NodeAccess (which is only necessary when they inherit privately from ilist_node). - Split out SpecificNodeAccess, which has overloads of getNodePtr and getValuePtr that are untemplated. - Use more typedefs to prevent more changes later. - Force inheritance to use *NodeAccess (to emphasize that ilist *users* shouldn't be doing this). There should be no functionality change here. llvm-svn: 281142
* ADT: Fix up IListTest.privateNode and get it passingDuncan P. N. Exon Smith2016-09-031-3/+3
| | | | | | | | This test was using the wrong type, and so not actually testing much. ilist_iterator constructors weren't going through ilist_node_access, so they didn't actually work with private inheritance. llvm-svn: 280564
* ADT: Split ilist_node_traits into alloc and callback, NFCDuncan P. N. Exon Smith2016-08-301-9/+25
| | | | | | | | | | | | | | | | Many lists want to override only allocation semantics, or callbacks for iplist. Split these up to prevent code duplication. - Specialize ilist_alloc_traits to change the implementations of deleteNode() and createNode(). - One common desire is to do nothing deleteNode() and disable createNode(). Specialize ilist_alloc_traits to inherit from ilist_noalloc_traits for that behaviour. - Specialize ilist_callback_traits to use the addNodeToList(), removeNodeFromList(), and transferNodesFromList() callbacks. As a drive-by, add some coverage to the callback-related unit tests. llvm-svn: 280128
* Rename unittests/ADT/ilistTestTemp.cpp => IListTest.cppDuncan P. N. Exon Smith2016-08-301-0/+229
And rename the tests inside from ilistTest to IListTest. This makes the file sort properly in the CMakeLists.txt (previously, sorting would throw it down to the end of the list) and is consistent with the tests I've added more recently. Why use IListNodeBaseTest.cpp (and a test name of IListNodeBaseTest)? - ilist_node_base_test is the obvious thing, since this is testing ilist_node_base. However, gtest disallows underscores in test names. - ilist_node_baseTest fails for the same reason. - ilistNodeBaseTest is weird, because it isn't in our usual TitleCaseTest form that we use for tests, and it also doesn't have the name of the tested class in it. - IlistNodeBaseTest matches TitleCaseTest, but "Ilist" is hard to read, and really "ilist" is an abbreviation for "IntrusiveList" so the lowercase "list" is strange. - That left IListNodeBaseTest. Note: I made this move in two stages, with a temporary filename of ilistTestTemp in between in r279524. This was in the hopes of avoiding problems on Git and SVN clients on case-insensitive filesystems, particularly on buildbots with incremental checkouts. llvm-svn: 280033
OpenPOWER on IntegriCloud