| Issue |
169375
|
| Summary |
Suggest and infer lifetime annotations
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
usx95
|
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]]
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs