[llvm] [mlir] [MLIR][ADT] Fix uninitialized scalar and array-vs-singleton patterns flagged by Coverity in generated code (PR #215217)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 10 01:38:14 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 h,cpp -- llvm/include/llvm/ADT/STLFunctionalExtras.h mlir/tools/mlir-tblgen/OpFormatGen.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/tools/mlir-tblgen/OpFormatGen.cpp b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
index 3732ed9d5..49acc7eff 100644
--- a/mlir/tools/mlir-tblgen/OpFormatGen.cpp
+++ b/mlir/tools/mlir-tblgen/OpFormatGen.cpp
@@ -961,10 +961,10 @@ static void genElementParserStorage(FormatElement *element, const Operator &op,
     if (lengthKind != ArgumentLengthKind::Single)
       body << "  ::llvm::SmallVector<::mlir::Type, 1> " << name << "Types;\n";
     else
-      body
-          << formatv("  ::mlir::Type {0}RawTypes[1] = {{};\n", name)
-          << formatv("  ::llvm::ArrayRef<::mlir::Type> {0}Types({0}RawTypes);\n",
-                     name);
+      body << formatv("  ::mlir::Type {0}RawTypes[1] = {{};\n", name)
+           << formatv(
+                  "  ::llvm::ArrayRef<::mlir::Type> {0}Types({0}RawTypes);\n",
+                  name);
   } else if (auto *dir = dyn_cast<FunctionalTypeDirective>(element)) {
     ArgumentLengthKind ignored;
     body << "  ::llvm::ArrayRef<::mlir::Type> "

``````````

</details>


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


More information about the llvm-commits mailing list