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

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Mar 13 11:22:47 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Christopher Di Bella (cjdb)

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/131184.diff


1 Files Affected:

- (modified) mlir/tools/mlir-tblgen/RewriterGen.cpp (+2-3) 


``````````diff
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);
   }
 

``````````

</details>


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


More information about the Mlir-commits mailing list