Skip to content

[llvm] Use llvm::append_range (NFC) #133658

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
3 changes: 1 addition & 2 deletions llvm/include/llvm/CodeGen/TileShapeInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
15 changes: 5 additions & 10 deletions llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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);
Expand All @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/DebugInfo/LogicalView/Core/LVOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/DebugInfo/LogicalView/Core/LVSymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/DebugInfo/LogicalView/Readers/LVCodeViewReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 2 additions & 4 deletions llvm/lib/FileCheck/FileCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/ObjCopy/COFF/COFFReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/ObjCopy/XCOFF/XCOFFReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 1 addition & 3 deletions llvm/lib/ObjectYAML/CodeViewYAMLDebugSections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Support/CommandLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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!");
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Support/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Support/SuffixTree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/TableGen/Record.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
5 changes: 1 addition & 4 deletions llvm/utils/not/not.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down