@@ -3878,8 +3878,12 @@ LifetimeCaptureByAttr *Sema::ParseLifetimeCaptureByAttr(const ParsedAttr &AL,
38783878 return nullptr ;
38793879 }
38803880 unsigned N = AL.getNumArgs ();
3881- IdentifierInfo **ParamIdents = new (Context) IdentifierInfo *[N];
3882- SourceLocation *ParamLocs = new (Context) SourceLocation[N];
3881+ SmallVector<int > FakeParamIndices (N, LifetimeCaptureByAttr::INVALID);
3882+ auto *CapturedBy = ::new (Context)
3883+ LifetimeCaptureByAttr (Context, AL, FakeParamIndices.data (), N);
3884+ CapturedBy->CreateArgs (Context);
3885+ MutableArrayRef<SourceLocation> ParamLocs = CapturedBy->getArgLocs ();
3886+ MutableArrayRef<IdentifierInfo *> ParamIdents = CapturedBy->getArgIdents ();
38833887 bool IsValid = true ;
38843888 for (unsigned I = 0 ; I < N; ++I) {
38853889 if (AL.isArgExpr (I)) {
@@ -3899,13 +3903,7 @@ LifetimeCaptureByAttr *Sema::ParseLifetimeCaptureByAttr(const ParsedAttr &AL,
38993903 ParamIdents[I] = IdLoc->Ident ;
39003904 ParamLocs[I] = IdLoc->Loc ;
39013905 }
3902- if (!IsValid)
3903- return nullptr ;
3904- SmallVector<int > FakeParamIndices (N, LifetimeCaptureByAttr::INVALID);
3905- LifetimeCaptureByAttr *CapturedBy = ::new (Context) LifetimeCaptureByAttr (
3906- Context, AL, FakeParamIndices.data (), FakeParamIndices.size ());
3907- CapturedBy->setArgs (ParamIdents, ParamLocs);
3908- return CapturedBy;
3906+ return IsValid ? CapturedBy : nullptr ;
39093907}
39103908
39113909static void handleLifetimeCaptureByAttr (Sema &S, Decl *D,
0 commit comments