[Mlir-commits] [mlir] Make `hasSummary` and `hasDescription` useful (PR #105531)

Alex Rice llvmlistbot at llvm.org
Wed Aug 21 07:06:05 PDT 2024


https://github.com/alexarice created https://github.com/llvm/llvm-project/pull/105531

The `hasSummary` and `hasDescription` functions are currently useless as they check if the corresponding `summary` and `description` are present. However, these values are set to a default value of `""`, and so these functions always return true.

This PR changes these functions to check if the summary and description are just whitespace, which is presumably closer to their original intent.

@math-fehr 
@zero9178 

>From 2062ffe98e24bd26ed60c7eb30a0b46050937b9e Mon Sep 17 00:00:00 2001
From: Alex Rice <alexrice999 at hotmail.co.uk>
Date: Wed, 21 Aug 2024 14:47:13 +0100
Subject: [PATCH] Make hasSummary and hasDescription useful

---
 mlir/lib/TableGen/Operator.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/TableGen/Operator.cpp b/mlir/lib/TableGen/Operator.cpp
index bd3e3b1c6b7ccf..76af82a827da13 100644
--- a/mlir/lib/TableGen/Operator.cpp
+++ b/mlir/lib/TableGen/Operator.cpp
@@ -798,14 +798,14 @@ const InferredResultType &Operator::getInferredResultType(int index) const {
 ArrayRef<SMLoc> Operator::getLoc() const { return def.getLoc(); }
 
 bool Operator::hasDescription() const {
-  return def.getValue("description") != nullptr;
+  return !getDescription().trim().empty();
 }
 
 StringRef Operator::getDescription() const {
   return def.getValueAsString("description");
 }
 
-bool Operator::hasSummary() const { return def.getValue("summary") != nullptr; }
+bool Operator::hasSummary() const { return !getSummary().trim().empty(); }
 
 StringRef Operator::getSummary() const {
   return def.getValueAsString("summary");



More information about the Mlir-commits mailing list