Skip to content

[clang][NFC] Add missing placement-new after Allocate() calls #68382

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clang/lib/AST/DeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1484,7 +1484,8 @@ void CXXRecordDecl::setCaptures(ASTContext &Context,
if (Captures[I].isExplicit())
++Data.NumExplicitCaptures;

*ToCapture++ = Captures[I];
new (ToCapture) LambdaCapture(Captures[I]);
ToCapture++;
}

if (!lambdaIsDefaultConstructibleAndAssignable())
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/AST/DeclObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,8 +931,8 @@ void ObjCMethodDecl::setParamsAndSelLocs(ASTContext &C,
unsigned Size = sizeof(ParmVarDecl *) * NumParams +
sizeof(SourceLocation) * SelLocs.size();
ParamsAndSelLocs = C.Allocate(Size);
std::copy(Params.begin(), Params.end(), getParams());
std::copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
std::uninitialized_copy(Params.begin(), Params.end(), getParams());
std::uninitialized_copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
}

void ObjCMethodDecl::getSelectorLocs(
Expand Down
7 changes: 5 additions & 2 deletions clang/lib/Serialization/ASTReaderDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2002,13 +2002,16 @@ void ASTDeclReader::ReadCXXDefinitionData(
case LCK_StarThis:
case LCK_This:
case LCK_VLAType:
*ToCapture++ = Capture(Loc, IsImplicit, Kind, nullptr,SourceLocation());
new (ToCapture)
Capture(Loc, IsImplicit, Kind, nullptr, SourceLocation());
ToCapture++;
break;
case LCK_ByCopy:
case LCK_ByRef:
auto *Var = readDeclAs<VarDecl>();
SourceLocation EllipsisLoc = readSourceLocation();
*ToCapture++ = Capture(Loc, IsImplicit, Kind, Var, EllipsisLoc);
new (ToCapture) Capture(Loc, IsImplicit, Kind, Var, EllipsisLoc);
ToCapture++;
break;
}
}
Expand Down