[clang] [LifetimeSafety] Infer [[clang::lifetimebound]] annotation (PR #171081)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 8 01:23:44 PST 2025
================
@@ -89,6 +89,18 @@ void test_getView_on_temporary() {
(void)sv;
}
+//===----------------------------------------------------------------------===//
+// Annotation Inference Test Cases
+//===----------------------------------------------------------------------===//
+
+View return_view_by_func (View a) { // expected-warning {{param should be marked [[clang::lifetimebound]]}}.
+ return return_view_directly(a); // expected-note {{param returned here}}
+}
+
+MyObj* return_pointer_by_func (MyObj* a) { // expected-warning {{param should be marked [[clang::lifetimebound]]}}.
+ return return_pointer_object(a); // expected-note {{param returned here}}
+}
----------------
usx95 wrote:
Please also add a negative test with these in the reverse order.
This is where a analysing the functions in a topological order of a call hierarchy would help.
(same for the test below)
https://github.com/llvm/llvm-project/pull/171081
More information about the cfe-commits
mailing list