[Mlir-commits] [mlir] [mlir][emitc] Don't emit extra semicolon after bracket (PR #122464)

Matthias Gehre llvmlistbot at llvm.org
Mon Jan 13 04:27:19 PST 2025


================
@@ -0,0 +1,18 @@
+// RUN: mlir-translate -mlir-to-cpp %s | FileCheck %s
+// RUN: mlir-translate -mlir-to-cpp -declare-variables-at-top %s | FileCheck %s
+
+func.func @no_extra_semicolon(%arg0: i1) {
+  emitc.if %arg0 {
+    emitc.if %arg0 {
+    }
+    emitc.verbatim "return;"
+  }
----------------
mgehre-amd wrote:

Can we check the missing semicolon for the other emitc ops that are handled, like `DeclareFuncOp` `ForOp`, `SwitchOp` and `IncludeOp`?
This doesn't need to be here, it can also be in their respective tests.

I think you need to take extra care with the check lines as they will look for a matching prefix, so will also pass if the line has something else at the end (like a semicolon). I.e. `// CHECK-NEXT: if ([[V0]]) {` will also match `if (v0) {;`
I think there is FileCheck command line args or syntax to enforce full line matching.


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


More information about the Mlir-commits mailing list