summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/ADT/STLExtrasTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [ADT] Move drop_begin from iterator_range.h into STLExtras.Lang Hames2019-11-141-0/+13
| | | | | | | | | | | | | | | | | Summary: drop_begin depends on adl_begin/adl_end, which are defined in STLExtras.h, but we can't just #include STLExtras.h in iterator_range.h as that would introduce a circular reference (STLExtras.h already depends on iterator_range.h). The simplest solution is to move drop_begin into STLExtras.h, which is a reasonable home for it anyway. Reviewers: dblaikie Subscribers: dexonsmith, ributzka, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D70189
* [llvm] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-151-1/+1
| | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. llvm-svn: 369013
* Cleanup: llvm::bsearch -> llvm::partition_point after r364719Fangrui Song2019-06-301-4/+5
| | | | llvm-svn: 364720
* [ADT] Implement llvm::bsearch() with std::partition_point()Fangrui Song2019-06-301-12/+0
| | | | | | | | | | | | | | | | | | | Summary: Delete the begin-end form because the standard std::partition_point can be easily used as a replacement. The ranges-style llvm::bsearch will be renamed to llvm::partition_point in the next clean-up patch. The name "bsearch" doesn't meet people's expectation because in C: > If two or more members compare equal, which member is returned is unspecified. Reviewed By: sammccall Differential Revision: https://reviews.llvm.org/D63718 llvm-svn: 364719
* [ADT] Avoid warning in bsearch testcaseSam McCall2019-04-201-3/+3
| | | | llvm-svn: 358811
* [ADT] llvm::bsearch, binary search for mere mortalsSam McCall2019-04-161-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Add to STLExtras a binary search function with a simple mental model: You provide a range and a predicate which is true above a certain point. bsearch() tells you that point. Overloads are provided for integers, iterators, and containers. This is more suitable than std:: alternatives in many cases: - std::binary_search only indicates presence/absence - upper_bound/lower_bound give you the opportunity to pick the wrong one - all of the options have confusing names and definitions when your predicate doesn't have simple "less than" semantics - all of the options require iterators - we plumb around a useless `value` parameter that should be a lambda capture The API is inspired by Go's standard library, but we add an extra parameter as well as some overloads and templates to show how clever C++ is. Reviewers: ilya-biryukov, gribozavr Subscribers: dexonsmith, kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D60779 llvm-svn: 358540
* Add partial implementation of std::to_address() as llvm::to_address()Daniel Sanders2019-02-201-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Following on from the review for D58088, this patch provides the prerequisite to_address() implementation that's needed to have pointer_iterator support unique_ptr. The late bound return should be removed once we move to C++14 to better align with the C++20 declaration. Also, this implementation can be removed once we move to C++20 where it's defined as std::to_addres() The std::pointer_traits<>::to_address(p) variations of these overloads has not been implemented. Reviewers: dblaikie, paquette Reviewed By: dblaikie Subscribers: dexonsmith, kristina, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58421 llvm-svn: 354491
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* 2nd attempt to fix ambiguities because of ADLMatthias Braun2018-10-311-9/+6
| | | | llvm-svn: 345690
* Try to fix ambiguities with C++17 headers in unittestMatthias Braun2018-10-311-0/+3
| | | | llvm-svn: 345689
* ADT/STLExtras: Introduce llvm::empty; NFCMatthias Braun2018-10-311-0/+17
| | | | | | | | This is modeled after C++17 std::empty(). Differential Revision: https://reviews.llvm.org/D53909 llvm-svn: 345679
* [MISC]Fix wrong usage of std::equal()Chen Zheng2018-08-171-0/+15
| | | | | | Differential Revision: https://reviews.llvm.org/D49958 llvm-svn: 340000
* [ADT] Add an early-increment iterator-like type and range adaptor.Chandler Carruth2018-08-041-0/+51
| | | | | | | | | | | | | | This allows us to model the common LLVM idiom of incrementing immediately after dereferencing so that we can remove or update the entity w/o losing our ability to reach the "next". However, these are not real or proper iterators. They are just enough to allow range based for loops and very simple range algorithms to work, but should not be considered full general. Differential Revision: https://reviews.llvm.org/D49956 llvm-svn: 338955
* [unittests] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang2018-04-071-2/+2
| | | | | | | | | | | | | | | r327219 added wrappers to std::sort which randomly shuffle the container before sorting. This will help in uncovering non-determinism caused due to undefined sorting order of objects having the same key. To make use of that infrastructure we need to invoke llvm::sort instead of std::sort. Note: This patch is one of a series of patches to replace *all* std::sort to llvm::sort. Refer the comments section in D44363 for a list of all the required patches. llvm-svn: 329475
* Add ADL support to range based <algorithm> extensionsDavid Blaikie2017-11-201-14/+52
| | | | | | | | | | | | | | | | | This adds support for ADL in the range based <algorithm> extensions (llvm::for_each etc.). Also adds the helper functions llvm::adl::begin and llvm::adl::end which wrap std::begin and std::end with ADL support. Saw this was missing from a recent llvm weekly post about adding llvm::for_each and thought I might add it. Patch by Stephen Dollberg! Differential Revision: https://reviews.llvm.org/D40006 llvm-svn: 318703
* Add llvm::for_each as a range-based extensions to <algorithm> and make use ↵Aaron Ballman2017-11-031-6/+14
| | | | | | of it in some cases where it is a more clear alternative to std::for_each. llvm-svn: 317356
* Fix sign compare warning in unit test by using an explicit unsigned literal ↵David Blaikie2017-03-131-1/+1
| | | | | | suffix llvm-svn: 297674
* [ADT] Improve the genericity of llvm::enumerate().Zachary Turner2017-03-131-7/+17
| | | | | | | | | | | | | | There were some issues in the implementation of enumerate() preventing it from being used in various contexts. These were all related to the fact that it did not supporter llvm's iterator_facade_base class. So this patch adds support for that and additionally exposes a new helper method to_vector() that will evaluate an entire range and store the results in a vector. Differential Revision: https://reviews.llvm.org/D30853 llvm-svn: 297633
* [Unittests] Fix a build failure with clang 3.8. NFCI.Davide Italiano2017-03-091-1/+1
| | | | llvm-svn: 297423
* [ADT] Add an llvm::erase_if utility to make the standard erase+remove_ifChandler Carruth2016-12-261-0/+11
| | | | | | | | pattern easier to write. Differential Revision: https://reviews.llvm.org/D28120 llvm-svn: 290555
* [ADT] Add a boring std::partition wrapper similar to our std::remove_ifChandler Carruth2016-12-261-0/+21
| | | | | | wrapper. llvm-svn: 290553
* [ADT] Add a generic concatenating iterator and range (take 2).Chandler Carruth2016-12-251-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | This recommits r290512 that was reverted when MSVC failed to compile it. Since then I've played with various approaches using rextester.com (where I was able to reproduce the failure) and think that I have a solution thanks in part to the help of Dave Blaikie! It seems MSVC just has a defective `decltype` in this version. Manually writing out the type seems to do the trick, even though it is .... quite complicated. Original commit message: This allows both defining convenience iterator/range accessors on types which walk across N different independent ranges within the object, and more direct and simple usages with range based for loops such as shown in the unittest. The same facilities are used for both. They end up quite small and simple as it happens. I've also switched an iterator on `Module` to use this. I would like to add another convenience iterator that includes even more sequences as part of it and seeing this one already present motivated me to actually abstract it away and introduce a general utility. Differential Revision: https://reviews.llvm.org/D28093 llvm-svn: 290528
* Revert r290512: [ADT] Add a generic concatenating iterator and range.Chandler Carruth2016-12-251-23/+0
| | | | | | | | This code doesn't work on MSVC for reasons that elude me and I've not yet covinced a workaround to compile cleanly so reverting for now while I play with it. llvm-svn: 290513
* [ADT] Add a generic concatenating iterator and range.Chandler Carruth2016-12-251-0/+23
| | | | | | | | | | | | | | | | | This allows both defining convenience iterator/range accessors on types which walk across N different independent ranges within the object, and more direct and simple usages with range based for loops such as shown in the unittest. The same facilities are used for both. They end up quite small and simple as it happens. I've also switched an iterator on `Module` to use this. I would like to add another convenience iterator that includes even more sequences as part of it and seeing this one already present motivated me to actually abstract it away and introduce a general utility. Differential Revision: https://reviews.llvm.org/D28093 llvm-svn: 290512
* [stl-extras] Provide an adaptor of std::count for ranges.Michael Gottesman2016-12-041-0/+17
| | | | llvm-svn: 288619
* [unittests] STLExtrasTest: Remove an MSVC 2013 workaround, NFCI.Vedant Kumar2016-10-251-2/+1
| | | | | | Let's see what the bots have to say about this... llvm-svn: 285091
* Rename llvm::apply -> llvm::apply_tuple.Zachary Turner2016-10-101-3/+3
| | | | | | | | | | | llvm::cl already has a function called llvm::apply() so this is causing an ODR violation. The STLExtras version should win the vote on which one gets to be called apply() since it is named after the equivalent STL function, but since renaiming the cl version is more difficult, let's do this for now to get the bots green. llvm-svn: 283800
* Add llvm::apply to STLExtras.Zachary Turner2016-10-101-0/+45
| | | | | | | | | This is equivalent to the C++14 std::apply(). Since we are not using C++14 yet, this allows us to still make use of apply anyway. Differential revision: https://reviews.llvm.org/D25100 llvm-svn: 283779
* Remove extra semicolonReid Kleckner2016-10-051-1/+1
| | | | llvm-svn: 283395
* Fix the build with MSVC 2013, still cannot default move ctors yetReid Kleckner2016-10-051-1/+2
| | | | | | Ten days. llvm-svn: 283394
* Fix build due to comparison of std::pairs.Zachary Turner2016-10-051-16/+20
| | | | llvm-svn: 283342
* Add llvm::enumerate() range adapter.Zachary Turner2016-10-051-27/+128
| | | | | | | | | This allows you to enumerate over a range using a range-based for while the return type contains the index of the enumeration. Differential revision: https://reviews.llvm.org/D25124 llvm-svn: 283337
* Resubmit "Add llvm::enumerate() to STLExtras."Zachary Turner2016-09-301-0/+49
| | | | | | | | The CL was originally failing due to the use of some C++14 specific features, so I've removed those. Hopefully this will satisfy the bots. llvm-svn: 282867
* Revert "Add llvm::enumerate() to STLExtras."Zachary Turner2016-09-291-49/+0
| | | | | | | This reverts commit r282804 as it seems to use some C++ features that not all compilers support. llvm-svn: 282809
* Add llvm::enumerate() to STLExtras.Zachary Turner2016-09-291-0/+49
| | | | | | | | | enumerate allows you to iterate over a range by pairing the iterator's value with its index in the enumeration. This gives you most of the benefits of using a for loop while still allowing the range syntax. llvm-svn: 282804
* [ADT] Add the worlds simplest STL extra. Or at least close to it.Chandler Carruth2016-08-191-0/+40
This is a little class template that just builds an inheritance chain of empty classes. Despite how simple this is, it can be used to really nicely create ranked overload sets. I've added a unittest as much to document this as test it. You can pass an object of this type as an argument to a function overload set an it will call the first viable and enabled candidate at or below the rank of the object. I'm planning to use this in a subsequent commit to more clearly rank overload candidates used for SFINAE. All credit for this technique and both lines of code here to Richard Smith who was helping me rewrite the SFINAE check in question to much more effectively capture the intended set of checks. llvm-svn: 279197
OpenPOWER on IntegriCloud