================ @@ -1412,17 +1438,34 @@ static void checkExprLifetimeImpl(Sema &SemaRef, return false; }; + bool HasReferenceBinding = Init->isGLValue(); llvm::SmallVector<IndirectLocalPathEntry, 8> Path; - if (LK == LK_Assignment && - shouldRunGSLAssignmentAnalysis(SemaRef, *AEntity)) { - Path.push_back( - {isAssignmentOperatorLifetimeBound(AEntity->AssignmentOperator) - ? IndirectLocalPathEntry::LifetimeBoundCall - : IndirectLocalPathEntry::GslPointerAssignment, - Init}); + switch (LK) { + case LK_Assignment: { + if (shouldRunGSLAssignmentAnalysis(SemaRef, *AEntity)) + Path.push_back( + {isAssignmentOperatorLifetimeBound(AEntity->AssignmentOperator) + ? IndirectLocalPathEntry::LifetimeBoundCall + : IndirectLocalPathEntry::GslPointerAssignment, + Init}); + break; + } + case LK_LifetimeCapture: { + Path.push_back({IndirectLocalPathEntry::LifetimeCapture, Init}); + if (isRecordWithAttr<PointerAttr>(Init->getType())) + HasReferenceBinding = false; + // Skip the top MTE if it is a temporary object of the pointer-like type + // itself. + if (auto *MTE = dyn_cast<MaterializeTemporaryExpr>(Init); + MTE && isPointerLikeType(Init->getType())) + Init = MTE->getSubExpr(); ---------------- usx95 wrote:
Great. Simplified. I have kept the `assert` though since it is important to not lifetimeextend. > So the need for IndirectLocalPathEntry::LifetimeCapture isn’t clear. I think it is important to stop lifetime extension. https://github.com/llvm/llvm-project/pull/115921 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits