Skip to content

Commit c4e9901

Browse files
[llvm] Use llvm::append_range (NFC) (#135931)
1 parent fe94f11 commit c4e9901

File tree

20 files changed

+31
-37
lines changed

20 files changed

+31
-37
lines changed

llvm/include/llvm/IR/ModuleSummaryIndex.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,8 +1319,10 @@ class CfiFunctionIndex {
13191319

13201320
std::vector<StringRef> symbols() const {
13211321
std::vector<StringRef> Symbols;
1322-
for (auto &[GUID, Syms] : Index)
1323-
Symbols.insert(Symbols.end(), Syms.begin(), Syms.end());
1322+
for (auto &[GUID, Syms] : Index) {
1323+
(void)GUID;
1324+
llvm::append_range(Symbols, Syms);
1325+
}
13241326
return Symbols;
13251327
}
13261328

llvm/lib/Analysis/MemoryProfileInfo.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,7 @@ void CallStackTrie::addCallStack(
181181
Curr = New;
182182
}
183183
assert(Curr);
184-
Curr->ContextSizeInfo.insert(Curr->ContextSizeInfo.end(),
185-
ContextSizeInfo.begin(), ContextSizeInfo.end());
184+
llvm::append_range(Curr->ContextSizeInfo, ContextSizeInfo);
186185
}
187186

188187
void CallStackTrie::addCallStack(MDNode *MIB) {
@@ -235,8 +234,7 @@ static MDNode *createMIBNode(LLVMContext &Ctx, ArrayRef<uint64_t> MIBCallStack,
235234

236235
void CallStackTrie::collectContextSizeInfo(
237236
CallStackTrieNode *Node, std::vector<ContextTotalSize> &ContextSizeInfo) {
238-
ContextSizeInfo.insert(ContextSizeInfo.end(), Node->ContextSizeInfo.begin(),
239-
Node->ContextSizeInfo.end());
237+
llvm::append_range(ContextSizeInfo, Node->ContextSizeInfo);
240238
for (auto &Caller : Node->Callers)
241239
collectContextSizeInfo(Caller.second, ContextSizeInfo);
242240
}

llvm/lib/Analysis/ScalarEvolution.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8503,10 +8503,8 @@ void ScalarEvolution::forgetLoop(const Loop *L) {
85038503
}
85048504

85058505
auto LoopUsersItr = LoopUsers.find(CurrL);
8506-
if (LoopUsersItr != LoopUsers.end()) {
8507-
ToForget.insert(ToForget.end(), LoopUsersItr->second.begin(),
8508-
LoopUsersItr->second.end());
8509-
}
8506+
if (LoopUsersItr != LoopUsers.end())
8507+
llvm::append_range(ToForget, LoopUsersItr->second);
85108508

85118509
// Drop information about expressions based on loop-header PHIs.
85128510
PushLoopPHIs(CurrL, Worklist, Visited);

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5098,7 +5098,7 @@ void IndexBitcodeWriter::writeCombinedGlobalValueSummary() {
50985098
return;
50995099
for (GlobalValue::GUID GUID : DefOrUseGUIDs) {
51005100
auto Defs = CfiIndex.forGuid(GUID);
5101-
Functions.insert(Functions.end(), Defs.begin(), Defs.end());
5101+
llvm::append_range(Functions, Defs);
51025102
}
51035103
if (Functions.empty())
51045104
return;

llvm/lib/DebugInfo/GSYM/DwarfTransformer.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -621,9 +621,7 @@ void DwarfTransformer::parseCallSiteInfoFromDwarf(CUInfo &CUI, DWARFDie Die,
621621
if (!FI.CallSites)
622622
FI.CallSites = CallSiteInfoCollection();
623623
// Append parsed DWARF callsites:
624-
FI.CallSites->CallSites.insert(FI.CallSites->CallSites.end(),
625-
CSIC.CallSites.begin(),
626-
CSIC.CallSites.end());
624+
llvm::append_range(FI.CallSites->CallSites, CSIC.CallSites);
627625
}
628626
}
629627

llvm/lib/DebugInfo/LogicalView/Core/LVCompare.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Error LVCompare::execute(LVReader *ReferenceReader, LVReader *TargetReader) {
230230
}
231231
if (Pass == LVComparePass::Added)
232232
// Record all the current missing elements for this category.
233-
Set.insert(Set.end(), Elements.begin(), Elements.end());
233+
llvm::append_range(Set, Elements);
234234
if (options().getReportList()) {
235235
if (Elements.size()) {
236236
OS << "\n(" << Elements.size() << ") "

llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@ static GenericValue lle_X_fprintf(FunctionType *FT,
485485
char Buffer[10000];
486486
std::vector<GenericValue> NewArgs;
487487
NewArgs.push_back(PTOGV(Buffer));
488-
NewArgs.insert(NewArgs.end(), Args.begin()+1, Args.end());
488+
llvm::append_range(NewArgs, llvm::drop_begin(Args));
489489
GenericValue GV = lle_X_sprintf(FT, NewArgs);
490490

491491
fputs(Buffer, (FILE *) GVTOP(Args[0]));

llvm/lib/ExecutionEngine/Orc/Debugging/VTuneSupportPlugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ void VTuneSupportPlugin::notifyTransferringResources(JITDylib &JD,
162162
return;
163163

164164
auto &Dest = LoadedMethodIDs[DstKey];
165-
Dest.insert(Dest.end(), I->second.begin(), I->second.end());
165+
llvm::append_range(Dest, I->second);
166166
LoadedMethodIDs.erase(SrcKey);
167167
}
168168

llvm/lib/ExecutionEngine/Orc/LazyReexports.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ void LazyReexportsManager::handleTransferResources(JITDylib &JD,
323323
} else {
324324
auto &SrcAddrs = I->second;
325325
auto &DstAddrs = J->second;
326-
DstAddrs.insert(DstAddrs.end(), SrcAddrs.begin(), SrcAddrs.end());
326+
llvm::append_range(DstAddrs, SrcAddrs);
327327
KeyToReentryAddrs.erase(I);
328328
}
329329
if (L)
@@ -503,7 +503,7 @@ void SimpleLazyReexportsSpeculator::onLazyReexportsTransfered(
503503
} else {
504504
auto &SrcNames = J->second;
505505
auto &DstNames = K->second;
506-
DstNames.insert(DstNames.end(), SrcNames.begin(), SrcNames.end());
506+
llvm::append_range(DstNames, SrcNames);
507507
MapForJD.erase(J);
508508
}
509509
}

llvm/lib/IR/DebugInfoMetadata.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,7 @@ DIExpression *DIExpression::appendOpsToArg(const DIExpression *Expr,
19901990
}
19911991
Op.appendToVector(NewOps);
19921992
if (Op.getOp() == dwarf::DW_OP_LLVM_arg && Op.getArg(0) == ArgNo)
1993-
NewOps.insert(NewOps.end(), Ops.begin(), Ops.end());
1993+
llvm::append_range(NewOps, Ops);
19941994
}
19951995
if (StackValue)
19961996
NewOps.push_back(dwarf::DW_OP_stack_value);

llvm/lib/MC/DXContainerPSVInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ ProcessElementList(StringTableBuilder &StrTabBuilder,
5858
size_t Idx = FindSequence(IndexBuffer, El.Indices);
5959
if (Idx == npos) {
6060
FinalElement.IndicesOffset = static_cast<uint32_t>(IndexBuffer.size());
61-
IndexBuffer.insert(IndexBuffer.end(), El.Indices.begin(),
62-
El.Indices.end());
61+
llvm::append_range(IndexBuffer, El.Indices);
6362
} else
6463
FinalElement.IndicesOffset = static_cast<uint32_t>(Idx);
6564
FinalElements.push_back(FinalElement);

llvm/lib/MC/MCParser/MasmParser.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3647,9 +3647,8 @@ bool MasmParser::parseFieldInitializer(const FieldInfo &Field,
36473647
std::to_string(Initializers.size()));
36483648
}
36493649
// Default-initialize all remaining values.
3650-
Initializers.insert(Initializers.end(),
3651-
Contents.Initializers.begin() + Initializers.size(),
3652-
Contents.Initializers.end());
3650+
llvm::append_range(Initializers, llvm::drop_begin(Contents.Initializers,
3651+
Initializers.size()));
36533652

36543653
Initializer = FieldInitializer(std::move(Initializers), Contents.Structure);
36553654
return false;

llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -662,13 +662,13 @@ RemoveNoteDetail::updateData(ArrayRef<uint8_t> OldData,
662662
for (const DeletedRange &RemRange : ToRemove) {
663663
if (CurPos < RemRange.OldFrom) {
664664
auto Slice = OldData.slice(CurPos, RemRange.OldFrom - CurPos);
665-
NewData.insert(NewData.end(), Slice.begin(), Slice.end());
665+
llvm::append_range(NewData, Slice);
666666
}
667667
CurPos = RemRange.OldTo;
668668
}
669669
if (CurPos < OldData.size()) {
670670
auto Slice = OldData.slice(CurPos);
671-
NewData.insert(NewData.end(), Slice.begin(), Slice.end());
671+
llvm::append_range(NewData, Slice);
672672
}
673673
return NewData;
674674
}

llvm/lib/ProfileData/InstrProfReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,7 @@ class llvm::InstrProfReaderItaniumRemapper
10961096
SmallVectorImpl<char> &Out) {
10971097
Out.reserve(OrigName.size() + Replacement.size() - ExtractedName.size());
10981098
Out.insert(Out.end(), OrigName.begin(), ExtractedName.begin());
1099-
Out.insert(Out.end(), Replacement.begin(), Replacement.end());
1099+
llvm::append_range(Out, Replacement);
11001100
Out.insert(Out.end(), ExtractedName.end(), OrigName.end());
11011101
}
11021102

llvm/lib/TargetParser/SubtargetFeature.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ void SubtargetFeatures::AddFeature(StringRef String, bool Enable) {
4343

4444
void SubtargetFeatures::addFeaturesVector(
4545
const ArrayRef<std::string> OtherFeatures) {
46-
Features.insert(Features.cend(), OtherFeatures.begin(), OtherFeatures.end());
46+
llvm::append_range(Features, OtherFeatures);
4747
}
4848

4949
SubtargetFeatures::SubtargetFeatures(StringRef Initial) {

llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,15 @@ void dwarfgen::LineTable::addByte(uint8_t Value) {
243243
void dwarfgen::LineTable::addStandardOpcode(uint8_t Opcode,
244244
ArrayRef<ValueAndLength> Operands) {
245245
Contents.push_back({Opcode, Byte});
246-
Contents.insert(Contents.end(), Operands.begin(), Operands.end());
246+
llvm::append_range(Contents, Operands);
247247
}
248248

249249
void dwarfgen::LineTable::addExtendedOpcode(uint64_t Length, uint8_t Opcode,
250250
ArrayRef<ValueAndLength> Operands) {
251251
Contents.push_back({0, Byte});
252252
Contents.push_back({Length, ULEB});
253253
Contents.push_back({Opcode, Byte});
254-
Contents.insert(Contents.end(), Operands.begin(), Operands.end());
254+
llvm::append_range(Contents, Operands);
255255
}
256256

257257
void dwarfgen::LineTable::generate(MCContext &MC, AsmPrinter &Asm) const {

llvm/unittests/DebugInfo/PDB/HashTableTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ struct FooBarHashTraits {
233233

234234
uint32_t lookupKeyToStorageKey(StringRef S) {
235235
uint32_t N = Buffer.size();
236-
Buffer.insert(Buffer.end(), S.begin(), S.end());
236+
llvm::append_range(Buffer, S);
237237
Buffer.push_back('\0');
238238
return N;
239239
}

llvm/unittests/Transforms/IPO/LowerTypeTests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ TEST(LowerTypeTests, GlobalLayoutBuilder) {
100100

101101
std::vector<uint64_t> ComputedLayout;
102102
for (auto &&F : GLB.Fragments)
103-
ComputedLayout.insert(ComputedLayout.end(), F.begin(), F.end());
103+
llvm::append_range(ComputedLayout, F);
104104

105105
EXPECT_EQ(T.WantLayout, ComputedLayout);
106106
}

llvm/utils/TableGen/Common/CodeGenRegisters.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ struct TupleExpander : SetTheory::Expander {
678678
// Take the cost list of the first register in the tuple.
679679
const ListInit *CostList = Proto->getValueAsListInit("CostPerUse");
680680
SmallVector<const Init *, 2> CostPerUse;
681-
CostPerUse.insert(CostPerUse.end(), CostList->begin(), CostList->end());
681+
llvm::append_range(CostPerUse, *CostList);
682682

683683
const StringInit *AsmName = StringInit::get(RK, "");
684684
if (!RegNames.empty()) {
@@ -1186,7 +1186,7 @@ void CodeGenRegisterClass::extendSuperRegClasses(CodeGenSubRegIndex *SubIdx) {
11861186
return;
11871187

11881188
SmallVector<CodeGenRegisterClass *> MidRCs;
1189-
MidRCs.insert(MidRCs.end(), It->second.begin(), It->second.end());
1189+
llvm::append_range(MidRCs, It->second);
11901190

11911191
for (CodeGenRegisterClass *MidRC : MidRCs) {
11921192
for (auto &Pair : MidRC->SuperRegClasses) {
@@ -1244,7 +1244,7 @@ CodeGenRegBank::CodeGenRegBank(const RecordKeeper &Records,
12441244
for (const Record *R : Records.getAllDerivedDefinitions("RegisterTuples")) {
12451245
// Expand tuples and merge the vectors
12461246
std::vector<const Record *> TupRegs = *Sets.expand(R);
1247-
Regs.insert(Regs.end(), TupRegs.begin(), TupRegs.end());
1247+
llvm::append_range(Regs, TupRegs);
12481248
}
12491249

12501250
llvm::sort(Regs, LessRecordRegister());

llvm/utils/TableGen/RegisterInfoEmitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ void RegisterInfoEmitter::runTargetDesc(raw_ostream &OS) {
14871487
// each register. Fill with zero for values which are not explicitly given.
14881488
for (const auto &Reg : Regs) {
14891489
auto Costs = Reg.CostPerUse;
1490-
AllRegCostPerUse.insert(AllRegCostPerUse.end(), Costs.begin(), Costs.end());
1490+
llvm::append_range(AllRegCostPerUse, Costs);
14911491
if (NumRegCosts > Costs.size())
14921492
AllRegCostPerUse.insert(AllRegCostPerUse.end(),
14931493
NumRegCosts - Costs.size(), 0);

0 commit comments

Comments
 (0)