-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[ADT] Use adl_*
wrappers across STLExtras
#87936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Update the remaining uses of `std::begin`/`end` functions to `adl_beging`/`end`. This is to make the behavior all the utility functions consistent, rather than trying to fix a specific usecase.
@llvm/pr-subscribers-llvm-adt Author: Jakub Kuderski (kuhar) ChangesUpdate the remaining uses of Full diff: https://github.com/llvm/llvm-project/pull/87936.diff 1 Files Affected:
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index 08a708e5c5871e..f906f7acfc1c4a 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -320,7 +320,8 @@ template <typename T> class Callable<T, true> {
/// Returns true if the given container only contains a single element.
template <typename ContainerTy> bool hasSingleElement(ContainerTy &&C) {
- auto B = std::begin(C), E = std::end(C);
+ auto B = adl_begin(C);
+ auto E = adl_end(C);
return B != E && std::next(B) == E;
}
@@ -375,8 +376,7 @@ inline mapped_iterator<ItTy, FuncTy> map_iterator(ItTy I, FuncTy F) {
template <class ContainerTy, class FuncTy>
auto map_range(ContainerTy &&C, FuncTy F) {
- return make_range(map_iterator(std::begin(C), F),
- map_iterator(std::end(C), F));
+ return make_range(map_iterator(adl_begin(C), F), map_iterator(adl_end(C), F));
}
/// A base type of mapped iterator, that is useful for building derived
@@ -572,11 +572,11 @@ iterator_range<filter_iterator<detail::IterOfRange<RangeT>, PredicateT>>
make_filter_range(RangeT &&Range, PredicateT Pred) {
using FilterIteratorT =
filter_iterator<detail::IterOfRange<RangeT>, PredicateT>;
- return make_range(
- FilterIteratorT(std::begin(std::forward<RangeT>(Range)),
- std::end(std::forward<RangeT>(Range)), Pred),
- FilterIteratorT(std::end(std::forward<RangeT>(Range)),
- std::end(std::forward<RangeT>(Range)), Pred));
+ return make_range(FilterIteratorT(adl_begin(std::forward<RangeT>(Range)),
+ adl_end(std::forward<RangeT>(Range)), Pred),
+ FilterIteratorT(adl_end(std::forward<RangeT>(Range)),
+ adl_end(std::forward<RangeT>(Range)),
+ Pred));
}
/// A pseudo-iterator adaptor that is designed to implement "early increment"
@@ -656,8 +656,8 @@ iterator_range<early_inc_iterator_impl<detail::IterOfRange<RangeT>>>
make_early_inc_range(RangeT &&Range) {
using EarlyIncIteratorT =
early_inc_iterator_impl<detail::IterOfRange<RangeT>>;
- return make_range(EarlyIncIteratorT(std::begin(std::forward<RangeT>(Range))),
- EarlyIncIteratorT(std::end(std::forward<RangeT>(Range))));
+ return make_range(EarlyIncIteratorT(adl_begin(std::forward<RangeT>(Range))),
+ EarlyIncIteratorT(adl_end(std::forward<RangeT>(Range))));
}
// Forward declarations required by zip_shortest/zip_equal/zip_first/zip_longest
@@ -1097,8 +1097,8 @@ class concat_iterator
/// We need the full range to know how to switch between each of the
/// iterators.
template <typename... RangeTs>
- explicit concat_iterator(RangeTs &&... Ranges)
- : Begins(std::begin(Ranges)...), Ends(std::end(Ranges)...) {}
+ explicit concat_iterator(RangeTs &&...Ranges)
+ : Begins(adl_begin(Ranges)...), Ends(adl_end(Ranges)...) {}
using BaseT::operator++;
@@ -1127,13 +1127,12 @@ template <typename ValueT, typename... RangeTs> class concat_range {
public:
using iterator =
concat_iterator<ValueT,
- decltype(std::begin(std::declval<RangeTs &>()))...>;
+ decltype(adl_begin(std::declval<RangeTs &>()))...>;
private:
std::tuple<RangeTs...> Ranges;
- template <size_t... Ns>
- iterator begin_impl(std::index_sequence<Ns...>) {
+ template <size_t... Ns> iterator begin_impl(std::index_sequence<Ns...>) {
return iterator(std::get<Ns>(Ranges)...);
}
template <size_t... Ns>
@@ -1141,12 +1140,12 @@ template <typename ValueT, typename... RangeTs> class concat_range {
return iterator(std::get<Ns>(Ranges)...);
}
template <size_t... Ns> iterator end_impl(std::index_sequence<Ns...>) {
- return iterator(make_range(std::end(std::get<Ns>(Ranges)),
- std::end(std::get<Ns>(Ranges)))...);
+ return iterator(make_range(adl_end(std::get<Ns>(Ranges)),
+ adl_end(std::get<Ns>(Ranges)))...);
}
template <size_t... Ns> iterator end_impl(std::index_sequence<Ns...>) const {
- return iterator(make_range(std::end(std::get<Ns>(Ranges)),
- std::end(std::get<Ns>(Ranges)))...);
+ return iterator(make_range(adl_end(std::get<Ns>(Ranges)),
+ adl_end(std::get<Ns>(Ranges)))...);
}
public:
@@ -1420,7 +1419,7 @@ template <typename EltTy, typename FirstTy> class first_or_second_type {
/// Given a container of pairs, return a range over the first elements.
template <typename ContainerTy> auto make_first_range(ContainerTy &&c) {
- using EltTy = decltype((*std::begin(c)));
+ using EltTy = decltype((*adl_begin(c)));
return llvm::map_range(std::forward<ContainerTy>(c),
[](EltTy elt) -> typename detail::first_or_second_type<
EltTy, decltype((elt.first))>::type {
@@ -1430,7 +1429,7 @@ template <typename ContainerTy> auto make_first_range(ContainerTy &&c) {
/// Given a container of pairs, return a range over the second elements.
template <typename ContainerTy> auto make_second_range(ContainerTy &&c) {
- using EltTy = decltype((*std::begin(c)));
+ using EltTy = decltype((*adl_begin(c)));
return llvm::map_range(
std::forward<ContainerTy>(c),
[](EltTy elt) ->
@@ -2106,7 +2105,7 @@ template<typename Container, typename Range = std::initializer_list<
typename Container::value_type>>
void replace(Container &Cont, typename Container::iterator ContIt,
typename Container::iterator ContEnd, Range R) {
- replace(Cont, ContIt, ContEnd, R.begin(), R.end());
+ replace(Cont, ContIt, ContEnd, adl_begin(R), adl_begin(R));
}
/// An STL-style algorithm similar to std::for_each that applies a second
@@ -2519,19 +2518,19 @@ bool hasNItemsOrLess(
/// Returns true if the given container has exactly N items
template <typename ContainerTy> bool hasNItems(ContainerTy &&C, unsigned N) {
- return hasNItems(std::begin(C), std::end(C), N);
+ return hasNItems(adl_begin(C), adl_end(C), N);
}
/// Returns true if the given container has N or more items
template <typename ContainerTy>
bool hasNItemsOrMore(ContainerTy &&C, unsigned N) {
- return hasNItemsOrMore(std::begin(C), std::end(C), N);
+ return hasNItemsOrMore(adl_begin(C), adl_end(C), N);
}
/// Returns true if the given container has N or less items
template <typename ContainerTy>
bool hasNItemsOrLess(ContainerTy &&C, unsigned N) {
- return hasNItemsOrLess(std::begin(C), std::end(C), N);
+ return hasNItemsOrLess(adl_begin(C), adl_end(C), N);
}
/// Returns a raw pointer that represents the same address as the argument.
|
Reverts #87936 Seems like this broke some clang designated initializers tests, reverting.
Could be nice to include unit test coverage for these changes... |
Yep. I'm low on cycles recently, but unless I can easily figure out why the clang initializer test failed, I will break this up and start landing piece by piece. |
This is to make sure that ADT helpers consistently use argument dependent lookup when dealing with input ranges. This was a part of llvm#87936 but reverted due to buildbot failures. Now that I have a threadripper system, I'm landing this piece-by-piece.
This is to make sure that ADT helpers consistently use argument dependent lookup when dealing with input ranges. This was a part of llvm#87936 but reverted due to buildbot failures.
This is to make sure that ADT helpers consistently use argument dependent lookup when dealing with input ranges. This was a part of #87936 but reverted due to buildbot failures. Now that I have a threadripper system, I'm landing this piece-by-piece.
This is to make sure that ADT helpers consistently use argument dependent lookup when dealing with input ranges. This was a part of llvm#87936 but reverted due to buildbot failures. Also fix potential issue with double-move on the input range.
This is to make sure that ADT helpers consistently use argument dependent lookup when dealing with input ranges. This was a part of llvm#87936 but reverted due to buildbot failures.
This is to make sure that ADT helpers consistently use argument dependent lookup when dealing with input ranges. This was a part of llvm#87936 but reverted due to buildbot failures.
This is to make sure that ADT helpers consistently use argument dependent lookup when dealing with input ranges. This was a part of llvm#87936 but reverted due to buildbot failures. This PR is stacked on top of llvm#130508.
This is to make sure that ADT helpers consistently use argument dependent lookup when dealing with input ranges. This was a part of llvm#87936 but reverted due to buildbot failures. Also clean up the implementation to adhere to the llvm coding standards.
This is to make sure that ADT helpers consistently use argument dependent lookup when dealing with input ranges. This was a part of #87936 but reverted due to buildbot failures. Also fix potential issue with double-move on the input range.
This is to make sure that ADT helpers consistently use argument dependent lookup when dealing with input ranges. This was a part of #87936 but reverted due to buildbot failures. Also add `map_range` unit tests -- there were no pre-existing tests AFAICT.
This is to make sure that ADT helpers consistently use argument dependent lookup when dealing with input ranges. This was a part of llvm#87936 but reverted due to buildbot failures. This PR is stacked on top of llvm#130508.
This is to make sure that ADT helpers consistently use argument dependent lookup when dealing with input ranges. This was a part of #87936 but reverted due to buildbot failures.
…nge (#130521) This is to make sure that ADT helpers consistently use argument dependent lookup when dealing with input ranges. This was a part of llvm/llvm-project#87936 but reverted due to buildbot failures.
Update: This should be fully landed now. I don't see any other uses of |
Update the remaining uses of
std::begin
/end
functions toadl_beging
/end
. This is to make the behavior all the utility functions consistent, rather than trying to fix a specific usecase.