@@ -632,10 +632,11 @@ class BitsInit final : public TypedInit,
632
632
633
633
const Init *resolveReferences (Resolver &R) const override ;
634
634
635
- const Init *getBit (unsigned Bit) const override {
636
- assert (Bit < NumBits && " Bit index out of range!" );
637
- return getTrailingObjects<const Init *>()[Bit];
635
+ ArrayRef<const Init *> getBits () const {
636
+ return ArrayRef (getTrailingObjects<const Init *>(), NumBits);
638
637
}
638
+
639
+ const Init *getBit (unsigned Bit) const override { return getBits ()[Bit]; }
639
640
};
640
641
641
642
// / '7' - Represent an initialization by a literal integer value.
@@ -781,10 +782,12 @@ class ListInit final : public TypedInit,
781
782
782
783
void Profile (FoldingSetNodeID &ID) const ;
783
784
784
- const Init *getElement (unsigned i) const {
785
- assert (i < NumValues && " List element index out of range!" );
786
- return getTrailingObjects<const Init *>()[i];
785
+ ArrayRef<const Init *> getValues () const {
786
+ return ArrayRef (getTrailingObjects<const Init *>(), NumValues);
787
787
}
788
+
789
+ const Init *getElement (unsigned Index) const { return getValues ()[Index]; }
790
+
788
791
const RecTy *getElementType () const {
789
792
return cast<ListRecTy>(getType ())->getElementType ();
790
793
}
@@ -804,12 +807,8 @@ class ListInit final : public TypedInit,
804
807
bool isConcrete () const override ;
805
808
std::string getAsString () const override ;
806
809
807
- ArrayRef<const Init *> getValues () const {
808
- return ArrayRef (getTrailingObjects<const Init *>(), NumValues);
809
- }
810
-
811
- const_iterator begin () const { return getTrailingObjects<const Init *>(); }
812
- const_iterator end () const { return begin () + NumValues; }
810
+ const_iterator begin () const { return getValues ().begin (); }
811
+ const_iterator end () const { return getValues ().end (); }
813
812
814
813
size_t size () const { return NumValues; }
815
814
bool empty () const { return NumValues == 0 ; }
0 commit comments