https://github.com/Endilll updated https://github.com/llvm/llvm-project/pull/68382
>From d987a8523086ab8b6d49f395429afda75769a731 Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov <serebrennikov.vladis...@gmail.com> Date: Fri, 6 Oct 2023 07:20:07 +0300 Subject: [PATCH 1/2] [clang][NFC] Add missing placement-new after Allocate() calls --- clang/lib/AST/DeclCXX.cpp | 3 ++- clang/lib/AST/DeclObjC.cpp | 4 ++-- clang/lib/Serialization/ASTReaderDecl.cpp | 6 ++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp index 42bab4ed51b7290..a92b788366434ce 100644 --- a/clang/lib/AST/DeclCXX.cpp +++ b/clang/lib/AST/DeclCXX.cpp @@ -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()) diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index e934a81d086e3c0..e1eef2dbd9c3d28 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -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( diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index d553b3c6d78dedc..7bf1bcceccf584e 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -2002,13 +2002,15 @@ 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; } } >From ba88e02ced2a97bfe37396de3c0746a07339cb89 Mon Sep 17 00:00:00 2001 From: Vlad Serebrennikov <serebrennikov.vladis...@gmail.com> Date: Fri, 6 Oct 2023 07:58:05 +0300 Subject: [PATCH 2/2] Run clang-format --- clang/lib/Serialization/ASTReaderDecl.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp index 7bf1bcceccf584e..6a2f607d916c472 100644 --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -2002,7 +2002,8 @@ void ASTDeclReader::ReadCXXDefinitionData( case LCK_StarThis: case LCK_This: case LCK_VLAType: - new (ToCapture) Capture(Loc, IsImplicit, Kind, nullptr,SourceLocation()); + new (ToCapture) + Capture(Loc, IsImplicit, Kind, nullptr, SourceLocation()); ToCapture++; break; case LCK_ByCopy: _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits