[clang] [Clang] Extend lifetime bound analysis to support assignments (PR #96475)
Haojian Wu via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 28 07:27:10 PDT 2024
================
@@ -1053,16 +1072,23 @@ void checkExprLifetime(Sema &SemaRef, const InitializedEntity &Entity,
if (pathContainsInit(Path))
return false;
- SemaRef.Diag(DiagLoc, diag::warn_dangling_variable)
- << RK << !Entity.getParent()
- << ExtendingEntity->getDecl()->isImplicit()
- << ExtendingEntity->getDecl() << Init->isGLValue() << DiagRange;
+ if (InitEntity) {
+ SemaRef.Diag(DiagLoc, diag::warn_dangling_variable)
+ << RK << !InitEntity->getParent()
+ << ExtendingEntity->getDecl()->isImplicit()
+ << ExtendingEntity->getDecl() << Init->isGLValue() << DiagRange;
+ } else {
+ SemaRef.Diag(DiagLoc, diag::warn_dangling_pointer_assignment)
+ << AEntity->LHS << DiagRange;
+ }
break;
}
break;
}
case LK_MemInitializer: {
+ assert(InitEntity && "Expect only on initializing the entity");
+
----------------
hokein wrote:
Done.
https://github.com/llvm/llvm-project/pull/96475
More information about the cfe-commits
mailing list