Skip to content

Commit aceae46

Browse files
committed
[NFC][TableGen] Code cleanup in Record.h/cpp
1 parent a061998 commit aceae46

File tree

2 files changed

+127
-192
lines changed

2 files changed

+127
-192
lines changed

llvm/include/llvm/TableGen/Record.h

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "llvm/ADT/DenseSet.h"
2020
#include "llvm/ADT/FoldingSet.h"
2121
#include "llvm/ADT/PointerIntPair.h"
22+
#include "llvm/ADT/STLExtras.h"
2223
#include "llvm/ADT/SmallVector.h"
2324
#include "llvm/ADT/StringExtras.h"
2425
#include "llvm/ADT/StringRef.h"
@@ -244,7 +245,7 @@ class RecordRecTy final : public RecTy,
244245
RecordRecTy &operator=(const RecordRecTy &) = delete;
245246

246247
// Do not use sized deallocation due to trailing objects.
247-
void operator delete(void *p) { ::operator delete(p); }
248+
void operator delete(void *Ptr) { ::operator delete(Ptr); }
248249

249250
static bool classof(const RecTy *RT) {
250251
return RT->getRecTyKind() == RecordRecTyKind;
@@ -598,7 +599,7 @@ class BitsInit final : public TypedInit,
598599
BitsInit &operator=(const BitsInit &) = delete;
599600

600601
// Do not use sized deallocation due to trailing objects.
601-
void operator delete(void *p) { ::operator delete(p); }
602+
void operator delete(void *Ptr) { ::operator delete(Ptr); }
602603

603604
static bool classof(const Init *I) {
604605
return I->getKind() == IK_BitsInit;
@@ -616,14 +617,16 @@ class BitsInit final : public TypedInit,
616617
std::optional<int64_t> convertInitializerToInt() const;
617618

618619
bool isComplete() const override {
619-
for (unsigned i = 0; i != getNumBits(); ++i)
620-
if (!getBit(i)->isComplete()) return false;
620+
for (const Init *Bit : getBits())
621+
if (!Bit->isComplete())
622+
return false;
621623
return true;
622624
}
623625

624626
bool allInComplete() const {
625-
for (unsigned i = 0; i != getNumBits(); ++i)
626-
if (getBit(i)->isComplete()) return false;
627+
for (const Init *Bit : getBits())
628+
if (Bit->isComplete())
629+
return false;
627630
return true;
628631
}
629632

@@ -773,7 +776,7 @@ class ListInit final : public TypedInit,
773776
ListInit &operator=(const ListInit &) = delete;
774777

775778
// Do not use sized deallocation due to trailing objects.
776-
void operator delete(void *p) { ::operator delete(p); }
779+
void operator delete(void *Ptr) { ::operator delete(Ptr); }
777780

778781
static bool classof(const Init *I) {
779782
return I->getKind() == IK_ListInit;
@@ -1060,6 +1063,8 @@ class CondOpInit final : public TypedInit,
10601063
return ArrayRef(getTrailingObjects<const Init *>() + NumConds, NumConds);
10611064
}
10621065

1066+
auto getCondAndVals() const { return zip_equal(getConds(), getVals()); }
1067+
10631068
const Init *Fold(const Record *CurRec) const;
10641069

10651070
const Init *resolveReferences(Resolver &R) const override;
@@ -1349,7 +1354,7 @@ class VarDefInit final
13491354
VarDefInit &operator=(const VarDefInit &) = delete;
13501355

13511356
// Do not use sized deallocation due to trailing objects.
1352-
void operator delete(void *p) { ::operator delete(p); }
1357+
void operator delete(void *Ptr) { ::operator delete(Ptr); }
13531358

13541359
static bool classof(const Init *I) {
13551360
return I->getKind() == IK_VarDefInit;
@@ -1495,6 +1500,8 @@ class DagInit final
14951500
return ArrayRef(getTrailingObjects<const StringInit *>(), NumArgs);
14961501
}
14971502

1503+
auto getArgAndNames() const { return zip_equal(getArgs(), getArgNames()); }
1504+
14981505
const Init *resolveReferences(Resolver &R) const override;
14991506

15001507
bool isConcrete() const override;
@@ -1798,9 +1805,9 @@ class Record {
17981805
}
17991806

18001807
void removeValue(const Init *Name) {
1801-
for (unsigned i = 0, e = Values.size(); i != e; ++i)
1802-
if (Values[i].getNameInit() == Name) {
1803-
Values.erase(Values.begin()+i);
1808+
for (auto [Idx, Value] : enumerate(Values))
1809+
if (Value.getNameInit() == Name) {
1810+
Values.erase(Values.begin() + Idx);
18041811
return;
18051812
}
18061813
llvm_unreachable("Cannot remove an entry that does not exist!");
@@ -2123,10 +2130,7 @@ struct LessRecordRegister {
21232130

21242131
size_t size() { return Parts.size(); }
21252132

2126-
std::pair<bool, StringRef> getPart(size_t i) {
2127-
assert (i < Parts.size() && "Invalid idx!");
2128-
return Parts[i];
2129-
}
2133+
std::pair<bool, StringRef> getPart(size_t Idx) { return Parts[Idx]; }
21302134
};
21312135

21322136
bool operator()(const Record *Rec1, const Record *Rec2) const {

0 commit comments

Comments
 (0)