Diagnose [[clang::lifetimebound]] on functions whose return value cannot refer to any object
Open
clang:temporal-safety
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
`[[clang::lifetimebound]]` on a parameter is meaningful only when the function's return value can refer to another object. When the return type is something like `int` or an enum, the returned value cannot carry a borrow, and the attribute has no effect:
```cpp
int getInt(const std::string &s [[clang::lifetimebound]]);
```
We should emit a diagnostic for this case.
cc @usx95
Contributor guide
Assessment
This issue has not been assessed yet.