llvm / llvm/llvm-project

Suggest, Infer, Verify lifetime annotations (workstream 4)

Open
#169,375 1 comment 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.