-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[llvm] Use llvm::copy (NFC) #168182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_20251114_clang_tidy_llvm-use-ranges
Nov 15, 2025
Merged
[llvm] Use llvm::copy (NFC) #168182
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_20251114_clang_tidy_llvm-use-ranges
Nov 15, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Identified with llvm-use-ranges.
Member
|
@llvm/pr-subscribers-llvm-ir @llvm/pr-subscribers-backend-hexagon Author: Kazu Hirata (kazutakahirata) ChangesIdentified with llvm-use-ranges. Full diff: https://github.com/llvm/llvm-project/pull/168182.diff 15 Files Affected:
diff --git a/llvm/include/llvm/CodeGen/MachineInstr.h b/llvm/include/llvm/CodeGen/MachineInstr.h
index 4fcb7f36e0238..ca984459c365a 100644
--- a/llvm/include/llvm/CodeGen/MachineInstr.h
+++ b/llvm/include/llvm/CodeGen/MachineInstr.h
@@ -185,8 +185,7 @@ class MachineInstr
HasHeapAllocMarker, HasPCSections, HasCFIType, HasMMRAs);
// Copy the actual data into the trailing objects.
- std::copy(MMOs.begin(), MMOs.end(),
- Result->getTrailingObjects<MachineMemOperand *>());
+ llvm::copy(MMOs, Result->getTrailingObjects<MachineMemOperand *>());
unsigned MDNodeIdx = 0;
diff --git a/llvm/include/llvm/CodeGen/RegAllocPBQP.h b/llvm/include/llvm/CodeGen/RegAllocPBQP.h
index 234f1c6ff115a..625c40ed8f8d2 100644
--- a/llvm/include/llvm/CodeGen/RegAllocPBQP.h
+++ b/llvm/include/llvm/CodeGen/RegAllocPBQP.h
@@ -100,7 +100,7 @@ class AllowedRegVector {
AllowedRegVector(const std::vector<MCRegister> &OptVec)
: NumOpts(OptVec.size()), Opts(new MCRegister[NumOpts]) {
- std::copy(OptVec.begin(), OptVec.end(), Opts.get());
+ llvm::copy(OptVec, Opts.get());
}
unsigned size() const { return NumOpts; }
diff --git a/llvm/include/llvm/IR/PredIteratorCache.h b/llvm/include/llvm/IR/PredIteratorCache.h
index ba3228347076b..96f546011b3a3 100644
--- a/llvm/include/llvm/IR/PredIteratorCache.h
+++ b/llvm/include/llvm/IR/PredIteratorCache.h
@@ -40,7 +40,7 @@ class PredIteratorCache {
SmallVector<BasicBlock *, 32> PredCache(predecessors(BB));
BasicBlock **Data = Memory.Allocate<BasicBlock *>(PredCache.size());
- std::copy(PredCache.begin(), PredCache.end(), Data);
+ llvm::copy(PredCache, Data);
Entry = ArrayRef(Data, PredCache.size());
return Entry;
}
diff --git a/llvm/lib/ObjCopy/COFF/COFFObject.h b/llvm/lib/ObjCopy/COFF/COFFObject.h
index 6b70add1bb1b7..1c04b7f64f3a0 100644
--- a/llvm/lib/ObjCopy/COFF/COFFObject.h
+++ b/llvm/lib/ObjCopy/COFF/COFFObject.h
@@ -69,7 +69,7 @@ struct Section {
struct AuxSymbol {
AuxSymbol(ArrayRef<uint8_t> In) {
assert(In.size() == sizeof(Opaque));
- std::copy(In.begin(), In.end(), Opaque);
+ llvm::copy(In, Opaque);
}
ArrayRef<uint8_t> getRef() const {
diff --git a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
index f810bbf639300..edb6ae0a5b108 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp
@@ -198,8 +198,7 @@ static Error dumpSectionToFile(StringRef SecName, StringRef Filename,
if (!BufferOrErr)
return createFileError(Filename, BufferOrErr.takeError());
std::unique_ptr<FileOutputBuffer> Buf = std::move(*BufferOrErr);
- std::copy(Sec.OriginalData.begin(), Sec.OriginalData.end(),
- Buf->getBufferStart());
+ llvm::copy(Sec.OriginalData, Buf->getBufferStart());
if (Error E = Buf->commit())
return createFileError(Filename, std::move(E));
return Error::success();
diff --git a/llvm/lib/ObjCopy/ELF/ELFObject.cpp b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
index 78b674c5fa348..641966a867102 100644
--- a/llvm/lib/ObjCopy/ELF/ELFObject.cpp
+++ b/llvm/lib/ObjCopy/ELF/ELFObject.cpp
@@ -536,7 +536,7 @@ Error ELFSectionWriter<ELFT>::visit(const CompressedSection &Sec) {
Elf_Chdr_Impl<ELFT> Chdr = {};
switch (Sec.CompressionType) {
case DebugCompressionType::None:
- std::copy(Sec.OriginalData.begin(), Sec.OriginalData.end(), Buf);
+ llvm::copy(Sec.OriginalData, Buf);
return Error::success();
case DebugCompressionType::Zlib:
Chdr.ch_type = ELF::ELFCOMPRESS_ZLIB;
@@ -550,7 +550,7 @@ Error ELFSectionWriter<ELFT>::visit(const CompressedSection &Sec) {
memcpy(Buf, &Chdr, sizeof(Chdr));
Buf += sizeof(Chdr);
- std::copy(Sec.CompressedData.begin(), Sec.CompressedData.end(), Buf);
+ llvm::copy(Sec.CompressedData, Buf);
return Error::success();
}
diff --git a/llvm/lib/Object/COFFImportFile.cpp b/llvm/lib/Object/COFFImportFile.cpp
index 595533ff94725..5ef5ea310766f 100644
--- a/llvm/lib/Object/COFFImportFile.cpp
+++ b/llvm/lib/Object/COFFImportFile.cpp
@@ -161,7 +161,7 @@ static void writeStringTable(std::vector<uint8_t> &B,
for (const auto &S : Strings) {
B.resize(Pos + S.length() + 1);
- std::copy(S.begin(), S.end(), std::next(B.begin(), Pos));
+ llvm::copy(S, std::next(B.begin(), Pos));
B[Pos + S.length()] = 0;
Pos += S.length() + 1;
}
diff --git a/llvm/lib/ObjectYAML/COFFEmitter.cpp b/llvm/lib/ObjectYAML/COFFEmitter.cpp
index b21197105cbde..8ba9e44c15385 100644
--- a/llvm/lib/ObjectYAML/COFFEmitter.cpp
+++ b/llvm/lib/ObjectYAML/COFFEmitter.cpp
@@ -99,7 +99,7 @@ struct COFFParser {
// store it in the string table.
StringRef Name = Sym.Name;
if (Name.size() <= COFF::NameSize) {
- std::copy(Name.begin(), Name.end(), Sym.Header.Name);
+ llvm::copy(Name, Sym.Header.Name);
} else {
// Add string to the string table and format the index for output.
unsigned Index = getStringIndex(Name);
diff --git a/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp b/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
index 075ad8d7aec8b..8ce0e9f62666c 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
@@ -1232,8 +1232,7 @@ loadBinaryFormat(std::unique_ptr<Binary> Bin, StringRef Arch,
if (!CoverageRecordsOrErr)
return CoverageRecordsOrErr.takeError();
const auto &CoverageRecords = CoverageRecordsOrErr.get();
- FuncRecordsBuffer = std::copy(CoverageRecords.begin(),
- CoverageRecords.end(), FuncRecordsBuffer);
+ FuncRecordsBuffer = llvm::copy(CoverageRecords, FuncRecordsBuffer);
FuncRecordsBuffer =
std::fill_n(FuncRecordsBuffer,
alignAddr(FuncRecordsBuffer, RecordAlignment) -
diff --git a/llvm/lib/Support/Mustache.cpp b/llvm/lib/Support/Mustache.cpp
index 8b95049eb9648..f27a647b9c67d 100644
--- a/llvm/lib/Support/Mustache.cpp
+++ b/llvm/lib/Support/Mustache.cpp
@@ -75,7 +75,7 @@ static Accessor splitMustacheString(StringRef Str, MustacheContext &Ctx) {
// Now, allocate memory for the array of StringRefs in the arena.
StringRef *ArenaTokens = Ctx.Allocator.Allocate<StringRef>(Tokens.size());
// Copy the StringRefs from the stack vector to the arena.
- std::copy(Tokens.begin(), Tokens.end(), ArenaTokens);
+ llvm::copy(Tokens, ArenaTokens);
// Return an ArrayRef pointing to the stable arena memory.
return ArrayRef<StringRef>(ArenaTokens, Tokens.size());
}
diff --git a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
index 3cc146b13f8f8..728ffefe5bd9e 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
@@ -811,8 +811,8 @@ ArrayRef<int> hi(ArrayRef<int> Vuu) { return Vuu.take_back(Vuu.size() / 2); }
MaskT vshuffvdd(ArrayRef<int> Vu, ArrayRef<int> Vv, unsigned Rt) {
int Len = Vu.size();
MaskT Vdd(2 * Len);
- std::copy(Vv.begin(), Vv.end(), Vdd.begin());
- std::copy(Vu.begin(), Vu.end(), Vdd.begin() + Len);
+ llvm::copy(Vv, Vdd.begin());
+ llvm::copy(Vu, Vdd.begin() + Len);
auto Vd0 = MutableArrayRef<int>(Vdd).take_front(Len);
auto Vd1 = MutableArrayRef<int>(Vdd).take_back(Len);
@@ -831,8 +831,8 @@ MaskT vshuffvdd(ArrayRef<int> Vu, ArrayRef<int> Vv, unsigned Rt) {
MaskT vdealvdd(ArrayRef<int> Vu, ArrayRef<int> Vv, unsigned Rt) {
int Len = Vu.size();
MaskT Vdd(2 * Len);
- std::copy(Vv.begin(), Vv.end(), Vdd.begin());
- std::copy(Vu.begin(), Vu.end(), Vdd.begin() + Len);
+ llvm::copy(Vv, Vdd.begin());
+ llvm::copy(Vu, Vdd.begin() + Len);
auto Vd0 = MutableArrayRef<int>(Vdd).take_front(Len);
auto Vd1 = MutableArrayRef<int>(Vdd).take_back(Len);
diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index 017e2102348b7..f1cf87fc88cee 100644
--- a/llvm/tools/lli/lli.cpp
+++ b/llvm/tools/lli/lli.cpp
@@ -1228,15 +1228,15 @@ static Expected<std::unique_ptr<orc::ExecutorProcessControl>> launchRemote() {
std::unique_ptr<char[]> ChildPath, ChildIn, ChildOut;
{
ChildPath.reset(new char[ChildExecPath.size() + 1]);
- std::copy(ChildExecPath.begin(), ChildExecPath.end(), &ChildPath[0]);
+ llvm::copy(ChildExecPath, &ChildPath[0]);
ChildPath[ChildExecPath.size()] = '\0';
std::string ChildInStr = utostr(PipeFD[0][0]);
ChildIn.reset(new char[ChildInStr.size() + 1]);
- std::copy(ChildInStr.begin(), ChildInStr.end(), &ChildIn[0]);
+ llvm::copy(ChildInStr, &ChildIn[0]);
ChildIn[ChildInStr.size()] = '\0';
std::string ChildOutStr = utostr(PipeFD[1][1]);
ChildOut.reset(new char[ChildOutStr.size() + 1]);
- std::copy(ChildOutStr.begin(), ChildOutStr.end(), &ChildOut[0]);
+ llvm::copy(ChildOutStr, &ChildOut[0]);
ChildOut[ChildOutStr.size()] = '\0';
}
diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp
index 73115fbb7e55e..55e106d8ea6ac 100644
--- a/llvm/tools/llvm-readobj/COFFDumper.cpp
+++ b/llvm/tools/llvm-readobj/COFFDumper.cpp
@@ -2330,8 +2330,7 @@ void COFFDumper::printResourceDirectoryTable(
std::vector<UTF16> EndianCorrectedNameString;
if (llvm::sys::IsBigEndianHost) {
EndianCorrectedNameString.resize(RawEntryNameString.size() + 1);
- std::copy(RawEntryNameString.begin(), RawEntryNameString.end(),
- EndianCorrectedNameString.begin() + 1);
+ llvm::copy(RawEntryNameString, EndianCorrectedNameString.begin() + 1);
EndianCorrectedNameString[0] = UNI_UTF16_BYTE_ORDER_MARK_SWAPPED;
RawEntryNameString = ArrayRef(EndianCorrectedNameString);
}
diff --git a/llvm/unittests/Object/ELFTypesTest.cpp b/llvm/unittests/Object/ELFTypesTest.cpp
index 9e99b4a6d7bf3..1c00c9f3c55bd 100644
--- a/llvm/unittests/Object/ELFTypesTest.cpp
+++ b/llvm/unittests/Object/ELFTypesTest.cpp
@@ -32,7 +32,7 @@ template <class ELFT> struct NoteTestData {
Nhdr->n_type = Type;
auto NameOffset = Data.begin() + sizeof(*Nhdr);
- std::copy(Name.begin(), Name.end(), NameOffset);
+ llvm::copy(Name, NameOffset);
auto DescOffset =
Data.begin() + alignTo(sizeof(*Nhdr) + Nhdr->n_namesz, Align);
diff --git a/llvm/unittests/Support/Path.cpp b/llvm/unittests/Support/Path.cpp
index eb649defc0021..51f65bf6824ec 100644
--- a/llvm/unittests/Support/Path.cpp
+++ b/llvm/unittests/Support/Path.cpp
@@ -1428,7 +1428,7 @@ TEST_F(FileSystemTest, FileMapping) {
fs::mapped_file_region mfr(fs::convertFDToNativeFile(FileDescriptor),
fs::mapped_file_region::readwrite, Size, 0, EC);
ASSERT_NO_ERROR(EC);
- std::copy(Val.begin(), Val.end(), mfr.data());
+ llvm::copy(Val, mfr.data());
// Explicitly add a 0.
mfr.data()[Val.size()] = 0;
@@ -1494,7 +1494,7 @@ TEST_F(FileSystemTest, FileMappingSync) {
// Write content through mapped memory.
ASSERT_NO_ERROR(EC);
- std::copy(Content.begin(), Content.end(), MFR.data());
+ llvm::copy(Content, MFR.data());
// Synchronize to file system.
ASSERT_FALSE((bool)MFR.sync());
|
kuhar
approved these changes
Nov 15, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backend:Hexagon
llvm:binary-utilities
llvm:ir
llvm:support
objectyaml
PGO
Profile Guided Optimizations
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Identified with llvm-use-ranges.