diff options
| author | Kazu Hirata <kazu@google.com> | 2025-03-30 18:43:02 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-30 18:43:02 -0700 |
| commit | 6257621f41d1deb31cfbfcee993a75991a0bca13 (patch) | |
| tree | 1a63b0df7bdb26cabffdbaf126029e9e9ae14b59 /llvm/lib | |
| parent | 94122d58fc77079a291a3d008914006cb509d9db (diff) | |
[llvm] Use llvm::append_range (NFC) (#133658)
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 15 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/LogicalView/Core/LVOptions.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/LogicalView/Core/LVSymbol.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewReader.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/FileCheck/FileCheck.cpp | 6 | ||||
| -rw-r--r-- | llvm/lib/ObjCopy/COFF/COFFReader.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/ObjCopy/XCOFF/XCOFFReader.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/Support/CommandLine.cpp | 4 | ||||
| -rw-r--r-- | llvm/lib/Support/Debug.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/Support/SuffixTree.cpp | 3 | ||||
| -rw-r--r-- | llvm/lib/TableGen/Record.cpp | 3 |
13 files changed, 19 insertions, 38 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 40e755902b72..b0d9bcc38410 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -3339,10 +3339,8 @@ Error BitcodeReader::parseConstants() { if (Record.empty()) return error("Invalid aggregate record"); - unsigned Size = Record.size(); SmallVector<unsigned, 16> Elts; - for (unsigned i = 0; i != Size; ++i) - Elts.push_back(Record[i]); + llvm::append_range(Elts, Record); if (isa<StructType>(CurTy)) { V = BitcodeConstant::create( diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 34ba25dccc36..49411098d9c0 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -1209,8 +1209,7 @@ void ModuleBitcodeWriter::writeTypeTable() { TypeVals.push_back(TET->getNumTypeParameters()); for (Type *InnerTy : TET->type_params()) TypeVals.push_back(VE.getTypeID(InnerTy)); - for (unsigned IntParam : TET->int_params()) - TypeVals.push_back(IntParam); + llvm::append_range(TypeVals, TET->int_params()); break; } case Type::TypedPointerTyID: @@ -4303,10 +4302,8 @@ static void writeFunctionHeapProfileRecords( } for (auto Id : CI.StackIdIndices) Record.push_back(GetStackIndex(Id)); - if (!PerModule) { - for (auto V : CI.Clones) - Record.push_back(V); - } + if (!PerModule) + llvm::append_range(Record, CI.Clones); Stream.EmitRecord(PerModule ? bitc::FS_PERMODULE_CALLSITE_INFO : bitc::FS_COMBINED_CALLSITE_INFO, Record, CallsiteAbbrev); @@ -4326,10 +4323,8 @@ static void writeFunctionHeapProfileRecords( assert(CallStackCount <= CallStackPos.size()); Record.push_back(CallStackPos[CallStackCount++]); } - if (!PerModule) { - for (auto V : AI.Versions) - Record.push_back(V); - } + if (!PerModule) + llvm::append_range(Record, AI.Versions); assert(AI.ContextSizeInfos.empty() || AI.ContextSizeInfos.size() == AI.MIBs.size()); // Optionally emit the context size information if it exists. diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVOptions.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVOptions.cpp index c8789cb959fb..8050c0efdd7c 100644 --- a/llvm/lib/DebugInfo/LogicalView/Core/LVOptions.cpp +++ b/llvm/lib/DebugInfo/LogicalView/Core/LVOptions.cpp @@ -445,8 +445,7 @@ void LVPatterns::addGenericPatterns(StringSet<> &Patterns) { } void LVPatterns::addOffsetPatterns(const LVOffsetSet &Patterns) { - for (const LVOffset &Entry : Patterns) - OffsetMatchInfo.push_back(Entry); + llvm::append_range(OffsetMatchInfo, Patterns); if (OffsetMatchInfo.size()) { options().setSelectOffsetPattern(); options().setSelectExecute(); diff --git a/llvm/lib/DebugInfo/LogicalView/Core/LVSymbol.cpp b/llvm/lib/DebugInfo/LogicalView/Core/LVSymbol.cpp index 4608fe20cb6d..44d073387206 100644 --- a/llvm/lib/DebugInfo/LogicalView/Core/LVSymbol.cpp +++ b/llvm/lib/DebugInfo/LogicalView/Core/LVSymbol.cpp @@ -182,8 +182,7 @@ void LVSymbol::getLocations(LVLocations &LocationList) const { if (!Locations) return; - for (LVLocation *Location : *Locations) - LocationList.push_back(Location); + llvm::append_range(LocationList, *Locations); } // Calculate coverage factor. diff --git a/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewReader.cpp b/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewReader.cpp index 8074f1a9fddf..e5895516b5e7 100644 --- a/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewReader.cpp +++ b/llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewReader.cpp @@ -163,8 +163,7 @@ void LVCodeViewReader::cacheRelocations() { const coff_section *CoffSection = getObj().getCOFFSection(Section); auto &RM = RelocMap[CoffSection]; - for (const RelocationRef &Relocacion : Section.relocations()) - RM.push_back(Relocacion); + llvm::append_range(RM, Section.relocations()); // Sort relocations by address. llvm::sort(RM, [](RelocationRef L, RelocationRef R) { diff --git a/llvm/lib/FileCheck/FileCheck.cpp b/llvm/lib/FileCheck/FileCheck.cpp index 10ca5f4d122b..71b47a04fd13 100644 --- a/llvm/lib/FileCheck/FileCheck.cpp +++ b/llvm/lib/FileCheck/FileCheck.cpp @@ -1640,13 +1640,11 @@ static const char *DefaultCommentPrefixes[] = {"COM", "RUN"}; static void addDefaultPrefixes(FileCheckRequest &Req) { if (Req.CheckPrefixes.empty()) { - for (const char *Prefix : DefaultCheckPrefixes) - Req.CheckPrefixes.push_back(Prefix); + llvm::append_range(Req.CheckPrefixes, DefaultCheckPrefixes); Req.IsDefaultCheckPrefix = true; } if (Req.CommentPrefixes.empty()) - for (const char *Prefix : DefaultCommentPrefixes) - Req.CommentPrefixes.push_back(Prefix); + llvm::append_range(Req.CommentPrefixes, DefaultCommentPrefixes); } struct PrefixMatcher { diff --git a/llvm/lib/ObjCopy/COFF/COFFReader.cpp b/llvm/lib/ObjCopy/COFF/COFFReader.cpp index 32aceb805a2a..62a71d41ded5 100644 --- a/llvm/lib/ObjCopy/COFF/COFFReader.cpp +++ b/llvm/lib/ObjCopy/COFF/COFFReader.cpp @@ -70,8 +70,7 @@ Error COFFReader::readSections(Object &Obj) const { return E; S.setContentsRef(Contents); ArrayRef<coff_relocation> Relocs = COFFObj.getRelocations(Sec); - for (const coff_relocation &R : Relocs) - S.Relocs.push_back(R); + llvm::append_range(S.Relocs, Relocs); if (Expected<StringRef> NameOrErr = COFFObj.getSectionName(Sec)) S.Name = *NameOrErr; else diff --git a/llvm/lib/ObjCopy/XCOFF/XCOFFReader.cpp b/llvm/lib/ObjCopy/XCOFF/XCOFFReader.cpp index 8ad3021a0342..e6018ebfbec2 100644 --- a/llvm/lib/ObjCopy/XCOFF/XCOFFReader.cpp +++ b/llvm/lib/ObjCopy/XCOFF/XCOFFReader.cpp @@ -38,8 +38,7 @@ Error XCOFFReader::readSections(Object &Obj) const { XCOFFObj.relocations<XCOFFSectionHeader32, XCOFFRelocation32>(Sec); if (!Relocations) return Relocations.takeError(); - for (const XCOFFRelocation32 &Rel : Relocations.get()) - ReadSec.Relocations.push_back(Rel); + llvm::append_range(ReadSec.Relocations, Relocations.get()); } Obj.Sections.push_back(std::move(ReadSec)); diff --git a/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp b/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp index 527265410809..381330b98f71 100644 --- a/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp +++ b/llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp @@ -735,9 +735,7 @@ Expected<std::shared_ptr<YAMLCoffSymbolRVASubsection>> YAMLCoffSymbolRVASubsection::fromCodeViewSubsection( const DebugSymbolRVASubsectionRef &Section) { auto Result = std::make_shared<YAMLCoffSymbolRVASubsection>(); - for (const auto &RVA : Section) { - Result->RVAs.push_back(RVA); - } + llvm::append_range(Result->RVAs, Section); return Result; } diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index e34a770b1b53..f1dd39ce133a 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -2435,8 +2435,8 @@ protected: // Collect registered option categories into vector in preparation for // sorting. - for (OptionCategory *Category : GlobalParser->RegisteredOptionCategories) - SortedCategories.push_back(Category); + llvm::append_range(SortedCategories, + GlobalParser->RegisteredOptionCategories); // Sort the different option categories alphabetically. assert(SortedCategories.size() > 0 && "No option categories registered!"); diff --git a/llvm/lib/Support/Debug.cpp b/llvm/lib/Support/Debug.cpp index 98a9ac4722b5..5bb04d0c2299 100644 --- a/llvm/lib/Support/Debug.cpp +++ b/llvm/lib/Support/Debug.cpp @@ -73,8 +73,7 @@ void setCurrentDebugType(const char *Type) { void setCurrentDebugTypes(const char **Types, unsigned Count) { CurrentDebugType->clear(); - for (size_t T = 0; T < Count; ++T) - CurrentDebugType->push_back(Types[T]); + llvm::append_range(*CurrentDebugType, ArrayRef(Types, Count)); } } // namespace llvm diff --git a/llvm/lib/Support/SuffixTree.cpp b/llvm/lib/Support/SuffixTree.cpp index 5abcead5037f..b2e606c86dd5 100644 --- a/llvm/lib/Support/SuffixTree.cpp +++ b/llvm/lib/Support/SuffixTree.cpp @@ -348,8 +348,7 @@ void SuffixTree::RepeatedSubstringIterator::advance() { // Yes. Update the state to reflect this, and then bail out. N = Curr; RS.Length = Length; - for (unsigned StartIdx : RepeatedSubstringStarts) - RS.StartIndices.push_back(StartIdx); + llvm::append_range(RS.StartIndices, RepeatedSubstringStarts); break; } // At this point, either NewRS is an empty RepeatedSubstring, or it was diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index d182b647aa93..0fdf78976b69 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -1015,8 +1015,7 @@ const Init *UnOpInit::Fold(const Record *CurRec, bool IsFinal) const { const auto *InnerList = dyn_cast<ListInit>(InnerInit); if (!InnerList) return std::nullopt; - for (const Init *InnerElem : InnerList->getValues()) - Flattened.push_back(InnerElem); + llvm::append_range(Flattened, InnerList->getValues()); }; return Flattened; }; |
