[NFC][Clang][AST] Adopt llvm::copy in Clang AST (#145192)

This commit is contained in:
Rahul Joshi 2025-06-23 10:10:53 -07:00 committed by GitHub
parent f40909f605
commit ed75e55a70
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 73 additions and 90 deletions

View File

@ -814,7 +814,7 @@ public:
llvm::StringRef backupStr(llvm::StringRef S) const { llvm::StringRef backupStr(llvm::StringRef S) const {
char *Buf = new (*this) char[S.size()]; char *Buf = new (*this) char[S.size()];
std::copy(S.begin(), S.end(), Buf); llvm::copy(S, Buf);
return llvm::StringRef(Buf, S.size()); return llvm::StringRef(Buf, S.size());
} }

View File

@ -387,7 +387,7 @@ public:
assert( assert(
DK.size() == NumKinds && DK.size() == NumKinds &&
"Number of directive kinds is not the same as the preallocated buffer"); "Number of directive kinds is not the same as the preallocated buffer");
std::copy(DK.begin(), DK.end(), getDirectiveKinds().begin()); llvm::copy(DK, getDirectiveKinds().begin());
} }
SourceLocation getLParenLoc() { return LParenLoc; } SourceLocation getLParenLoc() { return LParenLoc; }
@ -5917,7 +5917,7 @@ protected:
void setUniqueDecls(ArrayRef<ValueDecl *> UDs) { void setUniqueDecls(ArrayRef<ValueDecl *> UDs) {
assert(UDs.size() == NumUniqueDeclarations && assert(UDs.size() == NumUniqueDeclarations &&
"Unexpected amount of unique declarations."); "Unexpected amount of unique declarations.");
std::copy(UDs.begin(), UDs.end(), getUniqueDeclsRef().begin()); llvm::copy(UDs, getUniqueDeclsRef().begin());
} }
/// Get the number of lists per declaration that are in the trailing /// Get the number of lists per declaration that are in the trailing
@ -5939,7 +5939,7 @@ protected:
void setDeclNumLists(ArrayRef<unsigned> DNLs) { void setDeclNumLists(ArrayRef<unsigned> DNLs) {
assert(DNLs.size() == NumUniqueDeclarations && assert(DNLs.size() == NumUniqueDeclarations &&
"Unexpected amount of list numbers."); "Unexpected amount of list numbers.");
std::copy(DNLs.begin(), DNLs.end(), getDeclNumListsRef().begin()); llvm::copy(DNLs, getDeclNumListsRef().begin());
} }
/// Get the cumulative component lists sizes that are in the trailing /// Get the cumulative component lists sizes that are in the trailing
@ -5965,7 +5965,7 @@ protected:
void setComponentListSizes(ArrayRef<unsigned> CLSs) { void setComponentListSizes(ArrayRef<unsigned> CLSs) {
assert(CLSs.size() == NumComponentLists && assert(CLSs.size() == NumComponentLists &&
"Unexpected amount of component lists."); "Unexpected amount of component lists.");
std::copy(CLSs.begin(), CLSs.end(), getComponentListSizesRef().begin()); llvm::copy(CLSs, getComponentListSizesRef().begin());
} }
/// Get the components that are in the trailing objects of the class. /// Get the components that are in the trailing objects of the class.
@ -5989,7 +5989,7 @@ protected:
"Unexpected amount of component lists."); "Unexpected amount of component lists.");
assert(CLSs.size() == NumComponentLists && assert(CLSs.size() == NumComponentLists &&
"Unexpected amount of list sizes."); "Unexpected amount of list sizes.");
std::copy(Components.begin(), Components.end(), getComponentsRef().begin()); llvm::copy(Components, getComponentsRef().begin());
} }
/// Fill the clause information from the list of declarations and /// Fill the clause information from the list of declarations and
@ -6063,7 +6063,7 @@ protected:
++CLSI; ++CLSI;
// Append components after the current components iterator. // Append components after the current components iterator.
CI = std::copy(C.begin(), C.end(), CI); CI = llvm::copy(C, CI);
} }
} }
} }
@ -6107,7 +6107,7 @@ protected:
"Unexpected number of user-defined mappers."); "Unexpected number of user-defined mappers.");
assert(SupportsMapper && assert(SupportsMapper &&
"Must be a clause that is possible to have user-defined mappers"); "Must be a clause that is possible to have user-defined mappers");
std::copy(DMDs.begin(), DMDs.end(), getUDMapperRefs().begin()); llvm::copy(DMDs, getUDMapperRefs().begin());
} }
public: public:

View File

@ -2214,7 +2214,7 @@ class AttributedStmt final
: ValueStmt(AttributedStmtClass), SubStmt(SubStmt) { : ValueStmt(AttributedStmtClass), SubStmt(SubStmt) {
AttributedStmtBits.NumAttrs = Attrs.size(); AttributedStmtBits.NumAttrs = Attrs.size();
AttributedStmtBits.AttrLoc = Loc; AttributedStmtBits.AttrLoc = Loc;
std::copy(Attrs.begin(), Attrs.end(), getAttrArrayPtr()); llvm::copy(Attrs, getAttrArrayPtr());
} }
explicit AttributedStmt(EmptyShell Empty, unsigned NumAttrs) explicit AttributedStmt(EmptyShell Empty, unsigned NumAttrs)

View File

@ -4123,7 +4123,7 @@ ExpectedDecl ASTNodeImporter::VisitFunctionDecl(FunctionDecl *D) {
return std::move(Err); return std::move(Err);
auto **Memory = auto **Memory =
new (Importer.getToContext()) CXXCtorInitializer *[NumInitializers]; new (Importer.getToContext()) CXXCtorInitializer *[NumInitializers];
std::copy(CtorInitializers.begin(), CtorInitializers.end(), Memory); llvm::copy(CtorInitializers, Memory);
auto *ToCtor = cast<CXXConstructorDecl>(ToFunction); auto *ToCtor = cast<CXXConstructorDecl>(ToFunction);
ToCtor->setCtorInitializers(Memory); ToCtor->setCtorInitializers(Memory);
ToCtor->setNumCtorInitializers(NumInitializers); ToCtor->setNumCtorInitializers(NumInitializers);

View File

@ -2110,7 +2110,7 @@ void QualifierInfo::setTemplateParameterListsInfo(
if (!TPLists.empty()) { if (!TPLists.empty()) {
TemplParamLists = new (Context) TemplateParameterList *[TPLists.size()]; TemplParamLists = new (Context) TemplateParameterList *[TPLists.size()];
NumTemplParamLists = TPLists.size(); NumTemplParamLists = TPLists.size();
std::copy(TPLists.begin(), TPLists.end(), TemplParamLists); llvm::copy(TPLists, TemplParamLists);
} }
} }
@ -3753,7 +3753,7 @@ void FunctionDecl::setParams(ASTContext &C,
// Zero params -> null pointer. // Zero params -> null pointer.
if (!NewParamInfo.empty()) { if (!NewParamInfo.empty()) {
ParamInfo = new (C) ParmVarDecl*[NewParamInfo.size()]; ParamInfo = new (C) ParmVarDecl*[NewParamInfo.size()];
std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo); llvm::copy(NewParamInfo, ParamInfo);
} }
} }
@ -5322,7 +5322,7 @@ void BlockDecl::setParams(ArrayRef<ParmVarDecl *> NewParamInfo) {
if (!NewParamInfo.empty()) { if (!NewParamInfo.empty()) {
NumParams = NewParamInfo.size(); NumParams = NewParamInfo.size();
ParamInfo = new (getASTContext()) ParmVarDecl*[NewParamInfo.size()]; ParamInfo = new (getASTContext()) ParmVarDecl*[NewParamInfo.size()];
std::copy(NewParamInfo.begin(), NewParamInfo.end(), ParamInfo); llvm::copy(NewParamInfo, ParamInfo);
} }
} }
@ -5379,7 +5379,7 @@ PragmaCommentDecl *PragmaCommentDecl::Create(const ASTContext &C,
PragmaCommentDecl *PCD = PragmaCommentDecl *PCD =
new (C, DC, additionalSizeToAlloc<char>(Arg.size() + 1)) new (C, DC, additionalSizeToAlloc<char>(Arg.size() + 1))
PragmaCommentDecl(DC, CommentLoc, CommentKind); PragmaCommentDecl(DC, CommentLoc, CommentKind);
memcpy(PCD->getTrailingObjects(), Arg.data(), Arg.size()); llvm::copy(Arg, PCD->getTrailingObjects());
PCD->getTrailingObjects()[Arg.size()] = '\0'; PCD->getTrailingObjects()[Arg.size()] = '\0';
return PCD; return PCD;
} }
@ -5401,9 +5401,9 @@ PragmaDetectMismatchDecl::Create(const ASTContext &C, TranslationUnitDecl *DC,
PragmaDetectMismatchDecl *PDMD = PragmaDetectMismatchDecl *PDMD =
new (C, DC, additionalSizeToAlloc<char>(ValueStart + Value.size() + 1)) new (C, DC, additionalSizeToAlloc<char>(ValueStart + Value.size() + 1))
PragmaDetectMismatchDecl(DC, Loc, ValueStart); PragmaDetectMismatchDecl(DC, Loc, ValueStart);
memcpy(PDMD->getTrailingObjects(), Name.data(), Name.size()); llvm::copy(Name, PDMD->getTrailingObjects());
PDMD->getTrailingObjects()[Name.size()] = '\0'; PDMD->getTrailingObjects()[Name.size()] = '\0';
memcpy(PDMD->getTrailingObjects() + ValueStart, Value.data(), Value.size()); llvm::copy(Value, PDMD->getTrailingObjects() + ValueStart);
PDMD->getTrailingObjects()[ValueStart + Value.size()] = '\0'; PDMD->getTrailingObjects()[ValueStart + Value.size()] = '\0';
return PDMD; return PDMD;
} }
@ -5443,7 +5443,7 @@ LabelDecl *LabelDecl::CreateDeserialized(ASTContext &C, GlobalDeclID ID) {
void LabelDecl::setMSAsmLabel(StringRef Name) { void LabelDecl::setMSAsmLabel(StringRef Name) {
char *Buffer = new (getASTContext(), 1) char[Name.size() + 1]; char *Buffer = new (getASTContext(), 1) char[Name.size() + 1];
memcpy(Buffer, Name.data(), Name.size()); llvm::copy(Name, Buffer);
Buffer[Name.size()] = '\0'; Buffer[Name.size()] = '\0';
MSAsmName = Buffer; MSAsmName = Buffer;
} }
@ -5828,7 +5828,7 @@ void HLSLBufferDecl::setDefaultBufferDecls(ArrayRef<Decl *> Decls) {
// allocate array for default decls with ASTContext allocator // allocate array for default decls with ASTContext allocator
Decl **DeclsArray = new (getASTContext()) Decl *[Decls.size()]; Decl **DeclsArray = new (getASTContext()) Decl *[Decls.size()];
std::copy(Decls.begin(), Decls.end(), DeclsArray); llvm::copy(Decls, DeclsArray);
DefaultBufferDecls = ArrayRef<Decl *>(DeclsArray, Decls.size()); DefaultBufferDecls = ArrayRef<Decl *>(DeclsArray, Decls.size());
} }
@ -5869,8 +5869,7 @@ HLSLRootSignatureDecl *HLSLRootSignatureDecl::Create(
RootElements.size())) RootElements.size()))
HLSLRootSignatureDecl(DC, Loc, ID, RootElements.size()); HLSLRootSignatureDecl(DC, Loc, ID, RootElements.size());
auto *StoredElems = RSDecl->getElems(); auto *StoredElems = RSDecl->getElems();
std::uninitialized_copy(RootElements.begin(), RootElements.end(), llvm::uninitialized_copy(RootElements, StoredElems);
StoredElems);
return RSDecl; return RSDecl;
} }

View File

@ -1512,7 +1512,7 @@ ObjCTypeParamList::ObjCTypeParamList(SourceLocation lAngleLoc,
ArrayRef<ObjCTypeParamDecl *> typeParams, ArrayRef<ObjCTypeParamDecl *> typeParams,
SourceLocation rAngleLoc) SourceLocation rAngleLoc)
: Brackets(lAngleLoc, rAngleLoc), NumParams(typeParams.size()) { : Brackets(lAngleLoc, rAngleLoc), NumParams(typeParams.size()) {
std::copy(typeParams.begin(), typeParams.end(), begin()); llvm::copy(typeParams, begin());
} }
ObjCTypeParamList *ObjCTypeParamList::create( ObjCTypeParamList *ObjCTypeParamList::create(

View File

@ -261,9 +261,8 @@ CXXNewExpr::CXXNewExpr(bool IsGlobalNew, FunctionDecl *OperatorNew,
getTrailingObjects<Stmt *>()[arraySizeOffset()] = *ArraySize; getTrailingObjects<Stmt *>()[arraySizeOffset()] = *ArraySize;
if (Initializer) if (Initializer)
getTrailingObjects<Stmt *>()[initExprOffset()] = Initializer; getTrailingObjects<Stmt *>()[initExprOffset()] = Initializer;
for (unsigned I = 0; I != PlacementArgs.size(); ++I) llvm::copy(PlacementArgs,
getTrailingObjects<Stmt *>()[placementNewArgsOffset() + I] = getTrailingObjects<Stmt *>() + placementNewArgsOffset());
PlacementArgs[I];
if (IsParenTypeId) if (IsParenTypeId)
getTrailingObjects<SourceRange>()[0] = TypeIdParens; getTrailingObjects<SourceRange>()[0] = TypeIdParens;
@ -1208,10 +1207,8 @@ CXXConstructExpr::CXXConstructExpr(
CXXConstructExprBits.Loc = Loc; CXXConstructExprBits.Loc = Loc;
Stmt **TrailingArgs = getTrailingArgs(); Stmt **TrailingArgs = getTrailingArgs();
for (unsigned I = 0, N = Args.size(); I != N; ++I) { llvm::copy(Args, TrailingArgs);
assert(Args[I] && "NULL argument in CXXConstructExpr!"); assert(llvm::all_of(Args, [](const Stmt *Arg) { return Arg != nullptr; }));
TrailingArgs[I] = Args[I];
}
// CXXTemporaryObjectExpr does this itself after setting its TypeSourceInfo. // CXXTemporaryObjectExpr does this itself after setting its TypeSourceInfo.
if (SC == CXXConstructExprClass) if (SC == CXXConstructExprClass)
@ -1472,8 +1469,7 @@ CXXUnresolvedConstructExpr::CXXUnresolvedConstructExpr(
RParenLoc(RParenLoc) { RParenLoc(RParenLoc) {
CXXUnresolvedConstructExprBits.NumArgs = Args.size(); CXXUnresolvedConstructExprBits.NumArgs = Args.size();
auto **StoredArgs = getTrailingObjects(); auto **StoredArgs = getTrailingObjects();
for (unsigned I = 0; I != Args.size(); ++I) llvm::copy(Args, StoredArgs);
StoredArgs[I] = Args[I];
setDependence(computeDependence(this)); setDependence(computeDependence(this));
} }
@ -1885,8 +1881,7 @@ TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation Loc, TypeTrait Kind,
assert(Args.size() == TypeTraitExprBits.NumArgs && assert(Args.size() == TypeTraitExprBits.NumArgs &&
"TypeTraitExprBits.NumArgs overflow!"); "TypeTraitExprBits.NumArgs overflow!");
auto **ToArgs = getTrailingObjects<TypeSourceInfo *>(); auto **ToArgs = getTrailingObjects<TypeSourceInfo *>();
for (unsigned I = 0, N = Args.size(); I != N; ++I) llvm::copy(Args, ToArgs);
ToArgs[I] = Args[I];
setDependence(computeDependence(this)); setDependence(computeDependence(this));

View File

@ -144,10 +144,8 @@ RequiresExpr::RequiresExpr(ASTContext &C, SourceLocation RequiresKWLoc,
if (RequirementContainsError(R)) if (RequirementContainsError(R))
setDependence(getDependence() | ExprDependence::Error); setDependence(getDependence() | ExprDependence::Error);
} }
std::copy(LocalParameters.begin(), LocalParameters.end(), llvm::copy(LocalParameters, getTrailingObjects<ParmVarDecl *>());
getTrailingObjects<ParmVarDecl *>()); llvm::copy(Requirements, getTrailingObjects<concepts::Requirement *>());
std::copy(Requirements.begin(), Requirements.end(),
getTrailingObjects<concepts::Requirement *>());
RequiresExprBits.IsSatisfied |= Dependent; RequiresExprBits.IsSatisfied |= Dependent;
// FIXME: move the computing dependency logic to ComputeDependence.h // FIXME: move the computing dependency logic to ComputeDependence.h
if (ContainsUnexpandedParameterPack) if (ContainsUnexpandedParameterPack)

View File

@ -163,10 +163,8 @@ void ObjCMessageExpr::initArgsAndSelLocs(ArrayRef<Expr *> Args,
MyArgs[I] = Args[I]; MyArgs[I] = Args[I];
SelLocsKind = SelLocsK; SelLocsKind = SelLocsK;
if (!isImplicit()) { if (!isImplicit() && SelLocsK == SelLoc_NonStandard)
if (SelLocsK == SelLoc_NonStandard) llvm::copy(SelLocs, getStoredSelLocs());
std::copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
}
} }
ObjCMessageExpr * ObjCMessageExpr *

View File

@ -428,7 +428,7 @@ OMPUpdateClause *OMPUpdateClause::CreateEmpty(const ASTContext &C,
void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) { void OMPPrivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
assert(VL.size() == varlist_size() && assert(VL.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"); "Number of private copies is not the same as the preallocated buffer");
std::copy(VL.begin(), VL.end(), varlist_end()); llvm::copy(VL, varlist_end());
} }
OMPPrivateClause * OMPPrivateClause *
@ -453,13 +453,13 @@ OMPPrivateClause *OMPPrivateClause::CreateEmpty(const ASTContext &C,
void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) { void OMPFirstprivateClause::setPrivateCopies(ArrayRef<Expr *> VL) {
assert(VL.size() == varlist_size() && assert(VL.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"); "Number of private copies is not the same as the preallocated buffer");
std::copy(VL.begin(), VL.end(), varlist_end()); llvm::copy(VL, varlist_end());
} }
void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) { void OMPFirstprivateClause::setInits(ArrayRef<Expr *> VL) {
assert(VL.size() == varlist_size() && assert(VL.size() == varlist_size() &&
"Number of inits is not the same as the preallocated buffer"); "Number of inits is not the same as the preallocated buffer");
std::copy(VL.begin(), VL.end(), getPrivateCopies().end()); llvm::copy(VL, getPrivateCopies().end());
} }
OMPFirstprivateClause * OMPFirstprivateClause *
@ -486,29 +486,28 @@ OMPFirstprivateClause *OMPFirstprivateClause::CreateEmpty(const ASTContext &C,
void OMPLastprivateClause::setPrivateCopies(ArrayRef<Expr *> PrivateCopies) { void OMPLastprivateClause::setPrivateCopies(ArrayRef<Expr *> PrivateCopies) {
assert(PrivateCopies.size() == varlist_size() && assert(PrivateCopies.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"); "Number of private copies is not the same as the preallocated buffer");
std::copy(PrivateCopies.begin(), PrivateCopies.end(), varlist_end()); llvm::copy(PrivateCopies, varlist_end());
} }
void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) { void OMPLastprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
assert(SrcExprs.size() == varlist_size() && "Number of source expressions is " assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
"not the same as the " "not the same as the "
"preallocated buffer"); "preallocated buffer");
std::copy(SrcExprs.begin(), SrcExprs.end(), getPrivateCopies().end()); llvm::copy(SrcExprs, getPrivateCopies().end());
} }
void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) { void OMPLastprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
assert(DstExprs.size() == varlist_size() && "Number of destination " assert(DstExprs.size() == varlist_size() && "Number of destination "
"expressions is not the same as " "expressions is not the same as "
"the preallocated buffer"); "the preallocated buffer");
std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end()); llvm::copy(DstExprs, getSourceExprs().end());
} }
void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) { void OMPLastprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
assert(AssignmentOps.size() == varlist_size() && assert(AssignmentOps.size() == varlist_size() &&
"Number of assignment expressions is not the same as the preallocated " "Number of assignment expressions is not the same as the preallocated "
"buffer"); "buffer");
std::copy(AssignmentOps.begin(), AssignmentOps.end(), llvm::copy(AssignmentOps, getDestinationExprs().end());
getDestinationExprs().end());
} }
OMPLastprivateClause *OMPLastprivateClause::Create( OMPLastprivateClause *OMPLastprivateClause::Create(
@ -555,32 +554,32 @@ OMPSharedClause *OMPSharedClause::CreateEmpty(const ASTContext &C, unsigned N) {
void OMPLinearClause::setPrivates(ArrayRef<Expr *> PL) { void OMPLinearClause::setPrivates(ArrayRef<Expr *> PL) {
assert(PL.size() == varlist_size() && assert(PL.size() == varlist_size() &&
"Number of privates is not the same as the preallocated buffer"); "Number of privates is not the same as the preallocated buffer");
std::copy(PL.begin(), PL.end(), varlist_end()); llvm::copy(PL, varlist_end());
} }
void OMPLinearClause::setInits(ArrayRef<Expr *> IL) { void OMPLinearClause::setInits(ArrayRef<Expr *> IL) {
assert(IL.size() == varlist_size() && assert(IL.size() == varlist_size() &&
"Number of inits is not the same as the preallocated buffer"); "Number of inits is not the same as the preallocated buffer");
std::copy(IL.begin(), IL.end(), getPrivates().end()); llvm::copy(IL, getPrivates().end());
} }
void OMPLinearClause::setUpdates(ArrayRef<Expr *> UL) { void OMPLinearClause::setUpdates(ArrayRef<Expr *> UL) {
assert(UL.size() == varlist_size() && assert(UL.size() == varlist_size() &&
"Number of updates is not the same as the preallocated buffer"); "Number of updates is not the same as the preallocated buffer");
std::copy(UL.begin(), UL.end(), getInits().end()); llvm::copy(UL, getInits().end());
} }
void OMPLinearClause::setFinals(ArrayRef<Expr *> FL) { void OMPLinearClause::setFinals(ArrayRef<Expr *> FL) {
assert(FL.size() == varlist_size() && assert(FL.size() == varlist_size() &&
"Number of final updates is not the same as the preallocated buffer"); "Number of final updates is not the same as the preallocated buffer");
std::copy(FL.begin(), FL.end(), getUpdates().end()); llvm::copy(FL, getUpdates().end());
} }
void OMPLinearClause::setUsedExprs(ArrayRef<Expr *> UE) { void OMPLinearClause::setUsedExprs(ArrayRef<Expr *> UE) {
assert( assert(
UE.size() == varlist_size() + 1 && UE.size() == varlist_size() + 1 &&
"Number of used expressions is not the same as the preallocated buffer"); "Number of used expressions is not the same as the preallocated buffer");
std::copy(UE.begin(), UE.end(), getFinals().end() + 2); llvm::copy(UE, getFinals().end() + 2);
} }
OMPLinearClause *OMPLinearClause::Create( OMPLinearClause *OMPLinearClause::Create(
@ -659,22 +658,21 @@ void OMPCopyinClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
assert(SrcExprs.size() == varlist_size() && "Number of source expressions is " assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
"not the same as the " "not the same as the "
"preallocated buffer"); "preallocated buffer");
std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end()); llvm::copy(SrcExprs, varlist_end());
} }
void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) { void OMPCopyinClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
assert(DstExprs.size() == varlist_size() && "Number of destination " assert(DstExprs.size() == varlist_size() && "Number of destination "
"expressions is not the same as " "expressions is not the same as "
"the preallocated buffer"); "the preallocated buffer");
std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end()); llvm::copy(DstExprs, getSourceExprs().end());
} }
void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) { void OMPCopyinClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
assert(AssignmentOps.size() == varlist_size() && assert(AssignmentOps.size() == varlist_size() &&
"Number of assignment expressions is not the same as the preallocated " "Number of assignment expressions is not the same as the preallocated "
"buffer"); "buffer");
std::copy(AssignmentOps.begin(), AssignmentOps.end(), llvm::copy(AssignmentOps, getDestinationExprs().end());
getDestinationExprs().end());
} }
OMPCopyinClause *OMPCopyinClause::Create( OMPCopyinClause *OMPCopyinClause::Create(
@ -700,22 +698,21 @@ void OMPCopyprivateClause::setSourceExprs(ArrayRef<Expr *> SrcExprs) {
assert(SrcExprs.size() == varlist_size() && "Number of source expressions is " assert(SrcExprs.size() == varlist_size() && "Number of source expressions is "
"not the same as the " "not the same as the "
"preallocated buffer"); "preallocated buffer");
std::copy(SrcExprs.begin(), SrcExprs.end(), varlist_end()); llvm::copy(SrcExprs, varlist_end());
} }
void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) { void OMPCopyprivateClause::setDestinationExprs(ArrayRef<Expr *> DstExprs) {
assert(DstExprs.size() == varlist_size() && "Number of destination " assert(DstExprs.size() == varlist_size() && "Number of destination "
"expressions is not the same as " "expressions is not the same as "
"the preallocated buffer"); "the preallocated buffer");
std::copy(DstExprs.begin(), DstExprs.end(), getSourceExprs().end()); llvm::copy(DstExprs, getSourceExprs().end());
} }
void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) { void OMPCopyprivateClause::setAssignmentOps(ArrayRef<Expr *> AssignmentOps) {
assert(AssignmentOps.size() == varlist_size() && assert(AssignmentOps.size() == varlist_size() &&
"Number of assignment expressions is not the same as the preallocated " "Number of assignment expressions is not the same as the preallocated "
"buffer"); "buffer");
std::copy(AssignmentOps.begin(), AssignmentOps.end(), llvm::copy(AssignmentOps, getDestinationExprs().end());
getDestinationExprs().end());
} }
OMPCopyprivateClause *OMPCopyprivateClause::Create( OMPCopyprivateClause *OMPCopyprivateClause::Create(
@ -741,28 +738,28 @@ OMPCopyprivateClause *OMPCopyprivateClause::CreateEmpty(const ASTContext &C,
void OMPReductionClause::setPrivates(ArrayRef<Expr *> Privates) { void OMPReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
assert(Privates.size() == varlist_size() && assert(Privates.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"); "Number of private copies is not the same as the preallocated buffer");
std::copy(Privates.begin(), Privates.end(), varlist_end()); llvm::copy(Privates, varlist_end());
} }
void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) { void OMPReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
assert( assert(
LHSExprs.size() == varlist_size() && LHSExprs.size() == varlist_size() &&
"Number of LHS expressions is not the same as the preallocated buffer"); "Number of LHS expressions is not the same as the preallocated buffer");
std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end()); llvm::copy(LHSExprs, getPrivates().end());
} }
void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) { void OMPReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
assert( assert(
RHSExprs.size() == varlist_size() && RHSExprs.size() == varlist_size() &&
"Number of RHS expressions is not the same as the preallocated buffer"); "Number of RHS expressions is not the same as the preallocated buffer");
std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end()); llvm::copy(RHSExprs, getLHSExprs().end());
} }
void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) { void OMPReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
assert(ReductionOps.size() == varlist_size() && "Number of reduction " assert(ReductionOps.size() == varlist_size() && "Number of reduction "
"expressions is not the same " "expressions is not the same "
"as the preallocated buffer"); "as the preallocated buffer");
std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end()); llvm::copy(ReductionOps, getRHSExprs().end());
} }
void OMPReductionClause::setInscanCopyOps(ArrayRef<Expr *> Ops) { void OMPReductionClause::setInscanCopyOps(ArrayRef<Expr *> Ops) {
@ -843,28 +840,28 @@ OMPReductionClause::CreateEmpty(const ASTContext &C, unsigned N,
void OMPTaskReductionClause::setPrivates(ArrayRef<Expr *> Privates) { void OMPTaskReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
assert(Privates.size() == varlist_size() && assert(Privates.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"); "Number of private copies is not the same as the preallocated buffer");
std::copy(Privates.begin(), Privates.end(), varlist_end()); llvm::copy(Privates, varlist_end());
} }
void OMPTaskReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) { void OMPTaskReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
assert( assert(
LHSExprs.size() == varlist_size() && LHSExprs.size() == varlist_size() &&
"Number of LHS expressions is not the same as the preallocated buffer"); "Number of LHS expressions is not the same as the preallocated buffer");
std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end()); llvm::copy(LHSExprs, getPrivates().end());
} }
void OMPTaskReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) { void OMPTaskReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
assert( assert(
RHSExprs.size() == varlist_size() && RHSExprs.size() == varlist_size() &&
"Number of RHS expressions is not the same as the preallocated buffer"); "Number of RHS expressions is not the same as the preallocated buffer");
std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end()); llvm::copy(RHSExprs, getLHSExprs().end());
} }
void OMPTaskReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) { void OMPTaskReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
assert(ReductionOps.size() == varlist_size() && "Number of task reduction " assert(ReductionOps.size() == varlist_size() && "Number of task reduction "
"expressions is not the same " "expressions is not the same "
"as the preallocated buffer"); "as the preallocated buffer");
std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end()); llvm::copy(ReductionOps, getRHSExprs().end());
} }
OMPTaskReductionClause *OMPTaskReductionClause::Create( OMPTaskReductionClause *OMPTaskReductionClause::Create(
@ -896,28 +893,28 @@ OMPTaskReductionClause *OMPTaskReductionClause::CreateEmpty(const ASTContext &C,
void OMPInReductionClause::setPrivates(ArrayRef<Expr *> Privates) { void OMPInReductionClause::setPrivates(ArrayRef<Expr *> Privates) {
assert(Privates.size() == varlist_size() && assert(Privates.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"); "Number of private copies is not the same as the preallocated buffer");
std::copy(Privates.begin(), Privates.end(), varlist_end()); llvm::copy(Privates, varlist_end());
} }
void OMPInReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) { void OMPInReductionClause::setLHSExprs(ArrayRef<Expr *> LHSExprs) {
assert( assert(
LHSExprs.size() == varlist_size() && LHSExprs.size() == varlist_size() &&
"Number of LHS expressions is not the same as the preallocated buffer"); "Number of LHS expressions is not the same as the preallocated buffer");
std::copy(LHSExprs.begin(), LHSExprs.end(), getPrivates().end()); llvm::copy(LHSExprs, getPrivates().end());
} }
void OMPInReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) { void OMPInReductionClause::setRHSExprs(ArrayRef<Expr *> RHSExprs) {
assert( assert(
RHSExprs.size() == varlist_size() && RHSExprs.size() == varlist_size() &&
"Number of RHS expressions is not the same as the preallocated buffer"); "Number of RHS expressions is not the same as the preallocated buffer");
std::copy(RHSExprs.begin(), RHSExprs.end(), getLHSExprs().end()); llvm::copy(RHSExprs, getLHSExprs().end());
} }
void OMPInReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) { void OMPInReductionClause::setReductionOps(ArrayRef<Expr *> ReductionOps) {
assert(ReductionOps.size() == varlist_size() && "Number of in reduction " assert(ReductionOps.size() == varlist_size() && "Number of in reduction "
"expressions is not the same " "expressions is not the same "
"as the preallocated buffer"); "as the preallocated buffer");
std::copy(ReductionOps.begin(), ReductionOps.end(), getRHSExprs().end()); llvm::copy(ReductionOps, getRHSExprs().end());
} }
void OMPInReductionClause::setTaskgroupDescriptors( void OMPInReductionClause::setTaskgroupDescriptors(
@ -925,8 +922,7 @@ void OMPInReductionClause::setTaskgroupDescriptors(
assert(TaskgroupDescriptors.size() == varlist_size() && assert(TaskgroupDescriptors.size() == varlist_size() &&
"Number of in reduction descriptors is not the same as the " "Number of in reduction descriptors is not the same as the "
"preallocated buffer"); "preallocated buffer");
std::copy(TaskgroupDescriptors.begin(), TaskgroupDescriptors.end(), llvm::copy(TaskgroupDescriptors, getReductionOps().end());
getReductionOps().end());
} }
OMPInReductionClause *OMPInReductionClause::Create( OMPInReductionClause *OMPInReductionClause::Create(
@ -1322,13 +1318,13 @@ OMPFromClause::CreateEmpty(const ASTContext &C,
void OMPUseDevicePtrClause::setPrivateCopies(ArrayRef<Expr *> VL) { void OMPUseDevicePtrClause::setPrivateCopies(ArrayRef<Expr *> VL) {
assert(VL.size() == varlist_size() && assert(VL.size() == varlist_size() &&
"Number of private copies is not the same as the preallocated buffer"); "Number of private copies is not the same as the preallocated buffer");
std::copy(VL.begin(), VL.end(), varlist_end()); llvm::copy(VL, varlist_end());
} }
void OMPUseDevicePtrClause::setInits(ArrayRef<Expr *> VL) { void OMPUseDevicePtrClause::setInits(ArrayRef<Expr *> VL) {
assert(VL.size() == varlist_size() && assert(VL.size() == varlist_size() &&
"Number of inits is not the same as the preallocated buffer"); "Number of inits is not the same as the preallocated buffer");
std::copy(VL.begin(), VL.end(), getPrivateCopies().end()); llvm::copy(VL, getPrivateCopies().end());
} }
OMPUseDevicePtrClause *OMPUseDevicePtrClause::Create( OMPUseDevicePtrClause *OMPUseDevicePtrClause::Create(
@ -1543,7 +1539,7 @@ OMPNontemporalClause *OMPNontemporalClause::CreateEmpty(const ASTContext &C,
void OMPNontemporalClause::setPrivateRefs(ArrayRef<Expr *> VL) { void OMPNontemporalClause::setPrivateRefs(ArrayRef<Expr *> VL) {
assert(VL.size() == varlist_size() && "Number of private references is not " assert(VL.size() == varlist_size() && "Number of private references is not "
"the same as the preallocated buffer"); "the same as the preallocated buffer");
std::copy(VL.begin(), VL.end(), varlist_end()); llvm::copy(VL, varlist_end());
} }
OMPInclusiveClause *OMPInclusiveClause::Create(const ASTContext &C, OMPInclusiveClause *OMPInclusiveClause::Create(const ASTContext &C,

View File

@ -384,8 +384,7 @@ CompoundStmt::CompoundStmt(ArrayRef<Stmt *> Stmts, FPOptionsOverride FPFeatures,
void CompoundStmt::setStmts(ArrayRef<Stmt *> Stmts) { void CompoundStmt::setStmts(ArrayRef<Stmt *> Stmts) {
assert(CompoundStmtBits.NumStmts == Stmts.size() && assert(CompoundStmtBits.NumStmts == Stmts.size() &&
"NumStmts doesn't fit in bits of CompoundStmtBits.NumStmts!"); "NumStmts doesn't fit in bits of CompoundStmtBits.NumStmts!");
llvm::copy(Stmts, body_begin());
std::copy(Stmts.begin(), Stmts.end(), body_begin());
} }
CompoundStmt *CompoundStmt::Create(const ASTContext &C, ArrayRef<Stmt *> Stmts, CompoundStmt *CompoundStmt::Create(const ASTContext &C, ArrayRef<Stmt *> Stmts,
@ -947,10 +946,10 @@ void MSAsmStmt::initialize(const ASTContext &C, StringRef asmstr,
AsmStr = copyIntoContext(C, asmstr); AsmStr = copyIntoContext(C, asmstr);
Exprs = new (C) Stmt*[exprs.size()]; Exprs = new (C) Stmt*[exprs.size()];
std::copy(exprs.begin(), exprs.end(), Exprs); llvm::copy(exprs, Exprs);
AsmToks = new (C) Token[asmtoks.size()]; AsmToks = new (C) Token[asmtoks.size()];
std::copy(asmtoks.begin(), asmtoks.end(), AsmToks); llvm::copy(asmtoks, AsmToks);
Constraints = new (C) StringRef[exprs.size()]; Constraints = new (C) StringRef[exprs.size()];
std::transform(constraints.begin(), constraints.end(), Constraints, std::transform(constraints.begin(), constraints.end(), Constraints,
@ -1385,7 +1384,7 @@ CapturedStmt::CapturedStmt(Stmt *S, CapturedRegionKind Kind,
// Copy all Capture objects. // Copy all Capture objects.
Capture *Buffer = getStoredCaptures(); Capture *Buffer = getStoredCaptures();
std::copy(Captures.begin(), Captures.end(), Buffer); llvm::copy(Captures, Buffer);
} }
CapturedStmt::CapturedStmt(EmptyShell Empty, unsigned NumCaptures) CapturedStmt::CapturedStmt(EmptyShell Empty, unsigned NumCaptures)

View File

@ -42,7 +42,7 @@ CXXTryStmt::CXXTryStmt(SourceLocation tryLoc, CompoundStmt *tryBlock,
: Stmt(CXXTryStmtClass), TryLoc(tryLoc), NumHandlers(handlers.size()) { : Stmt(CXXTryStmtClass), TryLoc(tryLoc), NumHandlers(handlers.size()) {
Stmt **Stmts = getStmts(); Stmt **Stmts = getStmts();
Stmts[0] = tryBlock; Stmts[0] = tryBlock;
std::copy(handlers.begin(), handlers.end(), Stmts + 1); llvm::copy(handlers, Stmts + 1);
} }
CXXForRangeStmt::CXXForRangeStmt(Stmt *Init, DeclStmt *Range, CXXForRangeStmt::CXXForRangeStmt(Stmt *Init, DeclStmt *Range,
@ -123,6 +123,5 @@ CoroutineBodyStmt::CoroutineBodyStmt(CoroutineBodyStmt::CtorArgs const &Args)
SubStmts[CoroutineBodyStmt::ReturnStmt] = Args.ReturnStmt; SubStmts[CoroutineBodyStmt::ReturnStmt] = Args.ReturnStmt;
SubStmts[CoroutineBodyStmt::ReturnStmtOnAllocFailure] = SubStmts[CoroutineBodyStmt::ReturnStmtOnAllocFailure] =
Args.ReturnStmtOnAllocFailure; Args.ReturnStmtOnAllocFailure;
std::copy(Args.ParamMoves.begin(), Args.ParamMoves.end(), llvm::copy(Args.ParamMoves, const_cast<Stmt **>(getParamMoves().data()));
const_cast<Stmt **>(getParamMoves().data()));
} }

View File

@ -3982,9 +3982,8 @@ CountAttributedType::CountAttributedType(
CountAttributedTypeBits.CountInBytes = CountInBytes; CountAttributedTypeBits.CountInBytes = CountInBytes;
CountAttributedTypeBits.OrNull = OrNull; CountAttributedTypeBits.OrNull = OrNull;
auto *DeclSlot = getTrailingObjects(); auto *DeclSlot = getTrailingObjects();
llvm::copy(CoupledDecls, DeclSlot);
Decls = llvm::ArrayRef(DeclSlot, CoupledDecls.size()); Decls = llvm::ArrayRef(DeclSlot, CoupledDecls.size());
for (unsigned i = 0; i != CoupledDecls.size(); ++i)
DeclSlot[i] = CoupledDecls[i];
} }
StringRef CountAttributedType::getAttributeName(bool WithMacroPrefix) const { StringRef CountAttributedType::getAttributeName(bool WithMacroPrefix) const {