================ @@ -268,6 +268,40 @@ void Sema::inferLifetimeBoundAttribute(FunctionDecl *FD) { } } +static bool IsPointerLikeType(QualType QT) { + QT = QT.getNonReferenceType(); + if (QT->isPointerType()) + return true; + auto *RD = QT->getAsCXXRecordDecl(); + if (!RD) + return false; + RD = RD->getCanonicalDecl(); + if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(RD)) + RD = CTSD->getSpecializedTemplate()->getTemplatedDecl(); + return RD->hasAttr<PointerAttr>(); +} + +void Sema::inferLifetimeCaptureByAttribute(FunctionDecl *FD) { + if (!FD) + return; + auto *MD = dyn_cast<CXXMethodDecl>(FD); + if (!MD || !MD->getIdentifier() || !MD->getParent()->isInStdNamespace()) + return; + static const llvm::StringSet<> CapturingMethods{"insert", "push", + "push_front", "push_back"}; + if (!CapturingMethods.contains(MD->getName())) + return; + for (ParmVarDecl *PVD : MD->parameters()) { + if (PVD->hasAttr<LifetimeCaptureByAttr>()) + return; ---------------- Xazax-hun wrote:
Is return intentional here? Do we want an explicit attr to turn off the inference for the rest of the params? If that is the case, I think we want to turn off the inference for the params before the explicit attr as well, not just after. https://github.com/llvm/llvm-project/pull/117122 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits