[Mlir-commits] [mlir] [emitC]Option to mlir-translate class instead of function (PR #141158)

Mehdi Amini llvmlistbot at llvm.org
Thu May 29 12:22:31 PDT 2025


================
@@ -1140,6 +1220,30 @@ static LogicalResult printOperation(CppEmitter &emitter,
 
   CppEmitter::Scope scope(emitter);
   raw_indented_ostream &os = emitter.ostream();
+  Operation *operation = functionOp.getOperation();
+  if (emitter.shouldPrintClass()) {
+    if (functionOp.isExternal()) {
+      // TODO: Determine the best long-term strategy for external functions.
+      // Currently, we're skipping over this functionOp.
+      // We have considered using emitWarning() which would return
+      // InFlightDiagnostic which seems can be automatically converted to
+      // LogicalResult since this is done in emitAttributes where emitError is
+      // converted to LogicalResult. However, it requires that we pass in a
+      // location which at first glance we don't have in this scope. Open to
+      // further discussion on this.
+      os << "Warning: Cannot process external function '"
+         << functionOp.getName() << "'. "
+         << "This functionOp lacks a body so we will skip over it.";
----------------
joker-eph wrote:

Every op has a location. The way to emit warning is simply:

`functionOp->emitWarning() << ...;`

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


More information about the Mlir-commits mailing list