[clang] [LifetimeSafety] Detect expiry of loans to trivially destructed types (PR #168855)
Kashika Akhouri via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 21 01:22:48 PST 2025
================
@@ -493,6 +515,20 @@ MyObj& reference_return_of_local() {
// expected-note at -1 {{returned here}}
}
+int* trivial_uar() {
+ int *a;
+ int b = 1;
+ a = &b; // expected-warning {{address of stack memory is returned later}}
+ return a; // expected-note {{returned here}}
+}
+
+S* trivial_class_uar () {
+ S *ptr;
+ S s;
+ ptr = &s; // expected-warning {{address of stack memory is returned later}}
+ return ptr; // expected-note {{returned here}}
+}
----------------
kashika0112 wrote:
Done.
https://github.com/llvm/llvm-project/pull/168855
More information about the cfe-commits
mailing list