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

This commit is contained in:
Kazu Hirata 2025-04-19 12:21:14 -07:00 committed by GitHub
parent 031475594a
commit c2d6c7cea7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 31 additions and 56 deletions

View File

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

View File

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

View File

@ -309,10 +309,8 @@ 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;
}
@ -320,17 +318,13 @@ class CXXNameMangler {
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);

View File

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

View File

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

View File

@ -312,12 +312,9 @@ public:
/// 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;

View File

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

View File

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

View File

@ -190,8 +190,7 @@ private:
processInput(BufferOrErr.get()->getMemBufferRef());
} else
WorkList.insert(WorkList.end(), CurrentAction->getInputs().begin(),
CurrentAction->getInputs().end());
llvm::append_range(WorkList, CurrentAction->getInputs());
}
}

View File

@ -276,8 +276,7 @@ private:
}
stable_sort(SortChunk);
mergeModuleReferences(SortChunk);
ReferencesSorted.insert(ReferencesSorted.end(), SortChunk.begin(),
SortChunk.end());
llvm::append_range(ReferencesSorted, SortChunk);
}
return ReferencesSorted;
}

View File

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

View File

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

View File

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

View File

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

View File

@ -209,8 +209,7 @@ public:
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;

View File

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

View File

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

View File

@ -165,8 +165,7 @@ public:
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());