[Mlir-commits] [mlir] [mlir][ODS] Name obfuscation for private / internal dialects (PR #198083)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sat May 16 03:53:04 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp,h -- mlir/include/mlir/TableGen/PrivateName.h mlir/lib/TableGen/PrivateName.cpp mlir/include/mlir/TableGen/AttrOrTypeDef.h mlir/include/mlir/TableGen/Dialect.h mlir/include/mlir/TableGen/Operator.h mlir/include/mlir/TableGen/Pass.h mlir/lib/TableGen/AttrOrTypeDef.cpp mlir/lib/TableGen/Dialect.cpp mlir/lib/TableGen/Operator.cpp mlir/lib/TableGen/Pass.cpp mlir/lib/Tools/mlir-tblgen/MlirTblgenMain.cpp mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp mlir/tools/mlir-tblgen/DialectGen.cpp mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp mlir/tools/mlir-tblgen/PassCAPIGen.cpp mlir/tools/mlir-tblgen/PassGen.cpp mlir/tools/mlir-tblgen/RewriterGen.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/mlir/lib/TableGen/Dialect.cpp b/mlir/lib/TableGen/Dialect.cpp
index e58e8bf13..9957ff0e3 100644
--- a/mlir/lib/TableGen/Dialect.cpp
+++ b/mlir/lib/TableGen/Dialect.cpp
@@ -102,9 +102,7 @@ bool Dialect::isExtensible() const {
   return def->getValueAsBit("isExtensible");
 }
 
-bool Dialect::isPrivate() const {
-  return def->getValueAsBit("isPrivate");
-}
+bool Dialect::isPrivate() const { return def->getValueAsBit("isPrivate"); }
 
 const llvm::DagInit *Dialect::getDiscardableAttributes() const {
   return def->getValueAsDag("discardableAttrs");
diff --git a/mlir/lib/TableGen/PrivateName.cpp b/mlir/lib/TableGen/PrivateName.cpp
index 3ffb69c1c..a974d34d5 100644
--- a/mlir/lib/TableGen/PrivateName.cpp
+++ b/mlir/lib/TableGen/PrivateName.cpp
@@ -112,8 +112,7 @@ StringRef mlir::tblgen::obfuscatePrivateName(StringRef name) {
     return it->second;
 
   uint8_t out[8] = {};
-  uint8_t (&saltKey)[16] =
-      *reinterpret_cast<uint8_t (*)[16]>(s.salt.data());
+  uint8_t (&saltKey)[16] = *reinterpret_cast<uint8_t (*)[16]>(s.salt.data());
   llvm::getSipHash_2_4_64(
       llvm::ArrayRef<uint8_t>(reinterpret_cast<const uint8_t *>(name.data()),
                               name.size()),
diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
index fcd3b81de..a30aadc4a 100644
--- a/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
+++ b/mlir/tools/mlir-tblgen/AttrOrTypeDefGen.cpp
@@ -454,9 +454,9 @@ void DefGen::emitInvariantsVerifier(bool hasImpl, bool hasCustomVerifier) {
 void DefGen::emitParserPrinter() {
   auto *mnemonic = defCls.addStaticMethod<Method::Constexpr>(
       "::llvm::StringLiteral", "getMnemonic");
-  mnemonic->body().indent() << strfmt(
-      "return {\"{0}\"};",
-      tblgen::maybeObfuscate(*def.getMnemonic(), def.isPrivate()));
+  mnemonic->body().indent()
+      << strfmt("return {\"{0}\"};",
+                tblgen::maybeObfuscate(*def.getMnemonic(), def.isPrivate()));
 
   // Declare the parser and printer, if needed.
   bool hasAssemblyFormat = def.getAssemblyFormat().has_value();
@@ -713,9 +713,9 @@ void DefGen::emitMnemonicAliasMethod() {
   SmallVector<MethodParameter> params{{"::llvm::raw_ostream &", "os"}};
   Method *m = defCls.addMethod<Method::Const>("::mlir::OpAsmAliasResult",
                                               "getAlias", std::move(params));
-  m->body().indent() << strfmt(
-      "os << \"{0}\";\n",
-      tblgen::maybeObfuscate(*def.getMnemonic(), def.isPrivate()))
+  m->body().indent() << strfmt("os << \"{0}\";\n",
+                               tblgen::maybeObfuscate(*def.getMnemonic(),
+                                                      def.isPrivate()))
                      << "return ::mlir::OpAsmAliasResult::OverridableAlias;\n";
 }
 
diff --git a/mlir/tools/mlir-tblgen/RewriterGen.cpp b/mlir/tools/mlir-tblgen/RewriterGen.cpp
index 6314046f4..f63c0257e 100644
--- a/mlir/tools/mlir-tblgen/RewriterGen.cpp
+++ b/mlir/tools/mlir-tblgen/RewriterGen.cpp
@@ -724,15 +724,15 @@ void PatternEmitter::emitOperandMatch(DagNode tree, StringRef opName,
       }
       auto self = formatv("(*{0}.begin()).getType()", operandName);
       StringRef verifier = staticMatcherHelper.getVerifierName(operandMatcher);
-    emitStaticVerifierCall(
-        verifier, opName, self.str(),
-        formatv(
-            "\"operand {0} of op '{1}' failed to satisfy constraint: '{2}'\"",
-            operandIndex,
-            tblgen::maybeObfuscateDotted(op.getOperationName(),
-                                         op.isPrivate()),
-            escapeString(constraint.getSummary()))
-            .str());
+      emitStaticVerifierCall(
+          verifier, opName, self.str(),
+          formatv(
+              "\"operand {0} of op '{1}' failed to satisfy constraint: '{2}'\"",
+              operandIndex,
+              tblgen::maybeObfuscateDotted(op.getOperationName(),
+                                           op.isPrivate()),
+              escapeString(constraint.getSummary()))
+              .str());
     }
   }
 
@@ -944,12 +944,12 @@ void PatternEmitter::emitAttributeMatch(DagNode tree, StringRef castedName,
     }
     emitStaticVerifierCall(
         verifier, castedName, "tblgen_attr",
-        formatv("\"op '{0}' attribute '{1}' failed to satisfy constraint: "
-                "'{2}'\"",
-                tblgen::maybeObfuscateDotted(op.getOperationName(),
-                                             op.isPrivate()),
-                namedAttr->name,
-                escapeString(matcher.getAsConstraint().getSummary()))
+        formatv(
+            "\"op '{0}' attribute '{1}' failed to satisfy constraint: "
+            "'{2}'\"",
+            tblgen::maybeObfuscateDotted(op.getOperationName(), op.isPrivate()),
+            namedAttr->name,
+            escapeString(matcher.getAsConstraint().getSummary()))
             .str());
   }
 
@@ -986,12 +986,12 @@ void PatternEmitter::emitPropertyMatch(DagNode tree, StringRef castedName,
     StringRef verifier = staticMatcherHelper.getVerifierName(matcher);
     emitStaticVerifierCall(
         verifier, castedName, "tblgen_prop",
-        formatv("\"op '{0}' property '{1}' failed to satisfy constraint: "
-                "'{2}'\"",
-                tblgen::maybeObfuscateDotted(op.getOperationName(),
-                                             op.isPrivate()),
-                namedProp->name,
-                escapeString(matcher.getAsConstraint().getSummary()))
+        formatv(
+            "\"op '{0}' property '{1}' failed to satisfy constraint: "
+            "'{2}'\"",
+            tblgen::maybeObfuscateDotted(op.getOperationName(), op.isPrivate()),
+            namedProp->name,
+            escapeString(matcher.getAsConstraint().getSummary()))
             .str());
   }
 

``````````

</details>


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


More information about the Mlir-commits mailing list