Suggest, Infer, Verify lifetime annotations (workstream 4)
Open
clang:temporal-safety
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
The idea is to use the lifetime analysis to conclude which parameters escape via return and can be annotated via `[[clang::lifetimebound]]`.
```cpp
std::string_view Select(bool cond, std::string_view a, std::string_view b) {
if (cond)
return a;
else
return b;
}
```
We can implement this as a clang warning:
```cpp
std::string_view Select(bool cond, std::string_view a, std::string_view b)
^^^^^^^^^^^^^ warning: param should be marked [[clang::lifetimebound]]
^^^^^^^^^^^^^ warning: param should be marked [[clang::lifetimebound]]
```
Contributor guide
Assessment
This issue has not been assessed yet.