[PATCH] D115187: [clangd] Expose CoawaitExpr's operand in the AST

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 25 00:34:28 PDT 2022


nridge added a comment.

Here is a reduced testcase for the semantic regression:

  namespace std {
  template <class PromiseType = void>
  struct coroutine_handle {
    static coroutine_handle from_address(void *) noexcept;
  };
  template <class Ret, class... Args>
  struct coroutine_traits;
  } // end of namespace std
  
  template <typename Promise> struct coro {};
  template <typename Promise, typename... Ps>
  struct std::coroutine_traits<coro<Promise>, Ps...> {
    using promise_type = Promise;
  };
  
  struct awaitable {
    bool await_ready() noexcept;
    template <typename F>
    void await_suspend(F) noexcept;
    void await_resume() noexcept;
  } a;
  
  struct transform_awaitable {};
  
  struct transform_promise {
    coro<transform_promise> get_return_object();
    awaitable initial_suspend();
    awaitable final_suspend() noexcept;
    awaitable await_transform(transform_awaitable);
    void unhandled_exception();
    void return_void();
  };
  
  template <typename T, typename U>
  coro<T> await_template(U t) {
    co_await t;
  }
  
  template coro<transform_promise> await_template<transform_promise>(transform_awaitable);

Without my patch, this compiles fine. With it, I clang gives the following errors:

  coroutines.cpp:35:9: error: no viable conversion from 'awaitable' to 'transform_awaitable'
  coro<T> await_template(U t) {
          ^~~~~~~~~~~~~~
  coroutines.cpp:39:34: note: in instantiation of function template specialization 'await_template<transform_promise, transform_awaitable>' requested here
  template coro<transform_promise> await_template<transform_promise>(transform_awaitable);
                                   ^
  coroutines.cpp:23:8: note: candidate constructor (the implicit copy constructor) not viable: no known conversion from 'awaitable' to 'const transform_awaitable &' for 1st argument
  struct transform_awaitable {};
         ^
  coroutines.cpp:23:8: note: candidate constructor (the implicit move constructor) not viable: no known conversion from 'awaitable' to 'transform_awaitable &&' for 1st argument
  struct transform_awaitable {};
         ^
  coroutines.cpp:29:48: note: passing argument to parameter here
    awaitable await_transform(transform_awaitable);
                                                 ^
  coroutines.cpp:35:9: note: call to 'await_transform' implicitly required by 'co_await' here
  coro<T> await_template(U t) {
          ^~~~~~~~~~~~~~
  1 error generated.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115187/new/

https://reviews.llvm.org/D115187



More information about the cfe-commits mailing list