Skip to content

Commit 0f38543

Browse files
authored
[NFC][TableGen] Use SmallVector range constructor when possible (llvm#140284)
Initialize vectors using constructor instead of llvm::append_range when possible.
1 parent 175f8a4 commit 0f38543

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

llvm/lib/TableGen/Record.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,10 @@ static const RecordRecTy *resolveRecordTypes(const RecordRecTy *T1,
334334
while (!Stack.empty()) {
335335
const Record *R = Stack.pop_back_val();
336336

337-
if (T2->isSubClassOf(R)) {
337+
if (T2->isSubClassOf(R))
338338
CommonSuperClasses.push_back(R);
339-
} else {
340-
append_range(Stack, make_first_range(R->getDirectSuperClasses()));
341-
}
339+
else
340+
llvm::append_range(Stack, make_first_range(R->getDirectSuperClasses()));
342341
}
343342

344343
return RecordRecTy::get(T1->getRecordKeeper(), CommonSuperClasses);
@@ -2733,11 +2732,8 @@ const DagInit *DagInit::get(const Init *V, const StringInit *VN,
27332732
const DagInit *DagInit::get(
27342733
const Init *V, const StringInit *VN,
27352734
ArrayRef<std::pair<const Init *, const StringInit *>> ArgAndNames) {
2736-
SmallVector<const Init *, 8> Args;
2737-
SmallVector<const StringInit *, 8> Names;
2738-
2739-
llvm::append_range(Args, make_first_range(ArgAndNames));
2740-
llvm::append_range(Names, make_second_range(ArgAndNames));
2735+
SmallVector<const Init *, 8> Args(make_first_range(ArgAndNames));
2736+
SmallVector<const StringInit *, 8> Names(make_second_range(ArgAndNames));
27412737
return DagInit::get(V, VN, Args, Names);
27422738
}
27432739

@@ -2901,8 +2897,8 @@ void Record::checkName() {
29012897
}
29022898

29032899
const RecordRecTy *Record::getType() const {
2904-
SmallVector<const Record *, 4> DirectSCs;
2905-
append_range(DirectSCs, make_first_range(getDirectSuperClasses()));
2900+
SmallVector<const Record *> DirectSCs(
2901+
make_first_range(getDirectSuperClasses()));
29062902
return RecordRecTy::get(TrackedRecords, DirectSCs);
29072903
}
29082904

llvm/utils/TableGen/Common/CodeGenRegisters.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -650,8 +650,7 @@ struct TupleExpander : SetTheory::Expander {
650650

651651
// Take the cost list of the first register in the tuple.
652652
const ListInit *CostList = Proto->getValueAsListInit("CostPerUse");
653-
SmallVector<const Init *, 2> CostPerUse;
654-
llvm::append_range(CostPerUse, *CostList);
653+
SmallVector<const Init *, 2> CostPerUse(CostList->getValues());
655654

656655
const StringInit *AsmName = StringInit::get(RK, "");
657656
if (!RegNames.empty()) {

0 commit comments

Comments
 (0)