================
@@ -3919,7 +3919,24 @@ static void HandleLifetimeCaptureByAttr(Sema &S, Decl *D,
void Sema::LazyProcessLifetimeCaptureByParams(FunctionDecl *FD) {
bool HasImplicitThisParam = isInstanceMethod(FD);
-
+ SmallVector<LifetimeCaptureByAttr *, 1> Attrs;
+ for (ParmVarDecl *PVD : FD->parameters())
+ if (auto *A = PVD->getAttr<LifetimeCaptureByAttr>())
+ Attrs.push_back(A);
+ if (HasImplicitThisParam) {
+ TypeSourceInfo *TSI = FD->getTypeSourceInfo();
+ if (!TSI)
+ return;
+ AttributedTypeLoc ATL;
+ for (TypeLoc TL = TSI->getTypeLoc();
+ (ATL = TL.getAsAdjusted<AttributedTypeLoc>());
+ TL = ATL.getModifiedLoc()) {
+ if (auto *A = ATL.getAttrAs<LifetimeCaptureByAttr>())
+ Attrs.push_back(const_cast<LifetimeCaptureByAttr *>(A));
+ }
+ }
+ if (Attrs.empty())
+ return;
----------------
usx95 wrote:
Avoid building expensive param map if we do not have any capture by attr.
https://github.com/llvm/llvm-project/pull/115823
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits