[clang] [clang] Introduce [[clang::lifetime_capture_by(X)]] (PR #111499)

Gábor Horváth via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 7 10:17:00 PST 2024


================
@@ -1199,6 +1213,17 @@ static void checkExprLifetimeImpl(Sema &SemaRef,
       break;
     }
 
+    case LK_LifetimeCapture: {
+      if (!MTE)
----------------
Xazax-hun wrote:

Do we want to diagnose the following case:
```
std::set<std::string_view> set;
void addToSet(std::string_view s [[clang::lifetime_capture_by()]]) {
   set.insert(s);
}
void f() {
  std::string local;
  addToSet(local);
}
```
?

I think we don't have an MTE here. It is OK to cover this in a follow-up. 

https://github.com/llvm/llvm-project/pull/111499


More information about the cfe-commits mailing list