================ @@ -964,11 +966,26 @@ static bool pathOnlyInitializesGslPointer(IndirectLocalPath &Path) { return false; } -void checkExprLifetime(Sema &SemaRef, const InitializedEntity &Entity, +void checkExprLifetime(Sema &SemaRef, const CheckingEntity &CEntity, Expr *Init) { - LifetimeResult LR = getEntityLifetime(&Entity); - LifetimeKind LK = LR.getInt(); - const InitializedEntity *ExtendingEntity = LR.getPointer(); + LifetimeKind LK = LK_FullExpression; + + const AssignedEntity *AEntity = nullptr; + // Local variables for initialized entity. + const InitializedEntity *InitEntity = nullptr; + const InitializedEntity *ExtendingEntity = nullptr; + if (auto IEntityP = std::get_if<const InitializedEntity *>(&CEntity)) { + InitEntity = *IEntityP; + auto LTResult = getEntityLifetime(InitEntity); + LK = LTResult.getInt(); + ExtendingEntity = LTResult.getPointer(); + } else if (auto AEntityP = std::get_if<const AssignedEntity *>(&CEntity)) { + AEntity = *AEntityP; + if (AEntity->LHS->getType()->isPointerType()) // builtin pointer type + LK = LK_Extended; ---------------- Xazax-hun wrote:
I am a bit confused here, could you elaborate why we want `LK_Extended` here? As fas as I remember, assignments are not doing lifetime extension. https://github.com/llvm/llvm-project/pull/96475 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits