[Mlir-commits] [mlir] [mlir][CAPI] Replace MlirIdentifier with MlirAttribute (PR #188222)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Tue Mar 24 04:22:27 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,c,h -- mlir/include/mlir-c/Dialect/SMT.h mlir/include/mlir-c/IR.h mlir/include/mlir/Bindings/Python/IRInterfaces.h mlir/include/mlir/CAPI/IR.h mlir/lib/Bindings/Python/IRAttributes.cpp mlir/lib/Bindings/Python/IRCore.cpp mlir/lib/Bindings/Python/Rewrite.cpp mlir/lib/CAPI/Dialect/SMT.cpp mlir/lib/CAPI/IR/BuiltinAttributes.cpp mlir/lib/CAPI/IR/IR.cpp mlir/test/CAPI/ir.c mlir/test/CAPI/pass.c mlir/test/CAPI/smt.c --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/include/mlir-c/IR.h b/mlir/include/mlir-c/IR.h
index d79a7e69d..2711ddab2 100644
--- a/mlir/include/mlir-c/IR.h
+++ b/mlir/include/mlir-c/IR.h
@@ -346,8 +346,7 @@ MLIR_CAPI_EXPORTED MlirLocation mlirLocationNameGet(MlirContext context,
                                                     MlirLocation childLoc);
 
 /// Getter for name of Name.
-MLIR_CAPI_EXPORTED MlirAttribute
-mlirLocationNameGetName(MlirLocation location);
+MLIR_CAPI_EXPORTED MlirAttribute mlirLocationNameGetName(MlirLocation location);
 
 /// Getter for childLoc of Name.
 MLIR_CAPI_EXPORTED MlirLocation
diff --git a/mlir/lib/Bindings/Python/Rewrite.cpp b/mlir/lib/Bindings/Python/Rewrite.cpp
index b37db0708..7c4910e2b 100644
--- a/mlir/lib/Bindings/Python/Rewrite.cpp
+++ b/mlir/lib/Bindings/Python/Rewrite.cpp
@@ -244,13 +244,13 @@ void PyRewritePatternSet::addConversion(nb::handle root,
     nb::object opView = PyOperation::forOperation(ctx, op)->createOpView();
 
     std::vector<MlirValue> operandsVec(operands, operands + nOperands);
-    nb::object adaptorCls =
-        PyGlobals::get()
-            .lookupOpAdaptorClass([&] {
-              MlirStringRef ref = mlirStringAttrGetValue(mlirOperationGetName(op));
-              return std::string_view(ref.data, ref.length);
-            }())
-            .value_or(nb::borrow(nb::type<PyOpAdaptor>()));
+    nb::object adaptorCls = PyGlobals::get()
+                                .lookupOpAdaptorClass([&] {
+                                  MlirStringRef ref = mlirStringAttrGetValue(
+                                      mlirOperationGetName(op));
+                                  return std::string_view(ref.data, ref.length);
+                                }())
+                                .value_or(nb::borrow(nb::type<PyOpAdaptor>()));
 
     nb::object res = f(opView, adaptorCls(operandsVec, opView),
                        PyConversionPattern(pattern).getTypeConverter(),
diff --git a/mlir/lib/CAPI/Dialect/SMT.cpp b/mlir/lib/CAPI/Dialect/SMT.cpp
index 422e07c91..06867e3ca 100644
--- a/mlir/lib/CAPI/Dialect/SMT.cpp
+++ b/mlir/lib/CAPI/Dialect/SMT.cpp
@@ -107,9 +107,8 @@ MlirType mlirSMTTypeGetSort(MlirContext ctx, MlirAttribute identifier,
   for (size_t i = 0; i < numberOfSortParams; i++)
     sortParamsVec.push_back(unwrap(sortParams[i]));
 
-  return wrap(SortType::get(unwrap(ctx),
-                            llvm::cast<StringAttr>(unwrap(identifier)),
-                            sortParamsVec));
+  return wrap(SortType::get(
+      unwrap(ctx), llvm::cast<StringAttr>(unwrap(identifier)), sortParamsVec));
 }
 
 //===----------------------------------------------------------------------===//
diff --git a/mlir/lib/CAPI/IR/IR.cpp b/mlir/lib/CAPI/IR/IR.cpp
index 03441f161..1c1bdac2d 100644
--- a/mlir/lib/CAPI/IR/IR.cpp
+++ b/mlir/lib/CAPI/IR/IR.cpp
@@ -286,8 +286,8 @@ mlirLocationFileLineColRangeGet(MlirContext context, MlirStringRef filename,
 }
 
 MlirAttribute mlirLocationFileLineColRangeGetFilename(MlirLocation location) {
-  return wrap(
-      Attribute(llvm::dyn_cast<FileLineColRange>(unwrap(location)).getFilename()));
+  return wrap(Attribute(
+      llvm::dyn_cast<FileLineColRange>(unwrap(location)).getFilename()));
 }
 
 int mlirLocationFileLineColRangeGetStartLine(MlirLocation location) {
@@ -600,8 +600,9 @@ MlirOperation mlirOperationCreate(MlirOperationState *state) {
 
   cppState.attributes.reserve(state->nAttributes);
   for (intptr_t i = 0; i < state->nAttributes; ++i)
-    cppState.addAttribute(llvm::cast<StringAttr>(unwrap(state->attributes[i].name)),
-                          unwrap(state->attributes[i].attribute));
+    cppState.addAttribute(
+        llvm::cast<StringAttr>(unwrap(state->attributes[i].name)),
+        unwrap(state->attributes[i].attribute));
 
   for (intptr_t i = 0; i < state->nRegions; ++i)
     cppState.addRegion(std::unique_ptr<Region>(unwrap(state->regions[i])));
diff --git a/mlir/test/CAPI/smt.c b/mlir/test/CAPI/smt.c
index 948f6aefc..1ae7ab8d5 100644
--- a/mlir/test/CAPI/smt.c
+++ b/mlir/test/CAPI/smt.c
@@ -11,8 +11,8 @@
  */
 
 #include "mlir-c/Dialect/SMT.h"
-#include "mlir-c/Dialect/Func.h"
 #include "mlir-c/BuiltinAttributes.h"
+#include "mlir-c/Dialect/Func.h"
 #include "mlir-c/IR.h"
 #include "mlir-c/Support.h"
 #include "mlir-c/Target/ExportSMTLIB.h"

``````````

</details>


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


More information about the Mlir-commits mailing list