[clang] [Lifetime Safety] Public Vs Private Annotation Suggestions (PR #171972)

Kashika Akhouri via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 15 00:35:07 PST 2025


================
@@ -12,14 +22,32 @@ struct [[gsl::Pointer()]] View {
   void use() const;
 };
 
-View return_view_directly (View a) {    // expected-warning {{param should be marked [[clang::lifetimebound]]}}.
+View return_view_directly(View a); // expected-warning {{parameter in cross-TU function should be marked [[clang::lifetimebound]]}}
+
+View conditional_return_view(
+  View a,        // expected-warning {{parameter in cross-TU function should be marked [[clang::lifetimebound]]}}
+  View b,        // expected-warning {{parameter in cross-TU function should be marked [[clang::lifetimebound]]}}
+  bool c);
+
+int* return_pointer_directly(int* a);  // expected-warning {{parameter in cross-TU function should be marked [[clang::lifetimebound]]}}
+
+MyObj* return_pointer_object(MyObj* a); // expected-warning {{parameter in cross-TU function should be marked [[clang::lifetimebound]]}}
+
+inline View inline_header_return_view(View a) { // expected-warning {{parameter in cross-TU function should be marked [[clang::lifetimebound]]}}
+  return a;                                     // expected-note {{param returned here}}
+}
+
----------------
kashika0112 wrote:

Yes done

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


More information about the cfe-commits mailing list