lifetime_capture_by conflicts with user-defined identifiers
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Consider:
```c++
struct S {
void foo(int global) [[clang::lifetime_capture_by(global)]] {
}
};
```
This code is rejected with `parameter cannot be named 'global' while using 'lifetime_capture_by(global)'`: https://godbolt.org/z/YWhW1dnoe
The usual approach of adding underscores doesn't save you: https://godbolt.org/z/9oeMoPWfK
I think 1) the above code should be accepted with the `global` parameter being used to denote the capture, though a warning would be reasonable, 2) we should allow optional leading & trailing underscores so library authors have a way to protect against things like:
```
#define global 12
#include "some_header.h" // has a declaration using [[clang::lifetime_capture_by(global)]]
```
Contributor guide
Assessment
This issue has not been assessed yet.