[clang] [LifetimeSafety] Introduce a liveness-based lifetime policy (PR #159991)
Utkarsh Saxena via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 7 10:20:09 PDT 2025
================
@@ -372,6 +421,19 @@ void no_error_if_dangle_then_rescue_gsl() {
v.use(); // This is safe.
}
+void no_error_loan_from_current_iteration(bool cond) {
+ // See https://github.com/llvm/llvm-project/issues/156959.
+ MyObj b;
+ while (cond) {
+ MyObj a;
+ View p = b;
+ if (cond) {
+ p = a;
+ }
+ (void)p;
----------------
usx95 wrote:
As discussed f2f, it is hard to isolate dereferences of a pointer from other usages. Rust also considers this as a usage. It keeps the analysis simple and reliable. Happy to reconsider in the future if there is need for more precision.
https://github.com/llvm/llvm-project/pull/159991
More information about the cfe-commits
mailing list