Fix compatibility for MSVC 19.32. (`fatal error C1001: Internal compiler error`) (#30459)

* Fix compatibility for MSVC 19.32. (`fatal error C1001: Internal compiler error`)

* Move `typename F, typename Arg, typename Iter` of `BasicSeqIter` into `typename IterTraits`

Signed-off-by: owentou <owentou@tencent.com>

* Keep just one template argument for `BasicSeqIter`

Signed-off-by: owentou <owentou@tencent.com>

* iwyu, fix_auto_deps, clang_format, buildifier format

Signed-off-by: owentou <owentou@tencent.com>
Co-authored-by: AJ Heller <hork@google.com>
pull/29835/head
WenTao Ou 2 years ago committed by GitHub
parent 45959e7cc1
commit 3cea62f686
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      BUILD
  2. 2
      src/core/lib/iomgr/resolve_address_windows.cc
  3. 30
      src/core/lib/promise/detail/basic_seq.h
  4. 29
      src/core/lib/promise/seq.h
  5. 31
      src/core/lib/promise/try_seq.h
  6. 1
      src/core/lib/security/credentials/composite/composite_credentials.cc

@ -1478,6 +1478,7 @@ grpc_cc_library(
"basic_seq",
"gpr_platform",
"poll",
"promise_like",
],
)
@ -1496,6 +1497,7 @@ grpc_cc_library(
"basic_seq",
"gpr_platform",
"poll",
"promise_like",
"promise_status",
],
)
@ -6019,7 +6021,6 @@ grpc_cc_library(
"activity",
"arena",
"arena_promise",
"basic_seq",
"channel_args",
"channel_fwd",
"closure",

@ -119,7 +119,7 @@ NativeDNSResolver::LookupHostnameBlocking(absl::string_view name,
goto done;
}
if (port.empty()) {
if (default_port == NULL) {
if (default_port.empty()) {
error = GRPC_ERROR_CREATE_FROM_CPP_STRING(
absl::StrFormat("no port in name '%s'", name));
goto done;

@ -421,20 +421,22 @@ class BasicSeq {
// As above, but models a sequence of unknown size
// At each element, the accumulator A and the current value V is passed to some
// function of type F as f(V, A); f is expected to return a promise that
// resolves to Traits::WrappedType.
template <template <typename Wrapped> class Traits, typename F, typename Arg,
typename Iter>
// function of type IterTraits::Factory as f(V, IterTraits::Argument); f is
// expected to return a promise that resolves to IterTraits::Wrapped.
template <class IterTraits>
class BasicSeqIter {
private:
using IterValue = decltype(*std::declval<Iter>());
using StateCreated = decltype(std::declval<F>()(std::declval<IterValue>(),
std::declval<Arg>()));
using State = PromiseLike<StateCreated>;
using Wrapped = typename State::Result;
using Traits = typename IterTraits::Traits;
using Iter = typename IterTraits::Iter;
using Factory = typename IterTraits::Factory;
using Argument = typename IterTraits::Argument;
using IterValue = typename IterTraits::IterValue;
using StateCreated = typename IterTraits::StateCreated;
using State = typename IterTraits::State;
using Wrapped = typename IterTraits::Wrapped;
public:
BasicSeqIter(Iter begin, Iter end, F f, Arg arg)
BasicSeqIter(Iter begin, Iter end, Factory f, Argument arg)
: cur_(begin), end_(end), f_(std::move(f)) {
if (cur_ == end_) {
Construct(&result_, std::move(arg));
@ -484,7 +486,7 @@ class BasicSeqIter {
Poll<Wrapped> PollNonEmpty() {
Poll<Wrapped> r = state_();
if (absl::holds_alternative<Pending>(r)) return r;
return Traits<Wrapped>::template CheckResultAndRunNext<Wrapped>(
return Traits::template CheckResultAndRunNext<Wrapped>(
std::move(absl::get<Wrapped>(r)), [this](Wrapped arg) -> Poll<Wrapped> {
auto next = cur_;
++next;
@ -494,17 +496,17 @@ class BasicSeqIter {
cur_ = next;
state_.~State();
Construct(&state_,
Traits<Wrapped>::CallSeqFactory(f_, *cur_, std::move(arg)));
Traits::template CallSeqFactory(f_, *cur_, std::move(arg)));
return PollNonEmpty();
});
}
Iter cur_;
const Iter end_;
GPR_NO_UNIQUE_ADDRESS F f_;
GPR_NO_UNIQUE_ADDRESS Factory f_;
union {
GPR_NO_UNIQUE_ADDRESS State state_;
GPR_NO_UNIQUE_ADDRESS Arg result_;
GPR_NO_UNIQUE_ADDRESS Argument result_;
};
};

@ -20,6 +20,7 @@
#include <utility>
#include "src/core/lib/promise/detail/basic_seq.h"
#include "src/core/lib/promise/detail/promise_like.h"
#include "src/core/lib/promise/poll.h"
namespace grpc_core {
@ -50,6 +51,26 @@ struct SeqTraits {
template <typename... Fs>
using Seq = BasicSeq<SeqTraits, Fs...>;
template <typename I, typename F, typename Arg>
struct SeqIterTraits {
using Iter = I;
using Factory = F;
using Argument = Arg;
using IterValue = decltype(*std::declval<Iter>());
using StateCreated = decltype(std::declval<F>()(std::declval<IterValue>(),
std::declval<Arg>()));
using State = PromiseLike<StateCreated>;
using Wrapped = typename State::Result;
using Traits = SeqTraits<Wrapped>;
};
template <typename Iter, typename Factory, typename Argument>
struct SeqIterResultTraits {
using IterTraits = SeqIterTraits<Iter, Factory, Argument>;
using Result = BasicSeqIter<IterTraits>;
};
} // namespace promise_detail
// Sequencing combinator.
@ -75,11 +96,11 @@ F Seq(F functor) {
// }
// return argument;
template <typename Iter, typename Factory, typename Argument>
promise_detail::BasicSeqIter<promise_detail::SeqTraits, Factory, Argument, Iter>
typename promise_detail::SeqIterResultTraits<Iter, Factory, Argument>::Result
SeqIter(Iter begin, Iter end, Argument argument, Factory factory) {
return promise_detail::BasicSeqIter<promise_detail::SeqTraits, Factory,
Argument, Iter>(
begin, end, std::move(factory), std::move(argument));
using Result = typename promise_detail::SeqIterResultTraits<Iter, Factory,
Argument>::Result;
return Result(begin, end, std::move(factory), std::move(argument));
}
} // namespace grpc_core

@ -24,6 +24,7 @@
#include "absl/status/statusor.h"
#include "src/core/lib/promise/detail/basic_seq.h"
#include "src/core/lib/promise/detail/promise_like.h"
#include "src/core/lib/promise/detail/status.h"
#include "src/core/lib/promise/poll.h"
@ -115,6 +116,26 @@ using TrySeqTraits = TrySeqTraitsWithSfinae<T>;
template <typename... Fs>
using TrySeq = BasicSeq<TrySeqTraits, Fs...>;
template <typename I, typename F, typename Arg>
struct TrySeqIterTraits {
using Iter = I;
using Factory = F;
using Argument = Arg;
using IterValue = decltype(*std::declval<Iter>());
using StateCreated = decltype(std::declval<F>()(std::declval<IterValue>(),
std::declval<Arg>()));
using State = PromiseLike<StateCreated>;
using Wrapped = typename State::Result;
using Traits = TrySeqTraits<Wrapped>;
};
template <typename Iter, typename Factory, typename Argument>
struct TrySeqIterResultTraits {
using IterTraits = TrySeqIterTraits<Iter, Factory, Argument>;
using Result = BasicSeqIter<IterTraits>;
};
} // namespace promise_detail
// Try a sequence of operations.
@ -143,12 +164,12 @@ promise_detail::TrySeq<Functors...> TrySeq(Functors... functors) {
// }
// return argument;
template <typename Iter, typename Factory, typename Argument>
promise_detail::BasicSeqIter<promise_detail::TrySeqTraits, Factory, Argument,
Iter>
typename promise_detail::TrySeqIterResultTraits<Iter, Factory, Argument>::Result
TrySeqIter(Iter begin, Iter end, Argument argument, Factory factory) {
return promise_detail::BasicSeqIter<promise_detail::TrySeqTraits, Factory,
Argument, Iter>(
begin, end, std::move(factory), std::move(argument));
using Result =
typename promise_detail::TrySeqIterResultTraits<Iter, Factory,
Argument>::Result;
return Result(begin, end, std::move(factory), std::move(argument));
}
} // namespace grpc_core

@ -31,7 +31,6 @@
#include "src/core/lib/debug/trace.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"
#include "src/core/lib/promise/detail/basic_seq.h"
#include "src/core/lib/promise/poll.h"
#include "src/core/lib/promise/try_seq.h"
#include "src/core/lib/surface/api_trace.h"

Loading…
Cancel
Save