Skip to content

Commit c2d6c7c

Browse files
[clang] Use llvm::append_range (NFC) (llvm#136448)
1 parent 0314755 commit c2d6c7c

File tree

18 files changed

+31
-56
lines changed

18 files changed

+31
-56
lines changed

clang/lib/AST/ByteCode/State.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,8 @@ OptionalDiagnostic State::Note(SourceLocation Loc, diag::kind DiagId) {
6767
}
6868

6969
void State::addNotes(ArrayRef<PartialDiagnosticAt> Diags) {
70-
if (hasActiveDiagnostic()) {
71-
getEvalStatus().Diag->insert(getEvalStatus().Diag->end(), Diags.begin(),
72-
Diags.end());
73-
}
70+
if (hasActiveDiagnostic())
71+
llvm::append_range(*getEvalStatus().Diag, Diags);
7472
}
7573

7674
DiagnosticBuilder State::report(SourceLocation Loc, diag::kind DiagId) {

clang/lib/AST/ExprConstant.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,7 @@ namespace {
298298
assert(V.isLValue() && "Non-LValue used to make an LValue designator?");
299299
if (!Invalid) {
300300
IsOnePastTheEnd = V.isLValueOnePastTheEnd();
301-
ArrayRef<PathEntry> VEntries = V.getLValuePath();
302-
Entries.insert(Entries.end(), VEntries.begin(), VEntries.end());
301+
llvm::append_range(Entries, V.getLValuePath());
303302
if (V.getLValueBase()) {
304303
bool IsArray = false;
305304
bool FirstIsUnsizedArray = false;
@@ -1832,8 +1831,7 @@ namespace {
18321831
DeclAndIsDerivedMember.setPointer(V.getMemberPointerDecl());
18331832
DeclAndIsDerivedMember.setInt(V.isMemberPointerToDerivedMember());
18341833
Path.clear();
1835-
ArrayRef<const CXXRecordDecl*> P = V.getMemberPointerPath();
1836-
Path.insert(Path.end(), P.begin(), P.end());
1834+
llvm::append_range(Path, V.getMemberPointerPath());
18371835
}
18381836

18391837
/// DeclAndIsDerivedMember - The member declaration, and a flag indicating

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -309,28 +309,22 @@ class CXXNameMangler {
309309
!AdditionalAbiTags &&
310310
"only function and variables need a list of additional abi tags");
311311
if (const auto *NS = dyn_cast<NamespaceDecl>(ND)) {
312-
if (const auto *AbiTag = NS->getAttr<AbiTagAttr>()) {
313-
UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
314-
AbiTag->tags().end());
315-
}
312+
if (const auto *AbiTag = NS->getAttr<AbiTagAttr>())
313+
llvm::append_range(UsedAbiTags, AbiTag->tags());
316314
// Don't emit abi tags for namespaces.
317315
return;
318316
}
319317
}
320318

321319
AbiTagList TagList;
322320
if (const auto *AbiTag = ND->getAttr<AbiTagAttr>()) {
323-
UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
324-
AbiTag->tags().end());
325-
TagList.insert(TagList.end(), AbiTag->tags().begin(),
326-
AbiTag->tags().end());
321+
llvm::append_range(UsedAbiTags, AbiTag->tags());
322+
llvm::append_range(TagList, AbiTag->tags());
327323
}
328324

329325
if (AdditionalAbiTags) {
330-
UsedAbiTags.insert(UsedAbiTags.end(), AdditionalAbiTags->begin(),
331-
AdditionalAbiTags->end());
332-
TagList.insert(TagList.end(), AdditionalAbiTags->begin(),
333-
AdditionalAbiTags->end());
326+
llvm::append_range(UsedAbiTags, *AdditionalAbiTags);
327+
llvm::append_range(TagList, *AdditionalAbiTags);
334328
}
335329

336330
llvm::sort(TagList);

clang/lib/AST/Randstruct.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,10 @@ bool randomizeStructureLayout(const ASTContext &Context, RecordDecl *RD,
208208
randomizeStructureLayoutImpl(Context, RandomizedFields, RNG);
209209

210210
// Plorp the randomized decls into the final ordering.
211-
FinalOrdering.insert(FinalOrdering.end(), RandomizedFields.begin(),
212-
RandomizedFields.end());
211+
llvm::append_range(FinalOrdering, RandomizedFields);
213212

214213
// Add fields that belong towards the end of the RecordDecl.
215-
FinalOrdering.insert(FinalOrdering.end(), PostRandomizedFields.begin(),
216-
PostRandomizedFields.end());
214+
llvm::append_range(FinalOrdering, PostRandomizedFields);
217215

218216
// Add back the flexible array.
219217
if (FlexibleArray)

clang/lib/Analysis/IntervalPartition.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ static void fillIntervalNode(CFGIntervalGraph &Graph,
132132
Count += N->Nodes.size();
133133
Nodes.reserve(Count);
134134
for (auto &N : Result.Nodes)
135-
Nodes.insert(Nodes.end(), N->Nodes.begin(), N->Nodes.end());
135+
llvm::append_range(Nodes, N->Nodes);
136136
Interval.Nodes = std::move(Nodes);
137137
}
138138
}

clang/lib/CodeGen/CGCall.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,9 @@ class CallArgList : public SmallVector<CallArg, 8> {
312312
/// this, the old CallArgList retains its list of arguments, but must not
313313
/// be used to emit a call.
314314
void addFrom(const CallArgList &other) {
315-
insert(end(), other.begin(), other.end());
316-
Writebacks.insert(Writebacks.end(), other.Writebacks.begin(),
317-
other.Writebacks.end());
318-
CleanupsToDeactivate.insert(CleanupsToDeactivate.end(),
319-
other.CleanupsToDeactivate.begin(),
320-
other.CleanupsToDeactivate.end());
315+
llvm::append_range(*this, other);
316+
llvm::append_range(Writebacks, other.Writebacks);
317+
llvm::append_range(CleanupsToDeactivate, other.CleanupsToDeactivate);
321318
assert(!(StackBase && other.StackBase) && "can't merge stackbases");
322319
if (!StackBase)
323320
StackBase = other.StackBase;

clang/lib/CodeGen/CGLoopInfo.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,8 +424,7 @@ SmallVector<Metadata *, 4> LoopInfo::createMetadata(
424424
LoopProperties.push_back(MDNode::get(Ctx, Vals));
425425
}
426426

427-
LoopProperties.insert(LoopProperties.end(), AdditionalLoopProperties.begin(),
428-
AdditionalLoopProperties.end());
427+
llvm::append_range(LoopProperties, AdditionalLoopProperties);
429428
return createFullUnrollMetadata(Attrs, LoopProperties, HasUserTransforms);
430429
}
431430

clang/lib/Driver/MultilibBuilder.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ static MultilibBuilder compose(const MultilibBuilder &Base,
142142

143143
MultilibBuilder::flags_list &Flags = Composed.flags();
144144

145-
Flags.insert(Flags.end(), Base.flags().begin(), Base.flags().end());
146-
Flags.insert(Flags.end(), New.flags().begin(), New.flags().end());
145+
llvm::append_range(Flags, Base.flags());
146+
llvm::append_range(Flags, New.flags());
147147

148148
return Composed;
149149
}
@@ -153,8 +153,7 @@ MultilibSetBuilder::Either(ArrayRef<MultilibBuilder> MultilibSegments) {
153153
multilib_list Composed;
154154

155155
if (Multilibs.empty())
156-
Multilibs.insert(Multilibs.end(), MultilibSegments.begin(),
157-
MultilibSegments.end());
156+
llvm::append_range(Multilibs, MultilibSegments);
158157
else {
159158
for (const auto &New : MultilibSegments) {
160159
for (const auto &Base : Multilibs) {

clang/lib/Driver/ToolChains/HIPUtility.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ class HIPUndefinedFatBinSymbols {
190190

191191
processInput(BufferOrErr.get()->getMemBufferRef());
192192
} else
193-
WorkList.insert(WorkList.end(), CurrentAction->getInputs().begin(),
194-
CurrentAction->getInputs().end());
193+
llvm::append_range(WorkList, CurrentAction->getInputs());
195194
}
196195
}
197196

clang/lib/Format/SortJavaScriptImports.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,7 @@ class JavaScriptImportSorter : public TokenAnalyzer {
276276
}
277277
stable_sort(SortChunk);
278278
mergeModuleReferences(SortChunk);
279-
ReferencesSorted.insert(ReferencesSorted.end(), SortChunk.begin(),
280-
SortChunk.end());
279+
llvm::append_range(ReferencesSorted, SortChunk);
281280
}
282281
return ReferencesSorted;
283282
}

0 commit comments

Comments
 (0)