[llvm] Use llvm::append_range (NFC)#133658
Merged
kazutakahirata merged 1 commit intollvm:mainfrom Mar 31, 2025
Merged
Conversation
Member
|
@llvm/pr-subscribers-tablegen @llvm/pr-subscribers-debuginfo Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/133658.diff 16 Files Affected:
diff --git a/llvm/include/llvm/CodeGen/TileShapeInfo.h b/llvm/include/llvm/CodeGen/TileShapeInfo.h
index 24f303a7d9d13..9cea327819895 100644
--- a/llvm/include/llvm/CodeGen/TileShapeInfo.h
+++ b/llvm/include/llvm/CodeGen/TileShapeInfo.h
@@ -48,8 +48,7 @@ class ShapeT {
ColImm(InvalidImmShape) {
assert(ShapesOperands.size() % 2 == 0 && "Miss row or col!");
- for (auto *Shape : ShapesOperands)
- Shapes.push_back(Shape);
+ llvm::append_range(Shapes, ShapesOperands);
if (MRI)
deduceImm(MRI);
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h
index 4ea840c099e70..f74dcecb7e3e6 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h
@@ -43,8 +43,7 @@ class ShuffleMask {
static ShuffleMask getIdentity(unsigned Sz) {
IndicesVecT Indices;
Indices.reserve(Sz);
- for (auto Idx : seq<int>(0, (int)Sz))
- Indices.push_back(Idx);
+ llvm::append_range(Indices, seq<int>(0, (int)Sz));
return ShuffleMask(std::move(Indices));
}
/// \Returns true if the mask is a perfect identity mask with consecutive
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 40e755902b724..b0d9bcc384101 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 34ba25dccc368..49411098d9c0c 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 c8789cb959fb7..8050c0efdd7cb 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 4608fe20cb6df..44d073387206e 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 8074f1a9fddfb..e5895516b5e77 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 10ca5f4d122bc..71b47a04fd131 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 32aceb805a2a0..62a71d41ded5f 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 8ad3021a03428..e6018ebfbec21 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 527265410809c..381330b98f711 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 e34a770b1b53e..f1dd39ce133a8 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -2435,8 +2435,8 @@ class CategorizedHelpPrinter : public HelpPrinter {
// 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 98a9ac4722b50..5bb04d0c22998 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 5abcead5037f4..b2e606c86dd57 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 d182b647aa931..0fdf78976b691 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;
};
diff --git a/llvm/utils/not/not.cpp b/llvm/utils/not/not.cpp
index 6ba59190d8ada..6f270cb0f7783 100644
--- a/llvm/utils/not/not.cpp
+++ b/llvm/utils/not/not.cpp
@@ -57,10 +57,7 @@ int main(int argc, const char **argv) {
return 1;
}
- std::vector<StringRef> Argv;
- Argv.reserve(argc);
- for (int i = 0; i < argc; ++i)
- Argv.push_back(argv[i]);
+ SmallVector<StringRef> Argv(ArrayRef(argv, argc));
std::string ErrMsg;
int Result =
sys::ExecuteAndWait(*Program, Argv, std::nullopt, {}, 0, 0, &ErrMsg);
|
Member
|
@llvm/pr-subscribers-testing-tools Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/133658.diff 16 Files Affected:
diff --git a/llvm/include/llvm/CodeGen/TileShapeInfo.h b/llvm/include/llvm/CodeGen/TileShapeInfo.h
index 24f303a7d9d13..9cea327819895 100644
--- a/llvm/include/llvm/CodeGen/TileShapeInfo.h
+++ b/llvm/include/llvm/CodeGen/TileShapeInfo.h
@@ -48,8 +48,7 @@ class ShapeT {
ColImm(InvalidImmShape) {
assert(ShapesOperands.size() % 2 == 0 && "Miss row or col!");
- for (auto *Shape : ShapesOperands)
- Shapes.push_back(Shape);
+ llvm::append_range(Shapes, ShapesOperands);
if (MRI)
deduceImm(MRI);
diff --git a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h
index 4ea840c099e70..f74dcecb7e3e6 100644
--- a/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h
+++ b/llvm/include/llvm/Transforms/Vectorize/SandboxVectorizer/Legality.h
@@ -43,8 +43,7 @@ class ShuffleMask {
static ShuffleMask getIdentity(unsigned Sz) {
IndicesVecT Indices;
Indices.reserve(Sz);
- for (auto Idx : seq<int>(0, (int)Sz))
- Indices.push_back(Idx);
+ llvm::append_range(Indices, seq<int>(0, (int)Sz));
return ShuffleMask(std::move(Indices));
}
/// \Returns true if the mask is a perfect identity mask with consecutive
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 40e755902b724..b0d9bcc384101 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 34ba25dccc368..49411098d9c0c 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 c8789cb959fb7..8050c0efdd7cb 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 4608fe20cb6df..44d073387206e 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 8074f1a9fddfb..e5895516b5e77 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 10ca5f4d122bc..71b47a04fd131 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 32aceb805a2a0..62a71d41ded5f 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 8ad3021a03428..e6018ebfbec21 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 527265410809c..381330b98f711 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 e34a770b1b53e..f1dd39ce133a8 100644
--- a/llvm/lib/Support/CommandLine.cpp
+++ b/llvm/lib/Support/CommandLine.cpp
@@ -2435,8 +2435,8 @@ class CategorizedHelpPrinter : public HelpPrinter {
// 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 98a9ac4722b50..5bb04d0c22998 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 5abcead5037f4..b2e606c86dd57 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 d182b647aa931..0fdf78976b691 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;
};
diff --git a/llvm/utils/not/not.cpp b/llvm/utils/not/not.cpp
index 6ba59190d8ada..6f270cb0f7783 100644
--- a/llvm/utils/not/not.cpp
+++ b/llvm/utils/not/not.cpp
@@ -57,10 +57,7 @@ int main(int argc, const char **argv) {
return 1;
}
- std::vector<StringRef> Argv;
- Argv.reserve(argc);
- for (int i = 0; i < argc; ++i)
- Argv.push_back(argv[i]);
+ SmallVector<StringRef> Argv(ArrayRef(argv, argc));
std::string ErrMsg;
int Result =
sys::ExecuteAndWait(*Program, Argv, std::nullopt, {}, 0, 0, &ErrMsg);
|
dwblaikie
approved these changes
Mar 31, 2025
SchrodingerZhu
pushed a commit
to SchrodingerZhu/llvm-project
that referenced
this pull request
Mar 31, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.