These are real cases, it would be nice to capture them in clang.
Case1:
class UrlAnalyzed {
public:
UrlAnalyzed(string_view url [[clang::lifetimebound]]);
};
std::string StrCat(std::string_view, std::string_view);
void test() {
UrlAnalyzed url(StrCat("abc", "bcd")); // dangling!
}
Case2:
std::string_view ReturnStringView(std::string_view abc [[clang::lifetimebound]]);
void test() {
std::string_view sv1 = ReturnStringView(StrCat("bar", "x")); // dangling
}