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

Nathan Ridge via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 9 01:18:39 PDT 2022


nridge added a comment.

There is one remaining test failure, related to a duplicate diagnostic. I've reduced it to the following:

  namespace std {
  
  template <class Ret, class... Args>
  struct coroutine_traits {};
  } // end of namespace std
  
  struct awaitable {
    bool await_ready() noexcept;
    template <typename F>
    void await_suspend(F) noexcept;
    void await_resume() noexcept;
  } a;
  
  struct suspend_always {
    bool await_ready() noexcept { return false; }
    template <typename F>
    void await_suspend(F) noexcept;
    void await_resume() noexcept {}
  };
  
  struct yielded_thing { const char *p; short a, b; };
  
  struct promise {
    void get_return_object();
    suspend_always initial_suspend();
    suspend_always final_suspend() noexcept;
    awaitable yield_value(int);
    awaitable yield_value(yielded_thing);
    void return_value(int);
    void unhandled_exception();
  };
  
  template <typename... T>
  struct std::coroutine_traits<void, T...> { using promise_type = promise; };
  
  namespace std {
  template <class PromiseType = void>
  struct coroutine_handle {
    static coroutine_handle from_address(void *) noexcept;
  };
  template <>
  struct coroutine_handle<void> {
    template <class PromiseType>
    coroutine_handle(coroutine_handle<PromiseType>) noexcept;
    static coroutine_handle from_address(void *) noexcept;
  };
  } // namespace std
  
  void yield() {
    co_yield 0;
    co_yield {1e100}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{implicit conversion}} expected-warning {{braces around scalar}}
    co_yield {"foo", __LONG_LONG_MAX__}; // expected-error {{cannot be narrowed}} expected-note {{explicit cast}} expected-warning {{changes value}}
  }

The last two lines each trigger an "implicit conversion" warning (among other diagnostics), which is expected, but with my patch the "implicit conversion" warnings appear **twice** each.


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