mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-24 06:10:12 +00:00
Replace llvm::integer_sequence and friends with the C++14 standard version
The implementation in libc++ takes O(1) compile time, ours was O(n). llvm-svn: 368990
This commit is contained in:
parent
d596dd8113
commit
37508d3dd9
@ -59,14 +59,14 @@ private:
|
||||
public:
|
||||
template <class... RestArgs>
|
||||
auto operator()(RestArgs &&... Rest)
|
||||
-> decltype(this->CallImpl(llvm::index_sequence_for<Args...>(),
|
||||
-> decltype(this->CallImpl(std::index_sequence_for<Args...>(),
|
||||
std::forward<RestArgs>(Rest)...)) {
|
||||
|
||||
#ifndef NDEBUG
|
||||
assert(!WasCalled && "Can only call result of Bind once.");
|
||||
WasCalled = true;
|
||||
#endif
|
||||
return CallImpl(llvm::index_sequence_for<Args...>(),
|
||||
return CallImpl(std::index_sequence_for<Args...>(),
|
||||
std::forward<RestArgs>(Rest)...);
|
||||
}
|
||||
};
|
||||
|
@ -89,12 +89,12 @@ public:
|
||||
|
||||
template <typename T> operator Matcher<const std::vector<T> &>() const {
|
||||
return ::testing::MakeMatcher(new SubsequenceMatcher<T>(
|
||||
TypedMatchers<T>(llvm::index_sequence_for<M...>{})));
|
||||
TypedMatchers<T>(std::index_sequence_for<M...>{})));
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename T, size_t... I>
|
||||
std::vector<Matcher<T>> TypedMatchers(llvm::index_sequence<I...>) const {
|
||||
std::vector<Matcher<T>> TypedMatchers(std::index_sequence<I...>) const {
|
||||
return {std::get<I>(Matchers)...};
|
||||
}
|
||||
};
|
||||
|
@ -1334,14 +1334,14 @@ public:
|
||||
template <typename T> operator Matcher<T>() const {
|
||||
return DynTypedMatcher::constructVariadic(
|
||||
Op, ast_type_traits::ASTNodeKind::getFromNodeKind<T>(),
|
||||
getMatchers<T>(llvm::index_sequence_for<Ps...>()))
|
||||
getMatchers<T>(std::index_sequence_for<Ps...>()))
|
||||
.template unconditionalConvertTo<T>();
|
||||
}
|
||||
|
||||
private:
|
||||
// Helper method to unpack the tuple into a vector.
|
||||
template <typename T, std::size_t... Is>
|
||||
std::vector<DynTypedMatcher> getMatchers(llvm::index_sequence<Is...>) const {
|
||||
std::vector<DynTypedMatcher> getMatchers(std::index_sequence<Is...>) const {
|
||||
return {Matcher<T>(std::get<Is>(Params))...};
|
||||
}
|
||||
|
||||
|
@ -1621,7 +1621,7 @@ public:
|
||||
|
||||
template <std::size_t... Is>
|
||||
void emit(const SemaDiagnosticBuilder &DB,
|
||||
llvm::index_sequence<Is...>) const {
|
||||
std::index_sequence<Is...>) const {
|
||||
// Apply all tuple elements to the builder in order.
|
||||
bool Dummy[] = {false, (DB << getPrintable(std::get<Is>(Args)))...};
|
||||
(void)Dummy;
|
||||
@ -1635,7 +1635,7 @@ public:
|
||||
|
||||
void diagnose(Sema &S, SourceLocation Loc, QualType T) override {
|
||||
const SemaDiagnosticBuilder &DB = S.Diag(Loc, DiagID);
|
||||
emit(DB, llvm::index_sequence_for<Ts...>());
|
||||
emit(DB, std::index_sequence_for<Ts...>());
|
||||
DB << T;
|
||||
}
|
||||
};
|
||||
|
@ -47,7 +47,7 @@ template <typename RuleType, typename... RequirementTypes, size_t... Is>
|
||||
void invokeRuleAfterValidatingRequirements(
|
||||
RefactoringResultConsumer &Consumer, RefactoringRuleContext &Context,
|
||||
const std::tuple<RequirementTypes...> &Requirements,
|
||||
llvm::index_sequence<Is...>) {
|
||||
std::index_sequence<Is...>) {
|
||||
// Check if the requirements we're interested in can be evaluated.
|
||||
auto Values =
|
||||
std::make_tuple(std::get<Is>(Requirements).evaluate(Context)...);
|
||||
@ -87,7 +87,7 @@ template <typename... RequirementTypes, size_t... Is>
|
||||
void visitRefactoringOptions(
|
||||
RefactoringOptionVisitor &Visitor,
|
||||
const std::tuple<RequirementTypes...> &Requirements,
|
||||
llvm::index_sequence<Is...>) {
|
||||
std::index_sequence<Is...>) {
|
||||
visitRefactoringOptionsImpl(Visitor, std::get<Is>(Requirements)...);
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ createRefactoringActionRule(const RequirementTypes &... Requirements) {
|
||||
RefactoringRuleContext &Context) override {
|
||||
internal::invokeRuleAfterValidatingRequirements<RuleType>(
|
||||
Consumer, Context, Requirements,
|
||||
llvm::index_sequence_for<RequirementTypes...>());
|
||||
std::index_sequence_for<RequirementTypes...>());
|
||||
}
|
||||
|
||||
bool hasSelectionRequirement() override {
|
||||
@ -142,7 +142,7 @@ createRefactoringActionRule(const RequirementTypes &... Requirements) {
|
||||
void visitRefactoringOptions(RefactoringOptionVisitor &Visitor) override {
|
||||
internal::visitRefactoringOptions(
|
||||
Visitor, Requirements,
|
||||
llvm::index_sequence_for<RequirementTypes...>());
|
||||
std::index_sequence_for<RequirementTypes...>());
|
||||
}
|
||||
private:
|
||||
std::tuple<RequirementTypes...> Requirements;
|
||||
|
@ -199,14 +199,14 @@ public:
|
||||
SavedTuple Saved;
|
||||
|
||||
template <std::size_t... Is>
|
||||
T restore(CodeGenFunction &CGF, llvm::index_sequence<Is...>) {
|
||||
T restore(CodeGenFunction &CGF, std::index_sequence<Is...>) {
|
||||
// It's important that the restores are emitted in order. The braced init
|
||||
// list guarantees that.
|
||||
return T{DominatingValue<As>::restore(CGF, std::get<Is>(Saved))...};
|
||||
}
|
||||
|
||||
void Emit(CodeGenFunction &CGF, Flags flags) override {
|
||||
restore(CGF, llvm::index_sequence_for<As...>()).Emit(CGF, flags);
|
||||
restore(CGF, std::index_sequence_for<As...>()).Emit(CGF, flags);
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -530,10 +530,6 @@ bool all_of(R &&range, UnaryPredicate P);
|
||||
template <typename R, typename UnaryPredicate>
|
||||
bool any_of(R &&range, UnaryPredicate P);
|
||||
|
||||
template <size_t... I> struct index_sequence;
|
||||
|
||||
template <class... Ts> struct index_sequence_for;
|
||||
|
||||
namespace detail {
|
||||
|
||||
using std::declval;
|
||||
@ -568,38 +564,38 @@ struct zip_common : public zip_traits<ZipType, Iters...> {
|
||||
std::tuple<Iters...> iterators;
|
||||
|
||||
protected:
|
||||
template <size_t... Ns> value_type deref(index_sequence<Ns...>) const {
|
||||
template <size_t... Ns> value_type deref(std::index_sequence<Ns...>) const {
|
||||
return value_type(*std::get<Ns>(iterators)...);
|
||||
}
|
||||
|
||||
template <size_t... Ns>
|
||||
decltype(iterators) tup_inc(index_sequence<Ns...>) const {
|
||||
decltype(iterators) tup_inc(std::index_sequence<Ns...>) const {
|
||||
return std::tuple<Iters...>(std::next(std::get<Ns>(iterators))...);
|
||||
}
|
||||
|
||||
template <size_t... Ns>
|
||||
decltype(iterators) tup_dec(index_sequence<Ns...>) const {
|
||||
decltype(iterators) tup_dec(std::index_sequence<Ns...>) const {
|
||||
return std::tuple<Iters...>(std::prev(std::get<Ns>(iterators))...);
|
||||
}
|
||||
|
||||
public:
|
||||
zip_common(Iters &&... ts) : iterators(std::forward<Iters>(ts)...) {}
|
||||
|
||||
value_type operator*() { return deref(index_sequence_for<Iters...>{}); }
|
||||
value_type operator*() { return deref(std::index_sequence_for<Iters...>{}); }
|
||||
|
||||
const value_type operator*() const {
|
||||
return deref(index_sequence_for<Iters...>{});
|
||||
return deref(std::index_sequence_for<Iters...>{});
|
||||
}
|
||||
|
||||
ZipType &operator++() {
|
||||
iterators = tup_inc(index_sequence_for<Iters...>{});
|
||||
iterators = tup_inc(std::index_sequence_for<Iters...>{});
|
||||
return *reinterpret_cast<ZipType *>(this);
|
||||
}
|
||||
|
||||
ZipType &operator--() {
|
||||
static_assert(Base::IsBidirectional,
|
||||
"All inner iterators must be at least bidirectional.");
|
||||
iterators = tup_dec(index_sequence_for<Iters...>{});
|
||||
iterators = tup_dec(std::index_sequence_for<Iters...>{});
|
||||
return *reinterpret_cast<ZipType *>(this);
|
||||
}
|
||||
};
|
||||
@ -618,7 +614,8 @@ struct zip_first : public zip_common<zip_first<Iters...>, Iters...> {
|
||||
template <typename... Iters>
|
||||
class zip_shortest : public zip_common<zip_shortest<Iters...>, Iters...> {
|
||||
template <size_t... Ns>
|
||||
bool test(const zip_shortest<Iters...> &other, index_sequence<Ns...>) const {
|
||||
bool test(const zip_shortest<Iters...> &other,
|
||||
std::index_sequence<Ns...>) const {
|
||||
return all_of(std::initializer_list<bool>{std::get<Ns>(this->iterators) !=
|
||||
std::get<Ns>(other.iterators)...},
|
||||
identity<bool>{});
|
||||
@ -630,7 +627,7 @@ public:
|
||||
zip_shortest(Iters &&... ts) : Base(std::forward<Iters>(ts)...) {}
|
||||
|
||||
bool operator==(const zip_shortest<Iters...> &other) const {
|
||||
return !test(other, index_sequence_for<Iters...>{});
|
||||
return !test(other, std::index_sequence_for<Iters...>{});
|
||||
}
|
||||
};
|
||||
|
||||
@ -646,18 +643,21 @@ public:
|
||||
private:
|
||||
std::tuple<Args...> ts;
|
||||
|
||||
template <size_t... Ns> iterator begin_impl(index_sequence<Ns...>) const {
|
||||
template <size_t... Ns>
|
||||
iterator begin_impl(std::index_sequence<Ns...>) const {
|
||||
return iterator(std::begin(std::get<Ns>(ts))...);
|
||||
}
|
||||
template <size_t... Ns> iterator end_impl(index_sequence<Ns...>) const {
|
||||
template <size_t... Ns> iterator end_impl(std::index_sequence<Ns...>) const {
|
||||
return iterator(std::end(std::get<Ns>(ts))...);
|
||||
}
|
||||
|
||||
public:
|
||||
zippy(Args &&... ts_) : ts(std::forward<Args>(ts_)...) {}
|
||||
|
||||
iterator begin() const { return begin_impl(index_sequence_for<Args...>{}); }
|
||||
iterator end() const { return end_impl(index_sequence_for<Args...>{}); }
|
||||
iterator begin() const {
|
||||
return begin_impl(std::index_sequence_for<Args...>{});
|
||||
}
|
||||
iterator end() const { return end_impl(std::index_sequence_for<Args...>{}); }
|
||||
};
|
||||
|
||||
} // end namespace detail
|
||||
@ -727,20 +727,20 @@ private:
|
||||
|
||||
template <size_t... Ns>
|
||||
bool test(const zip_longest_iterator<Iters...> &other,
|
||||
index_sequence<Ns...>) const {
|
||||
std::index_sequence<Ns...>) const {
|
||||
return llvm::any_of(
|
||||
std::initializer_list<bool>{std::get<Ns>(this->iterators) !=
|
||||
std::get<Ns>(other.iterators)...},
|
||||
identity<bool>{});
|
||||
}
|
||||
|
||||
template <size_t... Ns> value_type deref(index_sequence<Ns...>) const {
|
||||
template <size_t... Ns> value_type deref(std::index_sequence<Ns...>) const {
|
||||
return value_type(
|
||||
deref_or_none(std::get<Ns>(iterators), std::get<Ns>(end_iterators))...);
|
||||
}
|
||||
|
||||
template <size_t... Ns>
|
||||
decltype(iterators) tup_inc(index_sequence<Ns...>) const {
|
||||
decltype(iterators) tup_inc(std::index_sequence<Ns...>) const {
|
||||
return std::tuple<Iters...>(
|
||||
next_or_end(std::get<Ns>(iterators), std::get<Ns>(end_iterators))...);
|
||||
}
|
||||
@ -750,17 +750,19 @@ public:
|
||||
: iterators(std::forward<Iters>(ts.first)...),
|
||||
end_iterators(std::forward<Iters>(ts.second)...) {}
|
||||
|
||||
value_type operator*() { return deref(index_sequence_for<Iters...>{}); }
|
||||
value_type operator*() { return deref(std::index_sequence_for<Iters...>{}); }
|
||||
|
||||
value_type operator*() const { return deref(index_sequence_for<Iters...>{}); }
|
||||
value_type operator*() const {
|
||||
return deref(std::index_sequence_for<Iters...>{});
|
||||
}
|
||||
|
||||
zip_longest_iterator<Iters...> &operator++() {
|
||||
iterators = tup_inc(index_sequence_for<Iters...>{});
|
||||
iterators = tup_inc(std::index_sequence_for<Iters...>{});
|
||||
return *this;
|
||||
}
|
||||
|
||||
bool operator==(const zip_longest_iterator<Iters...> &other) const {
|
||||
return !test(other, index_sequence_for<Iters...>{});
|
||||
return !test(other, std::index_sequence_for<Iters...>{});
|
||||
}
|
||||
};
|
||||
|
||||
@ -777,12 +779,13 @@ public:
|
||||
private:
|
||||
std::tuple<Args...> ts;
|
||||
|
||||
template <size_t... Ns> iterator begin_impl(index_sequence<Ns...>) const {
|
||||
template <size_t... Ns>
|
||||
iterator begin_impl(std::index_sequence<Ns...>) const {
|
||||
return iterator(std::make_pair(adl_begin(std::get<Ns>(ts)),
|
||||
adl_end(std::get<Ns>(ts)))...);
|
||||
}
|
||||
|
||||
template <size_t... Ns> iterator end_impl(index_sequence<Ns...>) const {
|
||||
template <size_t... Ns> iterator end_impl(std::index_sequence<Ns...>) const {
|
||||
return iterator(std::make_pair(adl_end(std::get<Ns>(ts)),
|
||||
adl_end(std::get<Ns>(ts)))...);
|
||||
}
|
||||
@ -790,8 +793,10 @@ private:
|
||||
public:
|
||||
zip_longest_range(Args &&... ts_) : ts(std::forward<Args>(ts_)...) {}
|
||||
|
||||
iterator begin() const { return begin_impl(index_sequence_for<Args...>{}); }
|
||||
iterator end() const { return end_impl(index_sequence_for<Args...>{}); }
|
||||
iterator begin() const {
|
||||
return begin_impl(std::index_sequence_for<Args...>{});
|
||||
}
|
||||
iterator end() const { return end_impl(std::index_sequence_for<Args...>{}); }
|
||||
};
|
||||
} // namespace detail
|
||||
|
||||
@ -847,7 +852,7 @@ class concat_iterator
|
||||
/// Increments the first non-end iterator.
|
||||
///
|
||||
/// It is an error to call this with all iterators at the end.
|
||||
template <size_t... Ns> void increment(index_sequence<Ns...>) {
|
||||
template <size_t... Ns> void increment(std::index_sequence<Ns...>) {
|
||||
// Build a sequence of functions to increment each iterator if possible.
|
||||
bool (concat_iterator::*IncrementHelperFns[])() = {
|
||||
&concat_iterator::incrementHelper<Ns>...};
|
||||
@ -876,7 +881,7 @@ class concat_iterator
|
||||
/// reference.
|
||||
///
|
||||
/// It is an error to call this with all iterators at the end.
|
||||
template <size_t... Ns> ValueT &get(index_sequence<Ns...>) const {
|
||||
template <size_t... Ns> ValueT &get(std::index_sequence<Ns...>) const {
|
||||
// Build a sequence of functions to get from iterator if possible.
|
||||
ValueT *(concat_iterator::*GetHelperFns[])() const = {
|
||||
&concat_iterator::getHelper<Ns>...};
|
||||
@ -901,11 +906,13 @@ public:
|
||||
using BaseT::operator++;
|
||||
|
||||
concat_iterator &operator++() {
|
||||
increment(index_sequence_for<IterTs...>());
|
||||
increment(std::index_sequence_for<IterTs...>());
|
||||
return *this;
|
||||
}
|
||||
|
||||
ValueT &operator*() const { return get(index_sequence_for<IterTs...>()); }
|
||||
ValueT &operator*() const {
|
||||
return get(std::index_sequence_for<IterTs...>());
|
||||
}
|
||||
|
||||
bool operator==(const concat_iterator &RHS) const {
|
||||
return Begins == RHS.Begins && Ends == RHS.Ends;
|
||||
@ -928,10 +935,10 @@ public:
|
||||
private:
|
||||
std::tuple<RangeTs...> Ranges;
|
||||
|
||||
template <size_t... Ns> iterator begin_impl(index_sequence<Ns...>) {
|
||||
template <size_t... Ns> iterator begin_impl(std::index_sequence<Ns...>) {
|
||||
return iterator(std::get<Ns>(Ranges)...);
|
||||
}
|
||||
template <size_t... Ns> iterator end_impl(index_sequence<Ns...>) {
|
||||
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)))...);
|
||||
}
|
||||
@ -940,8 +947,8 @@ public:
|
||||
concat_range(RangeTs &&... Ranges)
|
||||
: Ranges(std::forward<RangeTs>(Ranges)...) {}
|
||||
|
||||
iterator begin() { return begin_impl(index_sequence_for<RangeTs...>{}); }
|
||||
iterator end() { return end_impl(index_sequence_for<RangeTs...>{}); }
|
||||
iterator begin() { return begin_impl(std::index_sequence_for<RangeTs...>{}); }
|
||||
iterator end() { return end_impl(std::index_sequence_for<RangeTs...>{}); }
|
||||
};
|
||||
|
||||
} // end namespace detail
|
||||
@ -990,28 +997,6 @@ struct on_first {
|
||||
}
|
||||
};
|
||||
|
||||
// A subset of N3658. More stuff can be added as-needed.
|
||||
|
||||
/// Represents a compile-time sequence of integers.
|
||||
template <class T, T... I> struct integer_sequence {
|
||||
using value_type = T;
|
||||
|
||||
static constexpr size_t size() { return sizeof...(I); }
|
||||
};
|
||||
|
||||
/// Alias for the common case of a sequence of size_ts.
|
||||
template <size_t... I>
|
||||
struct index_sequence : integer_sequence<std::size_t, I...> {};
|
||||
|
||||
template <std::size_t N, std::size_t... I>
|
||||
struct build_index_impl : build_index_impl<N - 1, N - 1, I...> {};
|
||||
template <std::size_t... I>
|
||||
struct build_index_impl<0, I...> : index_sequence<I...> {};
|
||||
|
||||
/// Creates a compile-time integer sequence for a parameter pack.
|
||||
template <class... Ts>
|
||||
struct index_sequence_for : build_index_impl<sizeof...(Ts)> {};
|
||||
|
||||
/// Utility type to build an inheritance chain that makes it easy to rank
|
||||
/// overload candidates.
|
||||
template <int N> struct rank : rank<N - 1> {};
|
||||
@ -1580,7 +1565,7 @@ template <typename R> detail::enumerator<R> enumerate(R &&TheRange) {
|
||||
namespace detail {
|
||||
|
||||
template <typename F, typename Tuple, std::size_t... I>
|
||||
auto apply_tuple_impl(F &&f, Tuple &&t, index_sequence<I...>)
|
||||
auto apply_tuple_impl(F &&f, Tuple &&t, std::index_sequence<I...>)
|
||||
-> decltype(std::forward<F>(f)(std::get<I>(std::forward<Tuple>(t))...)) {
|
||||
return std::forward<F>(f)(std::get<I>(std::forward<Tuple>(t))...);
|
||||
}
|
||||
@ -1593,9 +1578,9 @@ auto apply_tuple_impl(F &&f, Tuple &&t, index_sequence<I...>)
|
||||
template <typename F, typename Tuple>
|
||||
auto apply_tuple(F &&f, Tuple &&t) -> decltype(detail::apply_tuple_impl(
|
||||
std::forward<F>(f), std::forward<Tuple>(t),
|
||||
build_index_impl<
|
||||
std::make_index_sequence<
|
||||
std::tuple_size<typename std::decay<Tuple>::type>::value>{})) {
|
||||
using Indices = build_index_impl<
|
||||
using Indices = std::make_index_sequence<
|
||||
std::tuple_size<typename std::decay<Tuple>::type>::value>;
|
||||
|
||||
return detail::apply_tuple_impl(std::forward<F>(f), std::forward<Tuple>(t),
|
||||
|
@ -551,26 +551,26 @@ public:
|
||||
|
||||
/// RPC channel serialization for std::tuple.
|
||||
static Error serialize(ChannelT &C, const std::tuple<ArgTs...> &V) {
|
||||
return serializeTupleHelper(C, V, llvm::index_sequence_for<ArgTs...>());
|
||||
return serializeTupleHelper(C, V, std::index_sequence_for<ArgTs...>());
|
||||
}
|
||||
|
||||
/// RPC channel deserialization for std::tuple.
|
||||
static Error deserialize(ChannelT &C, std::tuple<ArgTs...> &V) {
|
||||
return deserializeTupleHelper(C, V, llvm::index_sequence_for<ArgTs...>());
|
||||
return deserializeTupleHelper(C, V, std::index_sequence_for<ArgTs...>());
|
||||
}
|
||||
|
||||
private:
|
||||
// Serialization helper for std::tuple.
|
||||
template <size_t... Is>
|
||||
static Error serializeTupleHelper(ChannelT &C, const std::tuple<ArgTs...> &V,
|
||||
llvm::index_sequence<Is...> _) {
|
||||
std::index_sequence<Is...> _) {
|
||||
return serializeSeq(C, std::get<Is>(V)...);
|
||||
}
|
||||
|
||||
// Serialization helper for std::tuple.
|
||||
template <size_t... Is>
|
||||
static Error deserializeTupleHelper(ChannelT &C, std::tuple<ArgTs...> &V,
|
||||
llvm::index_sequence<Is...> _) {
|
||||
std::index_sequence<Is...> _) {
|
||||
return deserializeSeq(C, std::get<Is>(V)...);
|
||||
}
|
||||
};
|
||||
|
@ -502,7 +502,7 @@ public:
|
||||
static typename WrappedHandlerReturn<RetT>::Type
|
||||
unpackAndRun(HandlerT &Handler, std::tuple<TArgTs...> &Args) {
|
||||
return unpackAndRunHelper(Handler, Args,
|
||||
llvm::index_sequence_for<TArgTs...>());
|
||||
std::index_sequence_for<TArgTs...>());
|
||||
}
|
||||
|
||||
// Call the given handler with the given arguments.
|
||||
@ -510,7 +510,7 @@ public:
|
||||
static Error unpackAndRunAsync(HandlerT &Handler, ResponderT &Responder,
|
||||
std::tuple<TArgTs...> &Args) {
|
||||
return unpackAndRunAsyncHelper(Handler, Responder, Args,
|
||||
llvm::index_sequence_for<TArgTs...>());
|
||||
std::index_sequence_for<TArgTs...>());
|
||||
}
|
||||
|
||||
// Call the given handler with the given arguments.
|
||||
@ -540,14 +540,13 @@ public:
|
||||
// Deserialize arguments from the channel.
|
||||
template <typename ChannelT, typename... CArgTs>
|
||||
static Error deserializeArgs(ChannelT &C, std::tuple<CArgTs...> &Args) {
|
||||
return deserializeArgsHelper(C, Args,
|
||||
llvm::index_sequence_for<CArgTs...>());
|
||||
return deserializeArgsHelper(C, Args, std::index_sequence_for<CArgTs...>());
|
||||
}
|
||||
|
||||
private:
|
||||
template <typename ChannelT, typename... CArgTs, size_t... Indexes>
|
||||
static Error deserializeArgsHelper(ChannelT &C, std::tuple<CArgTs...> &Args,
|
||||
llvm::index_sequence<Indexes...> _) {
|
||||
std::index_sequence<Indexes...> _) {
|
||||
return SequenceSerialization<ChannelT, ArgTs...>::deserialize(
|
||||
C, std::get<Indexes>(Args)...);
|
||||
}
|
||||
@ -556,18 +555,16 @@ private:
|
||||
static typename WrappedHandlerReturn<
|
||||
typename HandlerTraits<HandlerT>::ReturnType>::Type
|
||||
unpackAndRunHelper(HandlerT &Handler, ArgTuple &Args,
|
||||
llvm::index_sequence<Indexes...>) {
|
||||
std::index_sequence<Indexes...>) {
|
||||
return run(Handler, std::move(std::get<Indexes>(Args))...);
|
||||
}
|
||||
|
||||
|
||||
template <typename HandlerT, typename ResponderT, typename ArgTuple,
|
||||
size_t... Indexes>
|
||||
static typename WrappedHandlerReturn<
|
||||
typename HandlerTraits<HandlerT>::ReturnType>::Type
|
||||
unpackAndRunAsyncHelper(HandlerT &Handler, ResponderT &Responder,
|
||||
ArgTuple &Args,
|
||||
llvm::index_sequence<Indexes...>) {
|
||||
ArgTuple &Args, std::index_sequence<Indexes...>) {
|
||||
return run(Handler, Responder, std::move(std::get<Indexes>(Args))...);
|
||||
}
|
||||
};
|
||||
|
@ -418,7 +418,7 @@ template <typename PassT, typename IRUnitT, typename AnalysisManagerT,
|
||||
typename PassT::Result
|
||||
getAnalysisResultUnpackTuple(AnalysisManagerT &AM, IRUnitT &IR,
|
||||
std::tuple<ArgTs...> Args,
|
||||
llvm::index_sequence<Ns...>) {
|
||||
std::index_sequence<Ns...>) {
|
||||
(void)Args;
|
||||
return AM.template getResult<PassT>(IR, std::get<Ns>(Args)...);
|
||||
}
|
||||
@ -435,7 +435,7 @@ getAnalysisResult(AnalysisManager<IRUnitT, AnalysisArgTs...> &AM, IRUnitT &IR,
|
||||
std::tuple<MainArgTs...> Args) {
|
||||
return (getAnalysisResultUnpackTuple<
|
||||
PassT, IRUnitT>)(AM, IR, Args,
|
||||
llvm::index_sequence_for<AnalysisArgTs...>{});
|
||||
std::index_sequence_for<AnalysisArgTs...>{});
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
@ -91,7 +92,7 @@ class format_object final : public format_object_base {
|
||||
|
||||
template <std::size_t... Is>
|
||||
int snprint_tuple(char *Buffer, unsigned BufferSize,
|
||||
index_sequence<Is...>) const {
|
||||
std::index_sequence<Is...>) const {
|
||||
#ifdef _MSC_VER
|
||||
return _snprintf(Buffer, BufferSize, Fmt, std::get<Is>(Vals)...);
|
||||
#else
|
||||
@ -106,7 +107,7 @@ public:
|
||||
}
|
||||
|
||||
int snprint(char *Buffer, unsigned BufferSize) const override {
|
||||
return snprint_tuple(Buffer, BufferSize, index_sequence_for<Ts...>());
|
||||
return snprint_tuple(Buffer, BufferSize, std::index_sequence_for<Ts...>());
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user