diff --git a/mlir/include/mlir/IR/OpBase.td b/mlir/include/mlir/IR/OpBase.td --- a/mlir/include/mlir/IR/OpBase.td +++ b/mlir/include/mlir/IR/OpBase.td @@ -2861,6 +2861,7 @@ AttrOrTypeDef<"Attr", name, traits, baseCppClass> { // The name of the C++ Attribute class. string cppClassName = name # "Attr"; + let storageType = dialect.cppNamespace # "::" # name # "Attr"; // The underlying C++ value type let returnType = dialect.cppNamespace # "::" # cppClassName; diff --git a/mlir/test/mlir-tblgen/op-attribute.td b/mlir/test/mlir-tblgen/op-attribute.td --- a/mlir/test/mlir-tblgen/op-attribute.td +++ b/mlir/test/mlir-tblgen/op-attribute.td @@ -6,6 +6,7 @@ def Test_Dialect : Dialect { let name = "test"; + let cppNamespace = "foobar"; } class NS_Op traits> : Op; @@ -17,6 +18,10 @@ let constBuilderCall = "some-const-builder-call($_builder, $0)"; } +def SomeAttrDef : AttrDef { +} + + // Test required, optional, default-valued attributes // --- @@ -271,6 +276,19 @@ // DECL-LABEL: EOp declarations // DECL: static void build({{.*}}, uint32_t i32_attr, uint32_t dv_i32_attr, ::llvm::APFloat f64_attr, ::llvm::APFloat dv_f64_attr, ::llvm::StringRef str_attr, ::llvm::StringRef dv_str_attr, bool bool_attr, bool dv_bool_attr, ::SomeI32Enum enum_attr, ::SomeI32Enum dv_enum_attr = ::SomeI32Enum::case5) + +// Test proper namespacing for AttrDef +// --- + +def NamespaceOp : NS_Op<"namespace_op", []> { + let arguments = (ins + SomeAttrDef:$AttrDef + ); +} +// DECL: NamespaceOp +// DECL: foobar::SomeAttrAttr AttrDef() + + // Test mixing operands and attributes in arbitrary order // ---