[Mlir-commits] [mlir] [mlir] adds `[[maybe_unused]]` to variables that might not be used (PR #131184)

Christopher Di Bella llvmlistbot at llvm.org
Thu Mar 13 11:22:14 PDT 2025


https://github.com/cjdb created https://github.com/llvm/llvm-project/pull/131184

This should suppress an unused variable warning that was seemingly pervasive.

>From 385473b6361cf4cb4590a1d3822865d3a5bff917 Mon Sep 17 00:00:00 2001
From: Christopher Di Bella <cjdb at google.com>
Date: Thu, 13 Mar 2025 18:20:06 +0000
Subject: [PATCH] [mlir] adds `[[maybe_unused]]` to variables that might not be
 used

This should suppress an unused variable warning that was seemingly
pervasive.
---
 mlir/tools/mlir-tblgen/RewriterGen.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp
index f921788abdd71..068a454e4732f 100644
--- a/mlir/tools/mlir-tblgen/RewriterGen.cpp
+++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp
@@ -872,12 +872,11 @@ void PatternEmitter::emitAttributeMatch(DagNode tree, StringRef castedName,
 
   os << "{\n";
   if (op.getDialect().usePropertiesForAttributes()) {
-    os.indent() << formatv("auto tblgen_attr = {0}.getProperties().{1}();\n",
+    os.indent() << formatv("[[maybe_unused]] auto tblgen_attr = {0}.getProperties().{1}();\n",
                            castedName, op.getGetterName(namedAttr->name));
   } else {
     os.indent() << formatv(
-        "auto tblgen_attr = {0}->getAttrOfType<{1}>(\"{2}\");"
-        "(void)tblgen_attr;\n",
+        "[[maybe_unused]] auto tblgen_attr = {0}->getAttrOfType<{1}>(\"{2}\");\n",
         castedName, attr.getStorageType(), namedAttr->name);
   }
 



More information about the Mlir-commits mailing list