[clang] [LifetimeSafety] Suggest lifetime annotations (PR #169767)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 28 00:37:17 PST 2025
================
@@ -943,3 +943,73 @@ void parentheses(bool cond) {
} // expected-note 4 {{destroyed here}}
(void)*p; // expected-note 4 {{later used here}}
}
+
+//===----------------------------------------------------------------------===//
+// Lifetimebound Annotation Suggestion Tests
+//===----------------------------------------------------------------------===//
+
+View return_view_directly (View a // expected-warning {{param should be marked [[clang::lifetimebound]]}}.
+) {
+ return a; // expected-note {{param escapes here}}
+}
+
+View conditional_return_view (
+ View a, // expected-warning {{param should be marked [[clang::lifetimebound]]}}.
+ View b, // expected-warning {{param should be marked [[clang::lifetimebound]]}}.
+ bool c
+) {
----------------
usx95 wrote:
nit: Regarding formatting the function declaration:
```cpp
View conditional_return_view (
View a, // expected-warning {{param should be marked [[clang::lifetimebound]]}}.
View b, // expected-warning {{param should be marked [[clang::lifetimebound]]}}.
bool c) {
```
https://github.com/llvm/llvm-project/pull/169767
More information about the cfe-commits
mailing list