[clang] [lldb] [llvm] [mlir] [NFC][Support] Add llvm::uninitialized_copy (PR #138174)
Rahul Joshi via cfe-commits
cfe-commits at lists.llvm.org
Thu May 1 11:24:08 PDT 2025
https://github.com/jurahul updated https://github.com/llvm/llvm-project/pull/138174
>From b34e9b6c708dfbe097504804a0a85e1169518911 Mon Sep 17 00:00:00 2001
From: Rahul Joshi <rjoshi at nvidia.com>
Date: Wed, 30 Apr 2025 23:47:37 -0700
Subject: [PATCH] [NFC][Support] Add llvm::uninitialized_copy
---
clang/include/clang/AST/DeclCXX.h | 6 +-
clang/include/clang/AST/DeclOpenACC.h | 9 +--
clang/include/clang/AST/ExprCXX.h | 6 +-
clang/include/clang/AST/OpenACCClause.h | 72 +++++++------------
clang/include/clang/AST/StmtOpenACC.h | 58 +++++++--------
clang/include/clang/Sema/ParsedTemplate.h | 4 +-
clang/lib/AST/Decl.cpp | 6 +-
clang/lib/AST/DeclObjC.cpp | 4 +-
clang/lib/AST/DeclTemplate.cpp | 11 ++-
clang/lib/AST/Expr.cpp | 8 +--
clang/lib/AST/ExprCXX.cpp | 16 ++---
clang/lib/AST/OpenACCClause.cpp | 13 ++--
clang/lib/AST/StmtOpenACC.cpp | 4 +-
clang/lib/AST/Type.cpp | 8 +--
clang/tools/libclang/CXIndexDataConsumer.cpp | 3 +-
lldb/source/Utility/Checksum.cpp | 4 +-
llvm/include/llvm/ADT/ArrayRef.h | 2 +-
llvm/include/llvm/ADT/STLExtras.h | 5 ++
llvm/lib/Analysis/ScalarEvolution.cpp | 10 +--
llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 3 +-
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp | 4 +-
llvm/lib/DebugInfo/MSF/MSFBuilder.cpp | 6 +-
llvm/lib/IR/AttributeImpl.h | 2 +-
llvm/lib/ObjectYAML/MinidumpEmitter.cpp | 2 +-
llvm/lib/Support/FoldingSet.cpp | 4 +-
.../AMDGPU/MCTargetDesc/AMDGPUMCExpr.cpp | 2 +-
llvm/lib/Transforms/IPO/LowerTypeTests.cpp | 7 +-
.../unittests/Support/TrailingObjectsTest.cpp | 11 ++-
mlir/include/mlir/IR/BuiltinAttributes.td | 2 +-
mlir/include/mlir/Support/StorageUniquer.h | 4 +-
.../Dialect/Affine/Analysis/NestedMatcher.cpp | 4 +-
mlir/lib/IR/AffineMapDetail.h | 3 +-
mlir/lib/IR/Location.cpp | 8 +--
mlir/lib/IR/MLIRContext.cpp | 2 +-
mlir/lib/IR/TypeDetail.h | 3 +-
mlir/lib/Tools/PDLL/AST/Nodes.cpp | 42 ++++-------
36 files changed, 154 insertions(+), 204 deletions(-)
diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h
index dd325815ee28d..20720115bf6c3 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -3861,8 +3861,7 @@ class UsingPackDecl final
InstantiatedFrom ? InstantiatedFrom->getDeclName()
: DeclarationName()),
InstantiatedFrom(InstantiatedFrom), NumExpansions(UsingDecls.size()) {
- std::uninitialized_copy(UsingDecls.begin(), UsingDecls.end(),
- getTrailingObjects<NamedDecl *>());
+ llvm::uninitialized_copy(UsingDecls, getTrailingObjects<NamedDecl *>());
}
void anchor() override;
@@ -4233,8 +4232,7 @@ class DecompositionDecl final
: VarDecl(Decomposition, C, DC, StartLoc, LSquareLoc, nullptr, T, TInfo,
SC),
NumBindings(Bindings.size()) {
- std::uninitialized_copy(Bindings.begin(), Bindings.end(),
- getTrailingObjects<BindingDecl *>());
+ llvm::uninitialized_copy(Bindings, getTrailingObjects<BindingDecl *>());
for (auto *B : Bindings) {
B->setDecomposedDecl(this);
if (B->isParameterPack() && B->getBinding()) {
diff --git a/clang/include/clang/AST/DeclOpenACC.h b/clang/include/clang/AST/DeclOpenACC.h
index 8c612fbf1ec07..905d9bf636ea1 100644
--- a/clang/include/clang/AST/DeclOpenACC.h
+++ b/clang/include/clang/AST/DeclOpenACC.h
@@ -18,6 +18,7 @@
#include "clang/AST/Decl.h"
#include "clang/AST/OpenACCClause.h"
#include "clang/Basic/OpenACCKinds.h"
+#include "llvm/ADT/STLExtras.h"
namespace clang {
@@ -85,8 +86,8 @@ class OpenACCDeclareDecl final
: OpenACCConstructDecl(OpenACCDeclare, DC, OpenACCDirectiveKind::Declare,
StartLoc, DirLoc, EndLoc) {
// Initialize the trailing storage.
- std::uninitialized_copy(Clauses.begin(), Clauses.end(),
- getTrailingObjects<const OpenACCClause *>());
+ llvm::uninitialized_copy(Clauses,
+ getTrailingObjects<const OpenACCClause *>());
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
Clauses.size()));
@@ -136,8 +137,8 @@ class OpenACCRoutineDecl final
assert(LParenLoc.isValid() &&
"Cannot represent implicit name with this declaration");
// Initialize the trailing storage.
- std::uninitialized_copy(Clauses.begin(), Clauses.end(),
- getTrailingObjects<const OpenACCClause *>());
+ llvm::uninitialized_copy(Clauses,
+ getTrailingObjects<const OpenACCClause *>());
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
Clauses.size()));
}
diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h
index 844f6dd90ae1d..15d94a8765dd6 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -41,6 +41,7 @@
#include "clang/Basic/TypeTraits.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/PointerUnion.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/Casting.h"
@@ -4417,7 +4418,7 @@ class SizeOfPackExpr final
assert((!Length || PartialArgs.empty()) &&
"have partial args for non-dependent sizeof... expression");
auto *Args = getTrailingObjects<TemplateArgument>();
- std::uninitialized_copy(PartialArgs.begin(), PartialArgs.end(), Args);
+ llvm::uninitialized_copy(PartialArgs, Args);
setDependence(Length ? ExprDependence::None
: ExprDependence::ValueInstantiation);
}
@@ -4522,8 +4523,7 @@ class PackIndexingExpr final
FullySubstituted(FullySubstituted) {
auto *Exprs = getTrailingObjects<Expr *>();
- std::uninitialized_copy(SubstitutedExprs.begin(), SubstitutedExprs.end(),
- Exprs);
+ llvm::uninitialized_copy(SubstitutedExprs, Exprs);
setDependence(computeDependence(this));
if (!isInstantiationDependent())
diff --git a/clang/include/clang/AST/OpenACCClause.h b/clang/include/clang/AST/OpenACCClause.h
index 449bcb71f9f32..65377b91f83d3 100644
--- a/clang/include/clang/AST/OpenACCClause.h
+++ b/clang/include/clang/AST/OpenACCClause.h
@@ -13,9 +13,11 @@
#ifndef LLVM_CLANG_AST_OPENACCCLAUSE_H
#define LLVM_CLANG_AST_OPENACCCLAUSE_H
+
#include "clang/AST/ASTContext.h"
#include "clang/AST/StmtIterator.h"
#include "clang/Basic/OpenACCKinds.h"
+#include "llvm/ADT/STLExtras.h"
#include <utility>
#include <variant>
@@ -291,8 +293,7 @@ class OpenACCDeviceTypeClause final
"Only a single asterisk version is permitted, and must be the "
"only one");
- std::uninitialized_copy(Archs.begin(), Archs.end(),
- getTrailingObjects<DeviceTypeArgument>());
+ llvm::uninitialized_copy(Archs, getTrailingObjects<DeviceTypeArgument>());
}
public:
@@ -537,10 +538,9 @@ class OpenACCWaitClause final
QueuesLoc(QueuesLoc) {
// The first element of the trailing storage is always the devnum expr,
// whether it is used or not.
- std::uninitialized_copy(&DevNumExpr, &DevNumExpr + 1,
- getTrailingObjects<Expr *>());
- std::uninitialized_copy(QueueIdExprs.begin(), QueueIdExprs.end(),
- getTrailingObjects<Expr *>() + 1);
+ auto *Exprs = getTrailingObjects<Expr *>();
+ llvm::uninitialized_copy(ArrayRef(DevNumExpr), Exprs);
+ llvm::uninitialized_copy(QueueIdExprs, Exprs + 1);
setExprs(
MutableArrayRef(getTrailingObjects<Expr *>(), QueueIdExprs.size() + 1));
}
@@ -579,8 +579,7 @@ class OpenACCNumGangsClause final
ArrayRef<Expr *> IntExprs, SourceLocation EndLoc)
: OpenACCClauseWithExprs(OpenACCClauseKind::NumGangs, BeginLoc, LParenLoc,
EndLoc) {
- std::uninitialized_copy(IntExprs.begin(), IntExprs.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(IntExprs, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), IntExprs.size()));
}
@@ -609,8 +608,7 @@ class OpenACCTileClause final
ArrayRef<Expr *> SizeExprs, SourceLocation EndLoc)
: OpenACCClauseWithExprs(OpenACCClauseKind::Tile, BeginLoc, LParenLoc,
EndLoc) {
- std::uninitialized_copy(SizeExprs.begin(), SizeExprs.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(SizeExprs, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), SizeExprs.size()));
}
@@ -848,8 +846,7 @@ class OpenACCPrivateClause final
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
: OpenACCClauseWithVarList(OpenACCClauseKind::Private, BeginLoc,
LParenLoc, EndLoc) {
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
@@ -871,8 +868,7 @@ class OpenACCFirstPrivateClause final
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
: OpenACCClauseWithVarList(OpenACCClauseKind::FirstPrivate, BeginLoc,
LParenLoc, EndLoc) {
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
@@ -894,8 +890,7 @@ class OpenACCDevicePtrClause final
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
: OpenACCClauseWithVarList(OpenACCClauseKind::DevicePtr, BeginLoc,
LParenLoc, EndLoc) {
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
@@ -917,8 +912,7 @@ class OpenACCAttachClause final
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
: OpenACCClauseWithVarList(OpenACCClauseKind::Attach, BeginLoc, LParenLoc,
EndLoc) {
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
@@ -940,8 +934,7 @@ class OpenACCDetachClause final
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
: OpenACCClauseWithVarList(OpenACCClauseKind::Detach, BeginLoc, LParenLoc,
EndLoc) {
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
@@ -963,8 +956,7 @@ class OpenACCDeleteClause final
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
: OpenACCClauseWithVarList(OpenACCClauseKind::Delete, BeginLoc, LParenLoc,
EndLoc) {
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
@@ -986,8 +978,7 @@ class OpenACCUseDeviceClause final
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
: OpenACCClauseWithVarList(OpenACCClauseKind::UseDevice, BeginLoc,
LParenLoc, EndLoc) {
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
@@ -1009,8 +1000,7 @@ class OpenACCNoCreateClause final
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
: OpenACCClauseWithVarList(OpenACCClauseKind::NoCreate, BeginLoc,
LParenLoc, EndLoc) {
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
@@ -1032,8 +1022,7 @@ class OpenACCPresentClause final
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
: OpenACCClauseWithVarList(OpenACCClauseKind::Present, BeginLoc,
LParenLoc, EndLoc) {
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
@@ -1054,8 +1043,7 @@ class OpenACCHostClause final
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
: OpenACCClauseWithVarList(OpenACCClauseKind::Host, BeginLoc, LParenLoc,
EndLoc) {
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
@@ -1078,8 +1066,7 @@ class OpenACCDeviceClause final
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
: OpenACCClauseWithVarList(OpenACCClauseKind::Device, BeginLoc, LParenLoc,
EndLoc) {
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
@@ -1107,8 +1094,7 @@ class OpenACCCopyClause final
Spelling == OpenACCClauseKind::PCopy ||
Spelling == OpenACCClauseKind::PresentOrCopy) &&
"Invalid clause kind for copy-clause");
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
@@ -1142,8 +1128,7 @@ class OpenACCCopyInClause final
Spelling == OpenACCClauseKind::PCopyIn ||
Spelling == OpenACCClauseKind::PresentOrCopyIn) &&
"Invalid clause kind for copyin-clause");
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
@@ -1176,8 +1161,7 @@ class OpenACCCopyOutClause final
Spelling == OpenACCClauseKind::PCopyOut ||
Spelling == OpenACCClauseKind::PresentOrCopyOut) &&
"Invalid clause kind for copyout-clause");
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
@@ -1210,8 +1194,7 @@ class OpenACCCreateClause final
Spelling == OpenACCClauseKind::PCreate ||
Spelling == OpenACCClauseKind::PresentOrCreate) &&
"Invalid clause kind for create-clause");
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
@@ -1241,8 +1224,7 @@ class OpenACCReductionClause final
: OpenACCClauseWithVarList(OpenACCClauseKind::Reduction, BeginLoc,
LParenLoc, EndLoc),
Op(Operator) {
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
@@ -1268,8 +1250,7 @@ class OpenACCLinkClause final
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
: OpenACCClauseWithVarList(OpenACCClauseKind::Link, BeginLoc, LParenLoc,
EndLoc) {
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
@@ -1293,8 +1274,7 @@ class OpenACCDeviceResidentClause final
ArrayRef<Expr *> VarList, SourceLocation EndLoc)
: OpenACCClauseWithVarList(OpenACCClauseKind::DeviceResident, BeginLoc,
LParenLoc, EndLoc) {
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), VarList.size()));
}
diff --git a/clang/include/clang/AST/StmtOpenACC.h b/clang/include/clang/AST/StmtOpenACC.h
index 39c4c81844911..359909e98befb 100644
--- a/clang/include/clang/AST/StmtOpenACC.h
+++ b/clang/include/clang/AST/StmtOpenACC.h
@@ -17,6 +17,7 @@
#include "clang/AST/Stmt.h"
#include "clang/Basic/OpenACCKinds.h"
#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/STLExtras.h"
#include <memory>
namespace clang {
@@ -159,8 +160,8 @@ class OpenACCComputeConstruct final
"represented by this type");
// Initialize the trailing storage.
- std::uninitialized_copy(Clauses.begin(), Clauses.end(),
- getTrailingObjects<const OpenACCClause *>());
+ llvm::uninitialized_copy(Clauses,
+ getTrailingObjects<const OpenACCClause *>());
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
Clauses.size()));
@@ -272,8 +273,8 @@ class OpenACCCombinedConstruct final
"Only parallel loop, serial loop, and kernels loop constructs "
"should be represented by this type");
- std::uninitialized_copy(Clauses.begin(), Clauses.end(),
- getTrailingObjects<const OpenACCClause *>());
+ llvm::uninitialized_copy(Clauses,
+ getTrailingObjects<const OpenACCClause *>());
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
Clauses.size()));
}
@@ -322,8 +323,8 @@ class OpenACCDataConstruct final
: OpenACCAssociatedStmtConstruct(OpenACCDataConstructClass,
OpenACCDirectiveKind::Data, Start,
DirectiveLoc, End, StructuredBlock) {
- std::uninitialized_copy(Clauses.begin(), Clauses.end(),
- getTrailingObjects<const OpenACCClause *>());
+ llvm::uninitialized_copy(Clauses,
+ getTrailingObjects<const OpenACCClause *>());
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
Clauses.size()));
}
@@ -368,8 +369,8 @@ class OpenACCEnterDataConstruct final
: OpenACCConstructStmt(OpenACCEnterDataConstructClass,
OpenACCDirectiveKind::EnterData, Start,
DirectiveLoc, End) {
- std::uninitialized_copy(Clauses.begin(), Clauses.end(),
- getTrailingObjects<const OpenACCClause *>());
+ llvm::uninitialized_copy(Clauses,
+ getTrailingObjects<const OpenACCClause *>());
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
Clauses.size()));
}
@@ -406,8 +407,8 @@ class OpenACCExitDataConstruct final
: OpenACCConstructStmt(OpenACCExitDataConstructClass,
OpenACCDirectiveKind::ExitData, Start,
DirectiveLoc, End) {
- std::uninitialized_copy(Clauses.begin(), Clauses.end(),
- getTrailingObjects<const OpenACCClause *>());
+ llvm::uninitialized_copy(Clauses,
+ getTrailingObjects<const OpenACCClause *>());
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
Clauses.size()));
}
@@ -447,8 +448,8 @@ class OpenACCHostDataConstruct final
: OpenACCAssociatedStmtConstruct(OpenACCHostDataConstructClass,
OpenACCDirectiveKind::HostData, Start,
DirectiveLoc, End, StructuredBlock) {
- std::uninitialized_copy(Clauses.begin(), Clauses.end(),
- getTrailingObjects<const OpenACCClause *>());
+ llvm::uninitialized_copy(Clauses,
+ getTrailingObjects<const OpenACCClause *>());
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
Clauses.size()));
}
@@ -525,14 +526,9 @@ class OpenACCWaitConstruct final
"NumExprs should always be >= 1 because the 'devnum' "
"expr is represented by a null if necessary");
- std::uninitialized_copy(&DevNumExpr, &DevNumExpr + 1,
- getExprPtr());
- std::uninitialized_copy(QueueIdExprs.begin(), QueueIdExprs.end(),
- getExprPtr() + 1);
-
- std::uninitialized_copy(const_cast<OpenACCClause **>(Clauses.begin()),
- const_cast<OpenACCClause **>(Clauses.end()),
- getTrailingObjects<OpenACCClause *>());
+ llvm::uninitialized_copy(ArrayRef(DevNumExpr), getExprPtr());
+ llvm::uninitialized_copy(QueueIdExprs, getExprPtr() + 1);
+ llvm::uninitialized_copy(Clauses, getTrailingObjects<OpenACCClause *>());
setClauseList(MutableArrayRef(const_cast<const OpenACCClause **>(
getTrailingObjects<OpenACCClause *>()),
Clauses.size()));
@@ -624,7 +620,7 @@ class OpenACCCacheConstruct final
ParensLoc(LParenLoc, RParenLoc), ReadOnlyLoc(ReadOnlyLoc),
NumVars(VarList.size()) {
- std::uninitialized_copy(VarList.begin(), VarList.end(), getVarListPtr());
+ llvm::uninitialized_copy(VarList, getVarListPtr());
}
Expr **getVarListPtr() const {
@@ -690,8 +686,8 @@ class OpenACCInitConstruct final
: OpenACCConstructStmt(OpenACCInitConstructClass,
OpenACCDirectiveKind::Init, Start, DirectiveLoc,
End) {
- std::uninitialized_copy(Clauses.begin(), Clauses.end(),
- getTrailingObjects<const OpenACCClause *>());
+ llvm::uninitialized_copy(Clauses,
+ getTrailingObjects<const OpenACCClause *>());
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
Clauses.size()));
}
@@ -730,8 +726,8 @@ class OpenACCShutdownConstruct final
: OpenACCConstructStmt(OpenACCShutdownConstructClass,
OpenACCDirectiveKind::Shutdown, Start,
DirectiveLoc, End) {
- std::uninitialized_copy(Clauses.begin(), Clauses.end(),
- getTrailingObjects<const OpenACCClause *>());
+ llvm::uninitialized_copy(Clauses,
+ getTrailingObjects<const OpenACCClause *>());
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
Clauses.size()));
}
@@ -770,8 +766,8 @@ class OpenACCSetConstruct final
: OpenACCConstructStmt(OpenACCSetConstructClass,
OpenACCDirectiveKind::Set, Start, DirectiveLoc,
End) {
- std::uninitialized_copy(Clauses.begin(), Clauses.end(),
- getTrailingObjects<const OpenACCClause *>());
+ llvm::uninitialized_copy(Clauses,
+ getTrailingObjects<const OpenACCClause *>());
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
Clauses.size()));
}
@@ -810,8 +806,8 @@ class OpenACCUpdateConstruct final
: OpenACCConstructStmt(OpenACCUpdateConstructClass,
OpenACCDirectiveKind::Update, Start, DirectiveLoc,
End) {
- std::uninitialized_copy(Clauses.begin(), Clauses.end(),
- getTrailingObjects<const OpenACCClause *>());
+ llvm::uninitialized_copy(Clauses,
+ getTrailingObjects<const OpenACCClause *>());
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
Clauses.size()));
}
@@ -859,8 +855,8 @@ class OpenACCAtomicConstruct final
DirectiveLoc, End, AssociatedStmt),
AtomicKind(AtKind) {
// Initialize the trailing storage.
- std::uninitialized_copy(Clauses.begin(), Clauses.end(),
- getTrailingObjects<const OpenACCClause *>());
+ llvm::uninitialized_copy(Clauses,
+ getTrailingObjects<const OpenACCClause *>());
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
Clauses.size()));
diff --git a/clang/include/clang/Sema/ParsedTemplate.h b/clang/include/clang/Sema/ParsedTemplate.h
index ac4dbbf294caf..cff7f04666358 100644
--- a/clang/include/clang/Sema/ParsedTemplate.h
+++ b/clang/include/clang/Sema/ParsedTemplate.h
@@ -19,6 +19,7 @@
#include "clang/Basic/TemplateKinds.h"
#include "clang/Sema/DeclSpec.h"
#include "clang/Sema/Ownership.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include <cassert>
#include <cstdlib>
@@ -249,8 +250,7 @@ namespace clang {
Kind(TemplateKind), LAngleLoc(LAngleLoc), RAngleLoc(RAngleLoc),
NumArgs(TemplateArgs.size()), ArgsInvalid(ArgsInvalid) {
- std::uninitialized_copy(TemplateArgs.begin(), TemplateArgs.end(),
- getTemplateArgs());
+ llvm::uninitialized_copy(TemplateArgs, getTemplateArgs());
}
~TemplateIdAnnotation() = default;
};
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 61d497999b669..e6e9414746ede 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -3123,8 +3123,7 @@ FunctionDecl::DefaultedOrDeletedFunctionInfo::Create(
Info->NumLookups = Lookups.size();
Info->HasDeletedMessage = DeletedMessage != nullptr;
- std::uninitialized_copy(Lookups.begin(), Lookups.end(),
- Info->getTrailingObjects<DeclAccessPair>());
+ llvm::uninitialized_copy(Lookups, Info->getTrailingObjects<DeclAccessPair>());
if (DeletedMessage)
*Info->getTrailingObjects<StringLiteral *>() = DeletedMessage;
return Info;
@@ -5868,8 +5867,7 @@ ImportDecl::ImportDecl(DeclContext *DC, SourceLocation StartLoc,
NextLocalImportAndComplete(nullptr, true) {
assert(getNumModuleIdentifiers(Imported) == IdentifierLocs.size());
auto *StoredLocs = getTrailingObjects<SourceLocation>();
- std::uninitialized_copy(IdentifierLocs.begin(), IdentifierLocs.end(),
- StoredLocs);
+ llvm::uninitialized_copy(IdentifierLocs, StoredLocs);
}
ImportDecl::ImportDecl(DeclContext *DC, SourceLocation StartLoc,
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp
index 5c107325df30c..596262e217984 100644
--- a/clang/lib/AST/DeclObjC.cpp
+++ b/clang/lib/AST/DeclObjC.cpp
@@ -929,8 +929,8 @@ void ObjCMethodDecl::setParamsAndSelLocs(ASTContext &C,
unsigned Size = sizeof(ParmVarDecl *) * NumParams +
sizeof(SourceLocation) * SelLocs.size();
ParamsAndSelLocs = C.Allocate(Size);
- std::uninitialized_copy(Params.begin(), Params.end(), getParams());
- std::uninitialized_copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
+ llvm::uninitialized_copy(Params, getParams());
+ llvm::uninitialized_copy(SelLocs, getStoredSelLocs());
}
void ObjCMethodDecl::getSelectorLocs(
diff --git a/clang/lib/AST/DeclTemplate.cpp b/clang/lib/AST/DeclTemplate.cpp
index 79a36109276f0..d058831b9f6bf 100644
--- a/clang/lib/AST/DeclTemplate.cpp
+++ b/clang/lib/AST/DeclTemplate.cpp
@@ -884,9 +884,8 @@ TemplateTemplateParmDecl::TemplateTemplateParmDecl(
: TemplateDecl(TemplateTemplateParm, DC, L, Id, Params),
TemplateParmPosition(D, P), Typename(Typename), ParameterPack(true),
ExpandedParameterPack(true), NumExpandedParams(Expansions.size()) {
- if (!Expansions.empty())
- std::uninitialized_copy(Expansions.begin(), Expansions.end(),
- getTrailingObjects<TemplateParameterList *>());
+ llvm::uninitialized_copy(Expansions,
+ getTrailingObjects<TemplateParameterList *>());
}
TemplateTemplateParmDecl *
@@ -944,8 +943,7 @@ void TemplateTemplateParmDecl::setDefaultArgument(
//===----------------------------------------------------------------------===//
TemplateArgumentList::TemplateArgumentList(ArrayRef<TemplateArgument> Args)
: NumArguments(Args.size()) {
- std::uninitialized_copy(Args.begin(), Args.end(),
- getTrailingObjects<TemplateArgument>());
+ llvm::uninitialized_copy(Args, getTrailingObjects<TemplateArgument>());
}
TemplateArgumentList *
@@ -1172,8 +1170,7 @@ ImplicitConceptSpecializationDecl::CreateDeserialized(
void ImplicitConceptSpecializationDecl::setTemplateArguments(
ArrayRef<TemplateArgument> Converted) {
assert(Converted.size() == NumTemplateArgs);
- std::uninitialized_copy(Converted.begin(), Converted.end(),
- getTrailingObjects<TemplateArgument>());
+ llvm::uninitialized_copy(Converted, getTrailingObjects<TemplateArgument>());
}
//===----------------------------------------------------------------------===//
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 59c0e47c7c195..718619824555b 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -2111,8 +2111,8 @@ ImplicitCastExpr *ImplicitCastExpr::Create(const ASTContext &C, QualType T,
ImplicitCastExpr *E =
new (Buffer) ImplicitCastExpr(T, Kind, Operand, PathSize, FPO, VK);
if (PathSize)
- std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
- E->getTrailingObjects<CXXBaseSpecifier *>());
+ llvm::uninitialized_copy(BasePath,
+ E->getTrailingObjects<CXXBaseSpecifier *>());
return E;
}
@@ -2138,8 +2138,8 @@ CStyleCastExpr *CStyleCastExpr::Create(const ASTContext &C, QualType T,
CStyleCastExpr *E =
new (Buffer) CStyleCastExpr(T, VK, K, Op, PathSize, FPO, WrittenTy, L, R);
if (PathSize)
- std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
- E->getTrailingObjects<CXXBaseSpecifier *>());
+ llvm::uninitialized_copy(BasePath,
+ E->getTrailingObjects<CXXBaseSpecifier *>());
return E;
}
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 169f11b611066..d51c7a85d301e 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -772,8 +772,8 @@ CXXStaticCastExpr::Create(const ASTContext &C, QualType T, ExprValueKind VK,
auto *E = new (Buffer) CXXStaticCastExpr(T, VK, K, Op, PathSize, WrittenTy,
FPO, L, RParenLoc, AngleBrackets);
if (PathSize)
- std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
- E->getTrailingObjects<CXXBaseSpecifier *>());
+ llvm::uninitialized_copy(BasePath,
+ E->getTrailingObjects<CXXBaseSpecifier *>());
return E;
}
@@ -800,8 +800,8 @@ CXXDynamicCastExpr *CXXDynamicCastExpr::Create(const ASTContext &C, QualType T,
new (Buffer) CXXDynamicCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
RParenLoc, AngleBrackets);
if (PathSize)
- std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
- E->getTrailingObjects<CXXBaseSpecifier *>());
+ llvm::uninitialized_copy(BasePath,
+ E->getTrailingObjects<CXXBaseSpecifier *>());
return E;
}
@@ -863,8 +863,8 @@ CXXReinterpretCastExpr::Create(const ASTContext &C, QualType T,
new (Buffer) CXXReinterpretCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
RParenLoc, AngleBrackets);
if (PathSize)
- std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
- E->getTrailingObjects<CXXBaseSpecifier *>());
+ llvm::uninitialized_copy(BasePath,
+ E->getTrailingObjects<CXXBaseSpecifier *>());
return E;
}
@@ -911,8 +911,8 @@ CXXFunctionalCastExpr *CXXFunctionalCastExpr::Create(
auto *E = new (Buffer)
CXXFunctionalCastExpr(T, VK, Written, K, Op, PathSize, FPO, L, R);
if (PathSize)
- std::uninitialized_copy_n(BasePath->data(), BasePath->size(),
- E->getTrailingObjects<CXXBaseSpecifier *>());
+ llvm::uninitialized_copy(BasePath,
+ E->getTrailingObjects<CXXBaseSpecifier *>());
return E;
}
diff --git a/clang/lib/AST/OpenACCClause.cpp b/clang/lib/AST/OpenACCClause.cpp
index 9d3645e6da1ca..526ea89a2cee3 100644
--- a/clang/lib/AST/OpenACCClause.cpp
+++ b/clang/lib/AST/OpenACCClause.cpp
@@ -114,8 +114,7 @@ OpenACCSelfClause::OpenACCSelfClause(SourceLocation BeginLoc,
: OpenACCClauseWithParams(OpenACCClauseKind::Self, BeginLoc, LParenLoc,
EndLoc),
HasConditionExpr(std::nullopt), NumExprs(VarList.size()) {
- std::uninitialized_copy(VarList.begin(), VarList.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(VarList, getTrailingObjects<Expr *>());
}
OpenACCSelfClause::OpenACCSelfClause(SourceLocation BeginLoc,
@@ -127,8 +126,8 @@ OpenACCSelfClause::OpenACCSelfClause(SourceLocation BeginLoc,
assert((!ConditionExpr || ConditionExpr->isInstantiationDependent() ||
ConditionExpr->getType()->isScalarType()) &&
"Condition expression type not scalar/dependent");
- std::uninitialized_copy(&ConditionExpr, &ConditionExpr + 1,
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(ArrayRef(ConditionExpr),
+ getTrailingObjects<Expr *>());
}
OpenACCClause::child_range OpenACCClause::children() {
@@ -167,11 +166,9 @@ OpenACCGangClause::OpenACCGangClause(SourceLocation BeginLoc,
: OpenACCClauseWithExprs(OpenACCClauseKind::Gang, BeginLoc, LParenLoc,
EndLoc) {
assert(GangKinds.size() == IntExprs.size() && "Mismatch exprs/kind?");
- std::uninitialized_copy(IntExprs.begin(), IntExprs.end(),
- getTrailingObjects<Expr *>());
+ llvm::uninitialized_copy(IntExprs, getTrailingObjects<Expr *>());
setExprs(MutableArrayRef(getTrailingObjects<Expr *>(), IntExprs.size()));
- std::uninitialized_copy(GangKinds.begin(), GangKinds.end(),
- getTrailingObjects<OpenACCGangKind>());
+ llvm::uninitialized_copy(GangKinds, getTrailingObjects<OpenACCGangKind>());
}
OpenACCNumWorkersClause *
diff --git a/clang/lib/AST/StmtOpenACC.cpp b/clang/lib/AST/StmtOpenACC.cpp
index c45eca92dc874..268e411cee9c6 100644
--- a/clang/lib/AST/StmtOpenACC.cpp
+++ b/clang/lib/AST/StmtOpenACC.cpp
@@ -61,8 +61,8 @@ OpenACCLoopConstruct::OpenACCLoopConstruct(
assert((Loop == nullptr || isa<ForStmt, CXXForRangeStmt>(Loop)) &&
"Associated Loop not a for loop?");
// Initialize the trailing storage.
- std::uninitialized_copy(Clauses.begin(), Clauses.end(),
- getTrailingObjects<const OpenACCClause *>());
+ llvm::uninitialized_copy(Clauses,
+ getTrailingObjects<const OpenACCClause *>());
setClauseList(MutableArrayRef(getTrailingObjects<const OpenACCClause *>(),
Clauses.size()));
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 59369fba2e772..1806e6c6a91f1 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -3807,13 +3807,13 @@ FunctionProtoType::FunctionProtoType(QualType result, ArrayRef<QualType> params,
ArrayRef<FunctionEffect> SrcFX = epi.FunctionEffects.effects();
auto *DestFX = getTrailingObjects<FunctionEffect>();
- std::uninitialized_copy(SrcFX.begin(), SrcFX.end(), DestFX);
+ llvm::uninitialized_copy(SrcFX, DestFX);
ArrayRef<EffectConditionExpr> SrcConds = epi.FunctionEffects.conditions();
if (!SrcConds.empty()) {
ExtraBits.EffectsHaveConditions = true;
auto *DestConds = getTrailingObjects<EffectConditionExpr>();
- std::uninitialized_copy(SrcConds.begin(), SrcConds.end(), DestConds);
+ llvm::uninitialized_copy(SrcConds, DestConds);
assert(std::any_of(SrcConds.begin(), SrcConds.end(),
[](const EffectConditionExpr &EC) {
if (const Expr *E = EC.getCondition())
@@ -4157,9 +4157,7 @@ PackIndexingType::PackIndexingType(const ASTContext &Context,
computeDependence(Pattern, IndexExpr, Expansions)),
Context(Context), Pattern(Pattern), IndexExpr(IndexExpr),
Size(Expansions.size()), FullySubstituted(FullySubstituted) {
-
- std::uninitialized_copy(Expansions.begin(), Expansions.end(),
- getTrailingObjects<QualType>());
+ llvm::uninitialized_copy(Expansions, getTrailingObjects<QualType>());
}
UnsignedOrNone PackIndexingType::getSelectedIndex() const {
diff --git a/clang/tools/libclang/CXIndexDataConsumer.cpp b/clang/tools/libclang/CXIndexDataConsumer.cpp
index ced94e13baf12..2b2e70d60d1d6 100644
--- a/clang/tools/libclang/CXIndexDataConsumer.cpp
+++ b/clang/tools/libclang/CXIndexDataConsumer.cpp
@@ -15,6 +15,7 @@
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/DeclVisitor.h"
#include "clang/Frontend/ASTUnit.h"
+#include "llvm/ADT/STLExtras.h"
using namespace clang;
using namespace clang::index;
@@ -409,7 +410,7 @@ const char *ScratchAlloc::toCStr(StringRef Str) {
const char *ScratchAlloc::copyCStr(StringRef Str) {
char *buf = IdxCtx.StrScratch.Allocate<char>(Str.size() + 1);
- std::uninitialized_copy(Str.begin(), Str.end(), buf);
+ llvm::uninitialized_copy(Str, buf);
buf[Str.size()] = '\0';
return buf;
}
diff --git a/lldb/source/Utility/Checksum.cpp b/lldb/source/Utility/Checksum.cpp
index 8943b4e128520..5aefddc33e88b 100644
--- a/lldb/source/Utility/Checksum.cpp
+++ b/lldb/source/Utility/Checksum.cpp
@@ -22,8 +22,8 @@ Checksum &Checksum::operator=(const Checksum &checksum) {
}
void Checksum::SetMD5(llvm::MD5::MD5Result md5) {
- const constexpr size_t md5_length = 16;
- std::uninitialized_copy_n(md5.begin(), md5_length, m_checksum.begin());
+ static_assert(sizeof(md5) == 16, "MD5 expected to be 16 bytes/128 bits");
+ llvm::uninitialized_copy(md5, m_checksum.begin());
}
Checksum::operator bool() const { return !llvm::equal(m_checksum, g_sentinel); }
diff --git a/llvm/include/llvm/ADT/ArrayRef.h b/llvm/include/llvm/ADT/ArrayRef.h
index 1f2433b9a7667..4819c88471345 100644
--- a/llvm/include/llvm/ADT/ArrayRef.h
+++ b/llvm/include/llvm/ADT/ArrayRef.h
@@ -190,7 +190,7 @@ namespace llvm {
// copy - Allocate copy in Allocator and return ArrayRef<T> to it.
template <typename Allocator> MutableArrayRef<T> copy(Allocator &A) {
T *Buff = A.template Allocate<T>(Length);
- std::uninitialized_copy(begin(), end(), Buff);
+ llvm::uninitialized_copy(*this, Buff);
return MutableArrayRef<T>(Buff, Length);
}
diff --git a/llvm/include/llvm/ADT/STLExtras.h b/llvm/include/llvm/ADT/STLExtras.h
index dc0443c9244be..a5ac63a8ad923 100644
--- a/llvm/include/llvm/ADT/STLExtras.h
+++ b/llvm/include/llvm/ADT/STLExtras.h
@@ -2038,6 +2038,11 @@ template <typename R1, typename R2> auto mismatch(R1 &&Range1, R2 &&Range2) {
adl_end(Range2));
}
+template <typename R1, typename IterTy>
+auto uninitialized_copy(R1 &&Src, IterTy Dst) {
+ return std::uninitialized_copy(adl_begin(Src), adl_end(Src), Dst);
+}
+
template <typename R>
void stable_sort(R &&Range) {
std::stable_sort(adl_begin(Range), adl_end(Range));
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index 43d200f1153d0..ac69ad598a65a 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -2981,7 +2981,7 @@ ScalarEvolution::getOrCreateAddExpr(ArrayRef<const SCEV *> Ops,
static_cast<SCEVAddExpr *>(UniqueSCEVs.FindNodeOrInsertPos(ID, IP));
if (!S) {
const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
- std::uninitialized_copy(Ops.begin(), Ops.end(), O);
+ llvm::uninitialized_copy(Ops, O);
S = new (SCEVAllocator)
SCEVAddExpr(ID.Intern(SCEVAllocator), O, Ops.size());
UniqueSCEVs.InsertNode(S, IP);
@@ -3004,7 +3004,7 @@ ScalarEvolution::getOrCreateAddRecExpr(ArrayRef<const SCEV *> Ops,
static_cast<SCEVAddRecExpr *>(UniqueSCEVs.FindNodeOrInsertPos(ID, IP));
if (!S) {
const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
- std::uninitialized_copy(Ops.begin(), Ops.end(), O);
+ llvm::uninitialized_copy(Ops, O);
S = new (SCEVAllocator)
SCEVAddRecExpr(ID.Intern(SCEVAllocator), O, Ops.size(), L);
UniqueSCEVs.InsertNode(S, IP);
@@ -3027,7 +3027,7 @@ ScalarEvolution::getOrCreateMulExpr(ArrayRef<const SCEV *> Ops,
static_cast<SCEVMulExpr *>(UniqueSCEVs.FindNodeOrInsertPos(ID, IP));
if (!S) {
const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
- std::uninitialized_copy(Ops.begin(), Ops.end(), O);
+ llvm::uninitialized_copy(Ops, O);
S = new (SCEVAllocator) SCEVMulExpr(ID.Intern(SCEVAllocator),
O, Ops.size());
UniqueSCEVs.InsertNode(S, IP);
@@ -3932,7 +3932,7 @@ const SCEV *ScalarEvolution::getMinMaxExpr(SCEVTypes Kind,
if (ExistingSCEV)
return ExistingSCEV;
const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
- std::uninitialized_copy(Ops.begin(), Ops.end(), O);
+ llvm::uninitialized_copy(Ops, O);
SCEV *S = new (SCEVAllocator)
SCEVMinMaxExpr(ID.Intern(SCEVAllocator), Kind, O, Ops.size());
@@ -4319,7 +4319,7 @@ ScalarEvolution::getSequentialMinMaxExpr(SCEVTypes Kind,
return ExistingSCEV;
const SCEV **O = SCEVAllocator.Allocate<const SCEV *>(Ops.size());
- std::uninitialized_copy(Ops.begin(), Ops.end(), O);
+ llvm::uninitialized_copy(Ops, O);
SCEV *S = new (SCEVAllocator)
SCEVSequentialMinMaxExpr(ID.Intern(SCEVAllocator), Kind, O, Ops.size());
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 0e75c44333af5..e81a2bbfbd0ab 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -542,8 +542,7 @@ class BitcodeConstant final : public Value,
: Value(Ty, SubclassID), Opcode(Info.Opcode), Flags(Info.Flags),
NumOperands(OpIDs.size()), BlockAddressBB(Info.BlockAddressBB),
SrcElemTy(Info.SrcElemTy), InRange(Info.InRange) {
- std::uninitialized_copy(OpIDs.begin(), OpIDs.end(),
- getTrailingObjects<unsigned>());
+ llvm::uninitialized_copy(OpIDs, getTrailingObjects<unsigned>());
}
BitcodeConstant &operator=(const BitcodeConstant &) = delete;
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
index 55a3bfa459c3c..08b58669b3eb3 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -340,8 +340,8 @@ parseV5DirFileTables(const DWARFDataExtractor &DebugLineData,
return createStringError(
errc::invalid_argument,
"failed to parse file entry because the MD5 hash is invalid");
- std::uninitialized_copy_n(Value.getAsBlock()->begin(), 16,
- FileEntry.Checksum.begin());
+ llvm::uninitialized_copy(*Value.getAsBlock(),
+ FileEntry.Checksum.begin());
break;
default:
break;
diff --git a/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp b/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
index ed2d14dd79e45..bb3411bb9568e 100644
--- a/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
+++ b/llvm/lib/DebugInfo/MSF/MSFBuilder.cpp
@@ -286,8 +286,7 @@ Expected<MSFLayout> MSFBuilder::generateLayout() {
SB->NumBlocks = FreeBlocks.size();
ulittle32_t *DirBlocks = Allocator.Allocate<ulittle32_t>(NumDirectoryBlocks);
- std::uninitialized_copy_n(DirectoryBlocks.begin(), NumDirectoryBlocks,
- DirBlocks);
+ llvm::uninitialized_copy(DirectoryBlocks, DirBlocks);
L.DirectoryBlocks = ArrayRef<ulittle32_t>(DirBlocks, NumDirectoryBlocks);
// The stream sizes should be re-allocated as a stable pointer and the stream
@@ -300,8 +299,7 @@ Expected<MSFLayout> MSFBuilder::generateLayout() {
Sizes[I] = StreamData[I].first;
ulittle32_t *BlockList =
Allocator.Allocate<ulittle32_t>(StreamData[I].second.size());
- std::uninitialized_copy_n(StreamData[I].second.begin(),
- StreamData[I].second.size(), BlockList);
+ llvm::uninitialized_copy(StreamData[I].second, BlockList);
L.StreamMap[I] =
ArrayRef<ulittle32_t>(BlockList, StreamData[I].second.size());
}
diff --git a/llvm/lib/IR/AttributeImpl.h b/llvm/lib/IR/AttributeImpl.h
index 59cc489ade40d..98d1bad7680ab 100644
--- a/llvm/lib/IR/AttributeImpl.h
+++ b/llvm/lib/IR/AttributeImpl.h
@@ -258,7 +258,7 @@ class ConstantRangeListAttributeImpl final
: EnumAttributeImpl(ConstantRangeListAttrEntry, Kind), Size(Val.size()) {
assert(Size > 0);
ConstantRange *TrailingCR = getTrailingObjects<ConstantRange>();
- std::uninitialized_copy(Val.begin(), Val.end(), TrailingCR);
+ llvm::uninitialized_copy(Val, TrailingCR);
}
~ConstantRangeListAttributeImpl() {
diff --git a/llvm/lib/ObjectYAML/MinidumpEmitter.cpp b/llvm/lib/ObjectYAML/MinidumpEmitter.cpp
index 44cdfbdd80ea5..b27155162be6b 100644
--- a/llvm/lib/ObjectYAML/MinidumpEmitter.cpp
+++ b/llvm/lib/ObjectYAML/MinidumpEmitter.cpp
@@ -86,7 +86,7 @@ std::pair<size_t, MutableArrayRef<T>>
BlobAllocator::allocateNewArray(const iterator_range<RangeType> &Range) {
size_t Num = std::distance(Range.begin(), Range.end());
MutableArrayRef<T> Array(Temporaries.Allocate<T>(Num), Num);
- std::uninitialized_copy(Range.begin(), Range.end(), Array.begin());
+ llvm::uninitialized_copy(Range, Array.begin());
return {allocateArray(Array), Array};
}
diff --git a/llvm/lib/Support/FoldingSet.cpp b/llvm/lib/Support/FoldingSet.cpp
index 419bf67407684..977e4ca8c26ef 100644
--- a/llvm/lib/Support/FoldingSet.cpp
+++ b/llvm/lib/Support/FoldingSet.cpp
@@ -131,7 +131,7 @@ bool FoldingSetNodeID::operator<(FoldingSetNodeIDRef RHS) const {
FoldingSetNodeIDRef
FoldingSetNodeID::Intern(BumpPtrAllocator &Allocator) const {
unsigned *New = Allocator.Allocate<unsigned>(Bits.size());
- std::uninitialized_copy(Bits.begin(), Bits.end(), New);
+ llvm::uninitialized_copy(Bits, New);
return FoldingSetNodeIDRef(New, Bits.size());
}
@@ -142,7 +142,7 @@ FoldingSetNodeID::Intern(BumpPtrAllocator &Allocator) const {
/// singly-linked-list. In order to make deletion more efficient, we make
/// the list circular, so we can delete a node without computing its hash.
/// The problem with this is that the start of the hash buckets are not
-/// Nodes. If NextInBucketPtr is a bucket pointer, this method returns null:
+/// Nodes. If NextInBucketPtr is a bucket pointer, this method returns null:
/// use GetBucketPtr when this happens.
static FoldingSetBase::Node *GetNextPtr(void *NextInBucketPtr) {
// The low bit is set if this is the pointer back to the bucket.
diff --git a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCExpr.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCExpr.cpp
index 678a7be1f2456..e5601dca17b6a 100644
--- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCExpr.cpp
+++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCExpr.cpp
@@ -36,7 +36,7 @@ AMDGPUMCExpr::AMDGPUMCExpr(VariantKind Kind, ArrayRef<const MCExpr *> Args,
// allocation (e.g., through SmallVector's grow).
RawArgs = static_cast<const MCExpr **>(
Ctx.allocate(sizeof(const MCExpr *) * Args.size()));
- std::uninitialized_copy(Args.begin(), Args.end(), RawArgs);
+ llvm::uninitialized_copy(Args, RawArgs);
this->Args = ArrayRef<const MCExpr *>(RawArgs, Args.size());
}
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index f8205fb542623..8e174286a6f5b 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -297,8 +297,7 @@ class GlobalTypeMember final : TrailingObjects<GlobalTypeMember, MDNode *> {
GTM->NTypes = Types.size();
GTM->IsJumpTableCanonical = IsJumpTableCanonical;
GTM->IsExported = IsExported;
- std::uninitialized_copy(Types.begin(), Types.end(),
- GTM->getTrailingObjects<MDNode *>());
+ llvm::uninitialized_copy(Types, GTM->getTrailingObjects<MDNode *>());
return GTM;
}
@@ -330,8 +329,8 @@ struct ICallBranchFunnel final
Call->CI = CI;
Call->UniqueId = UniqueId;
Call->NTargets = Targets.size();
- std::uninitialized_copy(Targets.begin(), Targets.end(),
- Call->getTrailingObjects<GlobalTypeMember *>());
+ llvm::uninitialized_copy(Targets,
+ Call->getTrailingObjects<GlobalTypeMember *>());
return Call;
}
diff --git a/llvm/unittests/Support/TrailingObjectsTest.cpp b/llvm/unittests/Support/TrailingObjectsTest.cpp
index e2656b2229ca6..a0cae3a156fb2 100644
--- a/llvm/unittests/Support/TrailingObjectsTest.cpp
+++ b/llvm/unittests/Support/TrailingObjectsTest.cpp
@@ -23,15 +23,14 @@ class Class1 final : protected TrailingObjects<Class1, short> {
protected:
size_t numTrailingObjects(OverloadToken<short>) const { return NumShorts; }
- Class1(int *ShortArray, unsigned NumShorts) : NumShorts(NumShorts) {
- std::uninitialized_copy(ShortArray, ShortArray + NumShorts,
- getTrailingObjects<short>());
+ Class1(ArrayRef<int> ShortArray) : NumShorts(ShortArray.size()) {
+ llvm::uninitialized_copy(ShortArray, getTrailingObjects<short>());
}
public:
- static Class1 *create(int *ShortArray, unsigned NumShorts) {
+ static Class1 *create(ArrayRef<int> ShortArray) {
void *Mem = ::operator new(totalSizeToAlloc<short>(NumShorts));
- return new (Mem) Class1(ShortArray, NumShorts);
+ return new (Mem) Class1(ShortArray);
}
void operator delete(void *p) { ::operator delete(p); }
@@ -106,7 +105,7 @@ class Class2 final : protected TrailingObjects<Class2, double, short> {
TEST(TrailingObjects, OneArg) {
int arr[] = {1, 2, 3};
- Class1 *C = Class1::create(arr, 3);
+ Class1 *C = Class1::create(arr);
EXPECT_EQ(sizeof(Class1), sizeof(unsigned));
EXPECT_EQ(Class1::additionalSizeToAlloc<short>(1), sizeof(short));
EXPECT_EQ(Class1::additionalSizeToAlloc<short>(3), sizeof(short) * 3);
diff --git a/mlir/include/mlir/IR/BuiltinAttributes.td b/mlir/include/mlir/IR/BuiltinAttributes.td
index 0169f4b38bbe0..1ff9a8d36cd22 100644
--- a/mlir/include/mlir/IR/BuiltinAttributes.td
+++ b/mlir/include/mlir/IR/BuiltinAttributes.td
@@ -158,7 +158,7 @@ def Builtin_DenseArrayRawDataParameter : ArrayRefParameter<
if (!$_self.empty()) {
auto *alloc = static_cast<char *>(
$_allocator.allocate($_self.size(), alignof(uint64_t)));
- std::uninitialized_copy($_self.begin(), $_self.end(), alloc);
+ llvm::uninitialized_copy($_self, alloc);
$_dst = ArrayRef<char>(alloc, $_self.size());
}
}];
diff --git a/mlir/include/mlir/Support/StorageUniquer.h b/mlir/include/mlir/Support/StorageUniquer.h
index 26bdf09abba21..6756c4390276f 100644
--- a/mlir/include/mlir/Support/StorageUniquer.h
+++ b/mlir/include/mlir/Support/StorageUniquer.h
@@ -99,7 +99,7 @@ class StorageUniquer {
if (elements.empty())
return std::nullopt;
auto result = allocator.Allocate<T>(elements.size());
- std::uninitialized_copy(elements.begin(), elements.end(), result);
+ llvm::uninitialized_copy(elements, result);
return ArrayRef<T>(result, elements.size());
}
@@ -110,7 +110,7 @@ class StorageUniquer {
return StringRef();
char *result = allocator.Allocate<char>(str.size() + 1);
- std::uninitialized_copy(str.begin(), str.end(), result);
+ llvm::uninitialized_copy(str, result);
result[str.size()] = 0;
return StringRef(result, str.size());
}
diff --git a/mlir/lib/Dialect/Affine/Analysis/NestedMatcher.cpp b/mlir/lib/Dialect/Affine/Analysis/NestedMatcher.cpp
index be13a89c7ab4f..c158b98381a82 100644
--- a/mlir/lib/Dialect/Affine/Analysis/NestedMatcher.cpp
+++ b/mlir/lib/Dialect/Affine/Analysis/NestedMatcher.cpp
@@ -28,7 +28,7 @@ NestedMatch NestedMatch::build(Operation *operation,
ArrayRef<NestedMatch> nestedMatches) {
auto *result = allocator()->Allocate<NestedMatch>();
auto *children = allocator()->Allocate<NestedMatch>(nestedMatches.size());
- std::uninitialized_copy(nestedMatches.begin(), nestedMatches.end(), children);
+ llvm::uninitialized_copy(nestedMatches, children);
new (result) NestedMatch();
result->matchedOperation = operation;
result->matchedChildren =
@@ -46,7 +46,7 @@ void NestedPattern::copyNestedToThis(ArrayRef<NestedPattern> nested) {
return;
auto *newNested = allocator()->Allocate<NestedPattern>(nested.size());
- std::uninitialized_copy(nested.begin(), nested.end(), newNested);
+ llvm::uninitialized_copy(nested, newNested);
nestedPatterns = ArrayRef<NestedPattern>(newNested, nested.size());
}
diff --git a/mlir/lib/IR/AffineMapDetail.h b/mlir/lib/IR/AffineMapDetail.h
index 732c7fd1d3a12..32c9734f23a36 100644
--- a/mlir/lib/IR/AffineMapDetail.h
+++ b/mlir/lib/IR/AffineMapDetail.h
@@ -56,8 +56,7 @@ struct AffineMapStorage final
res->numDims = std::get<0>(key);
res->numSymbols = std::get<1>(key);
res->numResults = results.size();
- std::uninitialized_copy(results.begin(), results.end(),
- res->getTrailingObjects<AffineExpr>());
+ llvm::uninitialized_copy(results, res->getTrailingObjects<AffineExpr>());
return res;
}
};
diff --git a/mlir/lib/IR/Location.cpp b/mlir/lib/IR/Location.cpp
index 506a6c1fc16fb..e01dc31cd24e1 100644
--- a/mlir/lib/IR/Location.cpp
+++ b/mlir/lib/IR/Location.cpp
@@ -58,11 +58,11 @@ struct FileLineColRangeAttrStorage final
auto *result = ::new (rawMem) FileLineColRangeAttrStorage(
std::move(std::get<0>(tblgenKey)), locEnc - 1);
if (numInArray > 0) {
- result->startLine = std::get<1>(tblgenKey)[0];
+ ArrayRef<unsigned> elements = std::get<1>(tblgenKey);
+ result->startLine = array[0];
// Copy in the element types into the trailing storage.
- std::uninitialized_copy(std::next(std::get<1>(tblgenKey).begin()),
- std::get<1>(tblgenKey).end(),
- result->getTrailingObjects<unsigned>());
+ llvm::uninitialized_copy(elements.drop_front(),
+ result->getTrailingObjects<unsigned>());
}
return result;
}
diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp
index 87782e84dd6e4..d43dcc5a5e2fd 100644
--- a/mlir/lib/IR/MLIRContext.cpp
+++ b/mlir/lib/IR/MLIRContext.cpp
@@ -362,7 +362,7 @@ template <typename T>
static ArrayRef<T> copyArrayRefInto(llvm::BumpPtrAllocator &allocator,
ArrayRef<T> elements) {
auto result = allocator.Allocate<T>(elements.size());
- std::uninitialized_copy(elements.begin(), elements.end(), result);
+ llvm::uninitialized_copy(elements, result);
return ArrayRef<T>(result, elements.size());
}
diff --git a/mlir/lib/IR/TypeDetail.h b/mlir/lib/IR/TypeDetail.h
index 1d65fccb82b8e..19f3690c3d2dc 100644
--- a/mlir/lib/IR/TypeDetail.h
+++ b/mlir/lib/IR/TypeDetail.h
@@ -116,8 +116,7 @@ struct TupleTypeStorage final
auto *result = ::new (rawMem) TupleTypeStorage(key.size());
// Copy in the element types into the trailing storage.
- std::uninitialized_copy(key.begin(), key.end(),
- result->getTrailingObjects<Type>());
+ llvm::uninitialized_copy(key, result->getTrailingObjects<Type>());
return result;
}
diff --git a/mlir/lib/Tools/PDLL/AST/Nodes.cpp b/mlir/lib/Tools/PDLL/AST/Nodes.cpp
index ee2fe0fb9e3c3..159ce6235662b 100644
--- a/mlir/lib/Tools/PDLL/AST/Nodes.cpp
+++ b/mlir/lib/Tools/PDLL/AST/Nodes.cpp
@@ -195,8 +195,7 @@ CompoundStmt *CompoundStmt::create(Context &ctx, SMRange loc,
void *rawData = ctx.getAllocator().Allocate(allocSize, alignof(CompoundStmt));
CompoundStmt *stmt = new (rawData) CompoundStmt(loc, children.size());
- std::uninitialized_copy(children.begin(), children.end(),
- stmt->getChildren().begin());
+ llvm::uninitialized_copy(children, stmt->getChildren().begin());
return stmt;
}
@@ -230,8 +229,7 @@ ReplaceStmt *ReplaceStmt::create(Context &ctx, SMRange loc, Expr *rootOp,
void *rawData = ctx.getAllocator().Allocate(allocSize, alignof(ReplaceStmt));
ReplaceStmt *stmt = new (rawData) ReplaceStmt(loc, rootOp, replExprs.size());
- std::uninitialized_copy(replExprs.begin(), replExprs.end(),
- stmt->getReplExprs().begin());
+ llvm::uninitialized_copy(replExprs, stmt->getReplExprs().begin());
return stmt;
}
@@ -276,8 +274,7 @@ CallExpr *CallExpr::create(Context &ctx, SMRange loc, Expr *callable,
CallExpr *expr = new (rawData)
CallExpr(loc, resultType, callable, arguments.size(), isNegated);
- std::uninitialized_copy(arguments.begin(), arguments.end(),
- expr->getArguments().begin());
+ llvm::uninitialized_copy(arguments, expr->getArguments().begin());
return expr;
}
@@ -321,12 +318,9 @@ OperationExpr::create(Context &ctx, SMRange loc, const ods::Operation *odsOp,
OperationExpr *opExpr = new (rawData)
OperationExpr(loc, resultType, name, operands.size(), resultTypes.size(),
attributes.size(), name->getLoc());
- std::uninitialized_copy(operands.begin(), operands.end(),
- opExpr->getOperands().begin());
- std::uninitialized_copy(resultTypes.begin(), resultTypes.end(),
- opExpr->getResultTypes().begin());
- std::uninitialized_copy(attributes.begin(), attributes.end(),
- opExpr->getAttributes().begin());
+ llvm::uninitialized_copy(operands, opExpr->getOperands().begin());
+ llvm::uninitialized_copy(resultTypes, opExpr->getResultTypes().begin());
+ llvm::uninitialized_copy(attributes, opExpr->getAttributes().begin());
return opExpr;
}
@@ -344,8 +338,7 @@ RangeExpr *RangeExpr::create(Context &ctx, SMRange loc,
void *rawData = ctx.getAllocator().Allocate(allocSize, alignof(TupleExpr));
RangeExpr *expr = new (rawData) RangeExpr(loc, type, elements.size());
- std::uninitialized_copy(elements.begin(), elements.end(),
- expr->getElements().begin());
+ llvm::uninitialized_copy(elements, expr->getElements().begin());
return expr;
}
@@ -364,8 +357,7 @@ TupleExpr *TupleExpr::create(Context &ctx, SMRange loc,
TupleType type = TupleType::get(ctx, llvm::to_vector(elementTypes), names);
TupleExpr *expr = new (rawData) TupleExpr(loc, type);
- std::uninitialized_copy(elements.begin(), elements.end(),
- expr->getElements().begin());
+ llvm::uninitialized_copy(elements, expr->getElements().begin());
return expr;
}
@@ -482,10 +474,8 @@ UserConstraintDecl *UserConstraintDecl::createImpl(
UserConstraintDecl *decl = new (rawData)
UserConstraintDecl(name, inputs.size(), hasNativeInputTypes,
results.size(), codeBlock, body, resultType);
- std::uninitialized_copy(inputs.begin(), inputs.end(),
- decl->getInputs().begin());
- std::uninitialized_copy(results.begin(), results.end(),
- decl->getResults().begin());
+ llvm::uninitialized_copy(inputs, decl->getInputs().begin());
+ llvm::uninitialized_copy(results, decl->getResults().begin());
if (hasNativeInputTypes) {
StringRef *nativeInputTypesPtr = decl->getTrailingObjects<StringRef>();
for (unsigned i = 0, e = inputs.size(); i < e; ++i)
@@ -547,10 +537,8 @@ UserRewriteDecl *UserRewriteDecl::createImpl(Context &ctx, const Name &name,
UserRewriteDecl *decl = new (rawData) UserRewriteDecl(
name, inputs.size(), results.size(), codeBlock, body, resultType);
- std::uninitialized_copy(inputs.begin(), inputs.end(),
- decl->getInputs().begin());
- std::uninitialized_copy(results.begin(), results.end(),
- decl->getResults().begin());
+ llvm::uninitialized_copy(inputs, decl->getInputs().begin());
+ llvm::uninitialized_copy(results, decl->getResults().begin());
return decl;
}
@@ -567,8 +555,7 @@ VariableDecl *VariableDecl::create(Context &ctx, const Name &name, Type type,
VariableDecl *varDecl =
new (rawData) VariableDecl(name, type, initExpr, constraints.size());
- std::uninitialized_copy(constraints.begin(), constraints.end(),
- varDecl->getConstraints().begin());
+ llvm::uninitialized_copy(constraints, varDecl->getConstraints().begin());
return varDecl;
}
@@ -581,7 +568,6 @@ Module *Module::create(Context &ctx, SMLoc loc, ArrayRef<Decl *> children) {
void *rawData = ctx.getAllocator().Allocate(allocSize, alignof(Module));
Module *module = new (rawData) Module(loc, children.size());
- std::uninitialized_copy(children.begin(), children.end(),
- module->getChildren().begin());
+ llvm::uninitialized_copy(children, module->getChildren().begin());
return module;
}
More information about the cfe-commits
mailing list