================
@@ -582,3 +714,28 @@ void lifetimebound_ctor() {
   }
   (void)v;
 }
+
+View lifetimebound_return_of_local(){
+  MyObj stack;
+  return Identity(stack); // expected-warning {{returning reference to stack 
allocated object}}
+                          // expected-note@-1 {{returned here}}
+}
+
+const MyObj& lifetimebound_return_ref_to_local() {
+  MyObj stack;
+  return IdentityRef(stack); // expected-warning {{returning reference to 
stack allocated object}}
+                             // expected-note@-1 {{returned here}}
+                             // expected-warning@-2 {{reference to stack 
memory associated with local variable 'stack' returned}}
+}
+
+// FIXME: The analysis does not currently model the lifetime of by-value
+// parameters, so it fails to diagnose this UAR violation.
+View lifetimebound_return_of_by_value_param(MyObj stack_param) {
+  return Identity(stack_param); 
+}
+
+// FIXME: The analysis does not currently model the lifetime of by-value
----------------
usx95 wrote:

please also add that this is escape via output param (not by return which is 
implemented in this PR)

https://github.com/llvm/llvm-project/pull/165370
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to