Skip to content
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

incorrect source range for the CoyieldExpr AST node #64483

Closed
hokein opened this issue Aug 7, 2023 · 2 comments
Closed

incorrect source range for the CoyieldExpr AST node #64483

hokein opened this issue Aug 7, 2023 · 2 comments
Labels
coroutines C++20 coroutines

Comments

@hokein
Copy link
Collaborator

hokein commented Aug 7, 2023

Chat get(int s) { 
  co_yield s; // incorrect source range, line 69
  co_return s;
  co_await s;
}

The source range of the CoyieldExpr only covers the co_yield token. This seems to happen on CoyieldExpr node only (the other node CoreturnExpr and CoawaitExpr are fine).

|-ExprWithCleanups 0xca71878 <line:69:3> 'void'
  | | `-CoyieldExpr 0xca71830 <col:3> 'void'
  | |   |-CXXMemberCallExpr 0xca714a8 <col:3> 'std::suspend_always':'std::suspend_always'
  | |   | |-MemberExpr 0xca71478 <col:3> '<bound member function type>' .yield_value 0xca668b0
  | |   | | `-DeclRefExpr 0xca71458 <col:3> 'std::coroutine_traits<Chat, int>::promise_type':'Chat::promise_type' lvalue Var 0xca6e7e8 '__promise' 'std::coroutine_traits<Chat, int>::promise_type':'Chat::promise_type'
  | |   | `-ImplicitCastExpr 0xca714d0 <col:12> 'int' <LValueToRValue>
  | |   |   `-DeclRefExpr 0xca6cee8 <col:12> 'int' lvalue ParmVar 0xca6ccc0 's' 'int'

See the full example: https://godbolt.org/z/GcKP5r9xn

@hokein hokein added the coroutines C++20 coroutines label Aug 7, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 7, 2023

@llvm/issue-subscribers-coroutines

@danix800
Copy link
Member

danix800 commented Aug 7, 2023

Fixed https://reviews.llvm.org/D157296

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
coroutines C++20 coroutines
Projects
None yet
Development

No branches or pull requests

3 participants