[all-commits] [llvm/llvm-project] 858b56: [Clang] Preserve coroutine parameter referenced st...
Yuxuan Chen via All-commits
all-commits at lists.llvm.org
Wed Nov 1 23:04:01 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 858b56e4962749013ded409ff43370b542c8b6cb
https://github.com/llvm/llvm-project/commit/858b56e4962749013ded409ff43370b542c8b6cb
Author: Yuxuan Chen <yuxuanchen1997 at outlook.com>
Date: 2023-11-02 (Thu, 02 Nov 2023)
Changed paths:
M clang/lib/Sema/SemaCoroutine.cpp
A clang/test/SemaCXX/warn-unused-parameters-coroutine.cpp
Log Message:
-----------
[Clang] Preserve coroutine parameter referenced state (#70973)
This PR is proposing a fix for
https://github.com/llvm/llvm-project/issues/65971.
Previously, given a coroutine like this
```
task foo(int a) {
co_return;
}
```
Parameter `a` is never used. However, because C++ coroutines move
constructs the variable to a heap allocated coroutine activation frame,
we considered all parameters referenced. When diagnosing unused
parameters, we cannot distinguish if the variable reference was due to
coroutine parameter moves.
Compiler Explorer shows that GCC warns against this case correctly, but
clang does not: https://godbolt.org/z/Wo7dfqeaf
This patch addresses this issue by preserving the original
`ParmVarDecl`'s `Referenced` state.
More information about the All-commits
mailing list