[Mlir-commits] [mlir] [mlir][mlir-tblgen] Emit correct error message if method is pruned (PR #160334)

Justin Kim llvmlistbot at llvm.org
Wed Sep 24 01:48:50 PDT 2025


JustinKim98 wrote:

>From `genBuilder` implementation in `OpDefinitions.cpp`, I think `ERROR_IF_PRUNED` should be called regardless of presence of body, since it would allow ambiguous or duplicated symbol in declaration file.

I wonder is there a specific reason that `genBuidler` checks for pruned out builder only for non-empty builder?
```cpp
void OpEmitter::genBuilder() {
  // Handle custom builders if provided.
  for (const Builder &builder : op.getBuilders()) {
    SmallVector<MethodParameter> arguments = getBuilderSignature(builder);

    std::optional<StringRef> body = builder.getBody();
    auto properties = body ? Method::Static : Method::StaticDeclaration;
    auto *method = opClass.addMethod("void", "build", properties, arguments);
    
    // Why is this checked only if body is present?
    if (body)
      ERROR_IF_PRUNED(method, "build", op);

    if (method)
      method->setDeprecated(builder.getDeprecatedMessage());
```

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


More information about the Mlir-commits mailing list