llvm-project
llvm-project copied to clipboard
[LifetimeSafety] Verify lifetimebound param escapes via return
std::string_view identity(const std::string& in) { return in; }
std::string_view max(const std::string& a [[clang::lifetimebound]],
const std::string& b [[clang::lifetimebound]]) {
return a > b ? identity(a): identity(b);
}
For verification of lifetimebound, we need to verify that annotated parameter escapes via return.
For example, in the above snippet, we must get a warning that lifetimebound on a and b cannot be verified. In order for the analysis to deduce a escape via return, identity must be annotated with lifetimebound.
cc: @AbhinavPradeep
@llvm/issue-subscribers-clang-temporal-safety
Author: Utkarsh Saxena (usx95)
```cpp
std::string_view identity(const std::string& in) { return in; }
std::string_view max(const std::string& a [[clang::lifetimebound]], const std::string& b [[clang::lifetimebound]]) { return a > b ? identity(a): identity(b); }
For verification of `lifetimebound`, we need to verify that annotated parameter escapes via `return`.
For example, in the above snippet, we must get a warning that `lifetimebound` on `a` and `b` cannot be verified. In order for the analysis to deduce a escape via return, `identity` must be annotated with `lifetimebound`.
cc: @<!-- -->AbhinavPradeep
</details>
I will try to work on this.