[Mlir-commits] [mlir] [mlir][ods] resolve the wrong indent issue (PR #189277)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Mar 29 12:15:56 PDT 2026


https://github.com/aidint created https://github.com/llvm/llvm-project/pull/189277

The `emitSummaryAndDescComments` is used to generate summary and description for tablegen generated classes and structs such as Dialects and Interfaces. The generated summary and description is indented incorrectly in the output generated file. For example `NVGPUDialect.h.inc ` looks like the following:
```cpp
namespace mlir::nvgpu {

/// The `NVGPU` dialect provides a bridge between higher-level target-agnostic
///     dialects (GPU and Vector) and the lower-level target-specific dialect
///     (LLVM IR based NVVM dialect) for NVIDIA GPUs. This allow representing PTX
///     specific operations while using MLIR high level dialects such as Memref
///     and Vector for memory and target-specific register operands, respectively.
class NVGPUDialect : public ::mlir::Dialect {
    ...
  };

} // namespace mlir::nvgpu
```

This is because the `emitSummaryAndDescComments` trims the summary and description from both sides, rendering the re-indentation useless. This PR resolves this bug.

>From f9b7c7b92f2a95cd480072fb68804f4d438009b4 Mon Sep 17 00:00:00 2001
From: aidint <at.aidin at gmail.com>
Date: Sun, 29 Mar 2026 21:08:12 +0200
Subject: [PATCH] resolve the wrong indent issue

---
 mlir/tools/mlir-tblgen/CppGenUtilities.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mlir/tools/mlir-tblgen/CppGenUtilities.cpp b/mlir/tools/mlir-tblgen/CppGenUtilities.cpp
index 7cead353396dd..6c05d5336224d 100644
--- a/mlir/tools/mlir-tblgen/CppGenUtilities.cpp
+++ b/mlir/tools/mlir-tblgen/CppGenUtilities.cpp
@@ -18,8 +18,8 @@ void mlir::tblgen::emitSummaryAndDescComments(llvm::raw_ostream &os,
                                               llvm::StringRef summary,
                                               llvm::StringRef description,
                                               bool terminateComment) {
-  StringRef trimmedSummary = summary.trim();
-  StringRef trimmedDesc = description.trim();
+  StringRef trimmedSummary = summary.rtrim();
+  StringRef trimmedDesc = description.rtrim();
   raw_indented_ostream ros(os);
 
   bool empty = true;



More information about the Mlir-commits mailing list