llvm-project
llvm-project copied to clipboard
Diagnose [[clang::lifetimebound]] on functions whose return value cannot refer to any object
[[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:
int getInt(const std::string &s [[clang::lifetimebound]]);
We should emit a diagnostic for this case.
cc @usx95
@llvm/issue-subscribers-clang-temporal-safety
Author: Zhijie Wang (aeft)
`[[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:
int getInt(const std::string &s [[clang::lifetimebound]]);
We should emit a diagnostic for this case.
cc @usx95
I would like to work on this.