Skip to content

[clang] Use llvm::append_range (NFC) #136448

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions clang/lib/AST/ByteCode/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ OptionalDiagnostic State::Note(SourceLocation Loc, diag::kind DiagId) {
}

void State::addNotes(ArrayRef<PartialDiagnosticAt> Diags) {
if (hasActiveDiagnostic()) {
getEvalStatus().Diag->insert(getEvalStatus().Diag->end(), Diags.begin(),
Diags.end());
}
if (hasActiveDiagnostic())
llvm::append_range(*getEvalStatus().Diag, Diags);
}

DiagnosticBuilder State::report(SourceLocation Loc, diag::kind DiagId) {
Expand Down
6 changes: 2 additions & 4 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,7 @@ namespace {
assert(V.isLValue() && "Non-LValue used to make an LValue designator?");
if (!Invalid) {
IsOnePastTheEnd = V.isLValueOnePastTheEnd();
ArrayRef<PathEntry> VEntries = V.getLValuePath();
Entries.insert(Entries.end(), VEntries.begin(), VEntries.end());
llvm::append_range(Entries, V.getLValuePath());
if (V.getLValueBase()) {
bool IsArray = false;
bool FirstIsUnsizedArray = false;
Expand Down Expand Up @@ -1832,8 +1831,7 @@ namespace {
DeclAndIsDerivedMember.setPointer(V.getMemberPointerDecl());
DeclAndIsDerivedMember.setInt(V.isMemberPointerToDerivedMember());
Path.clear();
ArrayRef<const CXXRecordDecl*> P = V.getMemberPointerPath();
Path.insert(Path.end(), P.begin(), P.end());
llvm::append_range(Path, V.getMemberPointerPath());
}

/// DeclAndIsDerivedMember - The member declaration, and a flag indicating
Expand Down
18 changes: 6 additions & 12 deletions clang/lib/AST/ItaniumMangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,28 +309,22 @@ class CXXNameMangler {
!AdditionalAbiTags &&
"only function and variables need a list of additional abi tags");
if (const auto *NS = dyn_cast<NamespaceDecl>(ND)) {
if (const auto *AbiTag = NS->getAttr<AbiTagAttr>()) {
UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
AbiTag->tags().end());
}
if (const auto *AbiTag = NS->getAttr<AbiTagAttr>())
llvm::append_range(UsedAbiTags, AbiTag->tags());
// Don't emit abi tags for namespaces.
return;
}
}

AbiTagList TagList;
if (const auto *AbiTag = ND->getAttr<AbiTagAttr>()) {
UsedAbiTags.insert(UsedAbiTags.end(), AbiTag->tags().begin(),
AbiTag->tags().end());
TagList.insert(TagList.end(), AbiTag->tags().begin(),
AbiTag->tags().end());
llvm::append_range(UsedAbiTags, AbiTag->tags());
llvm::append_range(TagList, AbiTag->tags());
}

if (AdditionalAbiTags) {
UsedAbiTags.insert(UsedAbiTags.end(), AdditionalAbiTags->begin(),
AdditionalAbiTags->end());
TagList.insert(TagList.end(), AdditionalAbiTags->begin(),
AdditionalAbiTags->end());
llvm::append_range(UsedAbiTags, *AdditionalAbiTags);
llvm::append_range(TagList, *AdditionalAbiTags);
}

llvm::sort(TagList);
Expand Down
6 changes: 2 additions & 4 deletions clang/lib/AST/Randstruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,10 @@ bool randomizeStructureLayout(const ASTContext &Context, RecordDecl *RD,
randomizeStructureLayoutImpl(Context, RandomizedFields, RNG);

// Plorp the randomized decls into the final ordering.
FinalOrdering.insert(FinalOrdering.end(), RandomizedFields.begin(),
RandomizedFields.end());
llvm::append_range(FinalOrdering, RandomizedFields);

// Add fields that belong towards the end of the RecordDecl.
FinalOrdering.insert(FinalOrdering.end(), PostRandomizedFields.begin(),
PostRandomizedFields.end());
llvm::append_range(FinalOrdering, PostRandomizedFields);

// Add back the flexible array.
if (FlexibleArray)
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Analysis/IntervalPartition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static void fillIntervalNode(CFGIntervalGraph &Graph,
Count += N->Nodes.size();
Nodes.reserve(Count);
for (auto &N : Result.Nodes)
Nodes.insert(Nodes.end(), N->Nodes.begin(), N->Nodes.end());
llvm::append_range(Nodes, N->Nodes);
Interval.Nodes = std::move(Nodes);
}
}
Expand Down
9 changes: 3 additions & 6 deletions clang/lib/CodeGen/CGCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,9 @@ class CallArgList : public SmallVector<CallArg, 8> {
/// this, the old CallArgList retains its list of arguments, but must not
/// be used to emit a call.
void addFrom(const CallArgList &other) {
insert(end(), other.begin(), other.end());
Writebacks.insert(Writebacks.end(), other.Writebacks.begin(),
other.Writebacks.end());
CleanupsToDeactivate.insert(CleanupsToDeactivate.end(),
other.CleanupsToDeactivate.begin(),
other.CleanupsToDeactivate.end());
llvm::append_range(*this, other);
llvm::append_range(Writebacks, other.Writebacks);
llvm::append_range(CleanupsToDeactivate, other.CleanupsToDeactivate);
assert(!(StackBase && other.StackBase) && "can't merge stackbases");
if (!StackBase)
StackBase = other.StackBase;
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/CodeGen/CGLoopInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,7 @@ SmallVector<Metadata *, 4> LoopInfo::createMetadata(
LoopProperties.push_back(MDNode::get(Ctx, Vals));
}

LoopProperties.insert(LoopProperties.end(), AdditionalLoopProperties.begin(),
AdditionalLoopProperties.end());
llvm::append_range(LoopProperties, AdditionalLoopProperties);
return createFullUnrollMetadata(Attrs, LoopProperties, HasUserTransforms);
}

Expand Down
7 changes: 3 additions & 4 deletions clang/lib/Driver/MultilibBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ static MultilibBuilder compose(const MultilibBuilder &Base,

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

Flags.insert(Flags.end(), Base.flags().begin(), Base.flags().end());
Flags.insert(Flags.end(), New.flags().begin(), New.flags().end());
llvm::append_range(Flags, Base.flags());
llvm::append_range(Flags, New.flags());

return Composed;
}
Expand All @@ -153,8 +153,7 @@ MultilibSetBuilder::Either(ArrayRef<MultilibBuilder> MultilibSegments) {
multilib_list Composed;

if (Multilibs.empty())
Multilibs.insert(Multilibs.end(), MultilibSegments.begin(),
MultilibSegments.end());
llvm::append_range(Multilibs, MultilibSegments);
else {
for (const auto &New : MultilibSegments) {
for (const auto &Base : Multilibs) {
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Driver/ToolChains/HIPUtility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ class HIPUndefinedFatBinSymbols {

processInput(BufferOrErr.get()->getMemBufferRef());
} else
WorkList.insert(WorkList.end(), CurrentAction->getInputs().begin(),
CurrentAction->getInputs().end());
llvm::append_range(WorkList, CurrentAction->getInputs());
}
}

Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Format/SortJavaScriptImports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,7 @@ class JavaScriptImportSorter : public TokenAnalyzer {
}
stable_sort(SortChunk);
mergeModuleReferences(SortChunk);
ReferencesSorted.insert(ReferencesSorted.end(), SortChunk.begin(),
SortChunk.end());
llvm::append_range(ReferencesSorted, SortChunk);
}
return ReferencesSorted;
}
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Frontend/CompilerInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,7 @@ struct ReadModuleNames : ASTReaderListener {
if (Current->IsUnimportable) continue;
Current->IsAvailable = true;
auto SubmodulesRange = Current->submodules();
Stack.insert(Stack.end(), SubmodulesRange.begin(),
SubmodulesRange.end());
llvm::append_range(Stack, SubmodulesRange);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2078,7 +2078,7 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
A->render(Args, ASL);
for (const auto &arg : ASL) {
StringRef ArgStr(arg);
Opts.CmdArgs.insert(Opts.CmdArgs.end(), ArgStr.begin(), ArgStr.end());
llvm::append_range(Opts.CmdArgs, ArgStr);
// using \00 to separate each commandline options.
Opts.CmdArgs.push_back('\0');
}
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Sema/ParsedAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ void AttributeFactory::reclaimPool(AttributePool &cur) {
}

void AttributePool::takePool(AttributePool &pool) {
Attrs.insert(Attrs.end(), pool.Attrs.begin(), pool.Attrs.end());
llvm::append_range(Attrs, pool.Attrs);
pool.Attrs.clear();
}

void AttributePool::takeFrom(ParsedAttributesView &List, AttributePool &Pool) {
assert(&Pool != this && "AttributePool can't take attributes from itself");
llvm::for_each(List.AttrList, [&Pool](ParsedAttr *A) { Pool.remove(A); });
Attrs.insert(Attrs.end(), List.AttrList.begin(), List.AttrList.end());
llvm::append_range(Attrs, List.AttrList);
}

namespace {
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Sema/SemaConcept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,7 @@ bool Sema::CheckConstraintSatisfaction(
// here.
llvm::SmallVector<TemplateArgument, 4> FlattenedArgs;
for (auto List : TemplateArgsLists)
FlattenedArgs.insert(FlattenedArgs.end(), List.Args.begin(),
List.Args.end());
llvm::append_range(FlattenedArgs, List.Args);

llvm::FoldingSetNodeID ID;
ConstraintSatisfaction::Profile(ID, Context, Template, FlattenedArgs);
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Serialization/MultiOnDiskHashTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ template<typename Info> class MultiOnDiskHashTable {
OverriddenFiles.reserve(NumFiles);
for (/**/; NumFiles != 0; --NumFiles)
OverriddenFiles.push_back(InfoObj.ReadFileRef(Ptr));
PendingOverrides.insert(PendingOverrides.end(), OverriddenFiles.begin(),
OverriddenFiles.end());
llvm::append_range(PendingOverrides, OverriddenFiles);

// Read the OnDiskChainedHashTable header.
storage_type Buckets = Data + BucketOffset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -752,8 +752,7 @@ bool DependencyScanningWorker::scanDependencies(
// Insert -cc1 comand line options into Argv
std::vector<std::string> Argv;
Argv.push_back(Cmd.getExecutable());
Argv.insert(Argv.end(), Cmd.getArguments().begin(),
Cmd.getArguments().end());
llvm::append_range(Argv, Cmd.getArguments());

// Create an invocation that uses the underlying file
// system to ensure that any file system requests that
Expand Down
3 changes: 1 addition & 2 deletions clang/tools/clang-installapi/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,8 +801,7 @@ std::pair<LibAttrs, ReexportedInterfaces> Options::getReexportedLibraries() {
PathSeq FwkSearchPaths(FEOpts.FwkPaths.begin(), FEOpts.FwkPaths.end());
for (const PlatformType P : Platforms) {
PathSeq PlatformSearchPaths = getPathsForPlatform(FEOpts.SystemFwkPaths, P);
FwkSearchPaths.insert(FwkSearchPaths.end(), PlatformSearchPaths.begin(),
PlatformSearchPaths.end());
llvm::append_range(FwkSearchPaths, PlatformSearchPaths);
for (const StringMapEntry<ArchitectureSet> &Lib :
LinkerOpts.ReexportedFrameworks) {
std::string Name = (Lib.getKey() + ".framework/" + Lib.getKey()).str();
Expand Down
3 changes: 1 addition & 2 deletions clang/unittests/Format/MacroCallReconstructorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ class MacroCallReconstructorTest : public testing::Test {
UnwrappedLine Result;
Result.Level = Level;
for (const Chunk &Chunk : Chunks) {
Result.Tokens.insert(Result.Tokens.end(), Chunk.Tokens.begin(),
Chunk.Tokens.end());
llvm::append_range(Result.Tokens, Chunk.Tokens);
assert(!Result.Tokens.empty());
Result.Tokens.back().Children.append(Chunk.Children.begin(),
Chunk.Children.end());
Expand Down
Loading