Add iterators and size() helper method in ArrayAttr
authorLei Zhang <antiagainst@google.com>
Tue, 20 Nov 2018 23:00:51 +0000 (15:00 -0800)
committerjpienaar <jpienaar@google.com>
Fri, 29 Mar 2019 21:05:05 +0000 (14:05 -0700)
PiperOrigin-RevId: 222312276

mlir/include/mlir/IR/Attributes.h

index dabcdb494f348d7f34e122da40feee99dcc1a303..3aa020f4af8b17c2cf3efd8f2c61e6f4bccd96fe 100644 (file)
@@ -222,6 +222,12 @@ public:
 
   ArrayRef<Attribute> getValue() const;
 
+  size_t size() const { return getValue().size(); }
+
+  using iterator = llvm::ArrayRef<Attribute>::iterator;
+  iterator begin() const { return getValue().begin(); }
+  iterator end() const { return getValue().end(); }
+
   /// Methods for support type inquiry through isa, cast, and dyn_cast.
   static bool kindof(Kind kind) { return kind == Kind::Array; }
 };