[Mlir-commits] [mlir] [mlir][IR] Add `Builder::getArrayAttr` overload for concrete attributes (PR #170870)

Matthias Springer llvmlistbot at llvm.org
Fri Dec 5 08:21:28 PST 2025


================
@@ -112,6 +112,15 @@ class Builder {
   StringAttr getStringAttr(const Twine &bytes);
   ArrayAttr getArrayAttr(ArrayRef<Attribute> value);
 
+  // Convenience method for containers of specific attribute types. E.g., this
+  // overload will match SmallVector<IntegerAttr>.
+  template <typename ContainerTy>
+  ArrayAttr getArrayAttr(const ContainerTy &value) {
+    auto ref = ArrayRef(value);
+    return getArrayAttr(ArrayRef<Attribute>(
+        static_cast<const Attribute *>(ref.data()), ref.size()));
----------------
matthias-springer wrote:

I thought it would be safe for Attribute because derived attributes don't have any extra state. Something seems to be wrong though because the Windows build is failing...

https://github.com/llvm/llvm-project/pull/170870


More information about the Mlir-commits mailing list