================
@@ -0,0 +1,81 @@
+// RUN: %clang_cc1 -fsyntax-only -fexperimental-lifetime-safety
-Wexperimental-lifetime-safety-suggestions -verify %s
+
+struct MyObj {
+ int id;
+ ~MyObj() {} // Non-trivial destructor
+ MyObj operator+(MyObj);
+};
+
+struct [[gsl::Pointer()]] View {
+ View(const MyObj&); // Borrows from MyObj
+ View();
+ void use() const;
+};
+
+//===----------------------------------------------------------------------===//
+// Lifetimebound Annotation Suggestion Tests
+//===----------------------------------------------------------------------===//
+
+View return_view_directly (View a) { // expected-warning {{param should be
marked [[clang::lifetimebound]]}}.
+ return a; // expected-note {{param returned
here}}
+}
+
+View conditional_return_view (
----------------
usx95 wrote:
One more idea about control flow:
```
View test (
View a,
View b) { // expected-warning {{param should be marked
[[clang::lifetimebound]]}}.
a = b;
return a;
}
```
https://github.com/llvm/llvm-project/pull/169767
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits