summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/IteratorTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [ADT] drop_begin: use adl_begin/adl_end. NFC.Michael Kruse2018-06-271-0/+13
| | | | | | | | | | | | | | | | | | | Summary: The instantiation of the drop_begin function template usually fails because the functions begin() and end() do not exist. Only when using on a container from the std namespace (or `llvm::iterator_range`s of something derived from `std::iterator`), they are matched to std::begin() and std::end() due to Koenig-lookup. Explicitly use llvm::adl_begin and llvm::adl_end to make drop_begin applicable to anything iterable (including C-style arrays). A solution for general `llvm::iterator_range`s was already tried in r244620, but got reverted in r244621 due to MSVC not liking it. Reviewers: dblaikie, grosbach, aaron.ballman, ruiu Reviewed By: dblaikie, aaron.ballman Subscribers: aaron.ballman, llvm-commits Differential Revision: https://reviews.llvm.org/D48598 llvm-svn: 335772
* [ADT] Pass DerivedT from pointe{e,r}_iterator to iterator_adaptor_baseJustin Bogner2018-06-271-0/+14
| | | | | | | These were passing the wrong type into iterator_adaptor_base if T was anything but the default. llvm-svn: 335698
* [STLExtras] Add size() for ranges, and remove distance()Vedant Kumar2018-05-161-2/+2
| | | | | | | | | | r332057 introduced distance() for ranges. Based on post-commit feedback, this renames distance() to size(). The new size() is also only enabled when the operation is O(1). Differential Revision: https://reviews.llvm.org/D46976 llvm-svn: 332551
* [STLExtras] Add distance() for ranges, pred_size(), and succ_size()Vedant Kumar2018-05-101-0/+8
| | | | | | | | | | | This commit adds a wrapper for std::distance() which works with ranges. As it would be a common case to write `distance(predecessors(BB))`, this also introduces `pred_size()` and `succ_size()` helpers to make that easier to write. Differential Revision: https://reviews.llvm.org/D46668 llvm-svn: 332057
* [ADT] Make filter_iterator support bidirectional iterationVedant Kumar2018-04-251-0/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes it possible to reverse a filtered range. For example, here's a way to visit memory accesses in a BasicBlock in reverse order: auto MemInsts = reverse(make_filter_range(BB, [](Instruction &I) { return isa<StoreInst>(&I) || isa<LoadInst>(&I); })); for (auto &MI : MemInsts) ... To implement this functionality, I factored out forward iteration functionality into filter_iterator_base, and added a specialization of filter_iterator_impl which supports bidirectional iteration. Thanks to Tim Shen, Zachary Turner, and others for suggesting this design and providing feedback! This version of the patch supersedes the original (https://reviews.llvm.org/D45792). This was motivated by a problem we encountered in D45657: we'd like to visit the non-debug-info instructions in a BasicBlock in reverse order. Testing: check-llvm, check-clang Differential Revision: https://reviews.llvm.org/D45853 llvm-svn: 330875
* Re-sort #include lines for unittests. This uses a slightly modifiedChandler Carruth2017-06-061-1/+1
| | | | | | | | | | | | | | | clang-format (https://reviews.llvm.org/D33932) to keep primary headers at the top and handle new utility headers like 'gmock' consistently with other utility headers. No other change was made. I did no manual edits, all of this is clang-format. This should allow other changes to have more clear and focused diffs, and is especially motivated by moving some headers into more focused libraries. llvm-svn: 304786
* ADT: Add range helpers for pointer_ and pointee_iteratorJustin Bogner2017-03-271-0/+16
| | | | llvm-svn: 298841
* [ADT] Fix zip iterator interface.Bryant Wong2017-02-231-4/+53
| | | | | | | | | | | | This commit provides `zip_{first,shortest}` with the standard member types and methods expected of iterators (e.g., `difference_type`), in order for zip to be used with other adaptors, such as `make_filter_range`. Support for reverse iteration has also been added. Differential Revision: https://reviews.llvm.org/D30246 llvm-svn: 296036
* [ADT] Zip range adapterMehdi Amini2016-10-191-0/+63
| | | | | | | | | | | | | | | This augments the STLExtras toolset with a zip iterator and range adapter. Zip comes in two varieties: `zip`, which will zip to the shortest of the input ranges, and `zip_first`, which limits its `begin() == end()` checks to just the first range. Recommit r284035 after MSVC2013 support has been dropped. Patch by: Bryant Wong <github.com/bryant> Differential Revision: https://reviews.llvm.org/D23252 llvm-svn: 284623
* Revert "[ADT] Zip range adapter"Mehdi Amini2016-10-121-63/+0
| | | | | | This reverts commit r284035, which breaks with MSVC 2013. llvm-svn: 284037
* [ADT] Zip range adapterMehdi Amini2016-10-121-0/+63
| | | | | | | | | | | | | This augments the STLExtras toolset with a zip iterator and range adapter. Zip comes in two varieties: `zip`, which will zip to the shortest of the input ranges, and `zip_first`, which limits its `begin() == end()` checks to just the first krange. Patch by: Bryant Wong <github.com/bryant> Differential Revision: https://reviews.llvm.org/D23252 llvm-svn: 284035
* [ADT] Don't use make_pointee_iterator in IteratorTest.Justin Lebar2016-10-101-25/+20
| | | | llvm-svn: 283794
* [ADT] Add make_pointe{e,r}_iterator.Justin Lebar2016-10-101-20/+25
| | | | | | | | | | Reviewers: timshen Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D25418 llvm-svn: 283765
* Move unittests/Support/IteratorTest.cpp to unittests/ADT/Duncan P. N. Exon Smith2016-08-201-0/+212
This testing stuff from ADT, not Support. Fix the file location. llvm-svn: 279372
OpenPOWER on IntegriCloud