[clang] [clang] Extend lifetime analysis to support assignments for pointer-like objects. (PR #99032)

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 16 19:32:11 PDT 2024


================
@@ -1284,16 +1294,26 @@ void checkExprLifetime(Sema &SemaRef, const InitializedEntity &Entity,
   auto LTResult = getEntityLifetime(&Entity);
   LifetimeKind LK = LTResult.getInt();
   const InitializedEntity *ExtendingEntity = LTResult.getPointer();
-  checkExprLifetimeImpl(SemaRef, &Entity, ExtendingEntity, LK, nullptr, Init);
+  bool EnableLifetimeWarnings = !SemaRef.getDiagnostics().isIgnored(
+      diag::warn_dangling_lifetime_pointer, SourceLocation());
+  checkExprLifetimeImpl(SemaRef, &Entity, ExtendingEntity, LK, nullptr, Init,
----------------
shafik wrote:

```suggestion
  checkExprLifetimeImpl(SemaRef, &Entity, ExtendingEntity, LK, /*AEntity=*/nullptr, Init,
```

nitpick

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


More information about the cfe-commits mailing list