53 lines · plain
1// RUN: not mlir-tblgen -gen-attrdef-decls -I %S/../../include %s 2>&1 | FileCheck %s2 3include "mlir/IR/OpBase.td"4 5def Test_Dialect : Dialect {6 let name = "test";7 let cppNamespace = "::test";8}9 10class TestAttr<string attrName, string attrMnemonic, list<Trait> traits = []>11 : AttrDef<Test_Dialect, attrName, traits> {12 let mnemonic = attrMnemonic;13}14 15def TestAttr : TestAttr<"Test", "test"> {16 let summary = "Test attrubute";17 let description = "Test attribute";18 19 let parameters = (ins AttrParameter<"std::int64_t", "arg">:$arg);20 let builders = [AttrBuilder<(ins "std::int64_t":$arg), [{21 return $_get($_ctxt, arg);22 }]>,23 AttrBuilder<(ins "std::int64_t":$arg), [{24 // Duplicated builder25 return $_get($_ctxt, arg);26 }]>];27 28 let assemblyFormat = "`<` $arg `>`";29 30 let skipDefaultBuilders = 1;31 let genVerifyDecl = 1;32 let genMnemonicAlias = 1;33}34 35def Test_TestAttrOp : Op<Test_Dialect, "test", []> {36 let summary = "test operation with attribute";37 let description = "test operation with attribute";38 39 let arguments = (ins TestAttr:$testAttr);40 let assemblyFormat = "$testAttr attr-dict";41}42 43// CHECK: attr-duplicated-custom-builders-error.td:20:7: error: builder `get` conflicts with an existing builder.44// CHECK-NEXT: let builders = [AttrBuilder<(ins "std::int64_t":$arg), [{45// CHECK-NEXT: ^46// CHECK-NEXT: note: A new builder with signature:47// CHECK-NEXT: static TestAttr get(::mlir::MLIRContext *context, std::int64_t arg);48// CHECK-EMPTY:49// CHECK-NEXT: is shadowed by an existing builder with signature:50// CHECK-NEXT: static TestAttr get(::mlir::MLIRContext *context, std::int64_t arg);51// CHECK-EMPTY:52// CHECK-NEXT: Please remove one of the conflicting definitions.53