[llvm] Use llvm::copy (NFC) (#168182)

Identified with llvm-use-ranges.
This commit is contained in:
Kazu Hirata 2025-11-15 08:06:00 -08:00 committed by GitHub
parent 636e370b8a
commit 7a8237bbb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 22 additions and 26 deletions

View File

@ -185,8 +185,7 @@ private:
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;

View File

@ -100,7 +100,7 @@ public:
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; }

View File

@ -40,7 +40,7 @@ public:
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;
}

View File

@ -69,7 +69,7 @@ private:
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 {

View File

@ -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();

View File

@ -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();
}

View File

@ -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;
}

View File

@ -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);

View File

@ -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) -

View File

@ -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());
}

View File

@ -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);

View File

@ -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';
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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());