[llvm] [mlir] Disable clang-tidy misc-include-cleaner (PR #83945)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 18:13:00 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Mehdi Amini (joker-eph)

<details>
<summary>Changes</summary>

This does not apply well to LLVM which intentionally rely on forward declarations. Also depending on the config flags passed to CMake the result can be different.

---
Full diff: https://github.com/llvm/llvm-project/pull/83945.diff


3 Files Affected:

- (modified) .clang-tidy (+1-1) 
- (modified) mlir/include/mlir/IR/Matchers.h (+11) 
- (modified) mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp (+1-2) 


``````````diff
diff --git a/.clang-tidy b/.clang-tidy
index 4e1cb114f43b2c..9cece0de812b8e 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -1,4 +1,4 @@
-Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-const-correctness,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,-misc-use-anonymous-namespace,readability-identifier-naming'
+Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-const-correctness,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,-misc-use-anonymous-namespace,readability-identifier-naming,-misc-include-cleaner'
 CheckOptions:
   - key:             readability-identifier-naming.ClassCase
     value:           CamelCase
diff --git a/mlir/include/mlir/IR/Matchers.h b/mlir/include/mlir/IR/Matchers.h
index f6417f62d09e8c..31a687dd422f60 100644
--- a/mlir/include/mlir/IR/Matchers.h
+++ b/mlir/include/mlir/IR/Matchers.h
@@ -15,9 +15,11 @@
 #ifndef MLIR_IR_MATCHERS_H
 #define MLIR_IR_MATCHERS_H
 
+#include "mlir/IR/BuiltinAttributeInterfaces.h"
 #include "mlir/IR/BuiltinAttributes.h"
 #include "mlir/IR/BuiltinTypes.h"
 #include "mlir/IR/OpDefinition.h"
+#include "llvm/Support/Casting.h"
 
 namespace mlir {
 
@@ -92,6 +94,15 @@ struct constant_op_binder {
     assert(succeeded(result) && "expected ConstantLike op to be foldable");
 
     if (auto attr = llvm::dyn_cast<AttrT>(foldedOp.front().get<Attribute>())) {
+      // Check that the attribute type matches the result type, folder shouldn't do
+      // this and maybe we should assert here, unfortunately llvm.constant accepts
+      // at the moment index attributes when the SSA type is integer.
+      if (auto typedAttr = dyn_cast<TypedAttr>(attr)) {
+        if (typedAttr.getType() != op->getResult(0).getType()) {
+          llvm::errs() << "Type mismatch: " << attr << "  " << *op << "\n";
+          return false;
+        }
+      }
       if (bind_value)
         *bind_value = attr;
       return true;
diff --git a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
index 51d2f5e01b7235..665536fb0c85ee 100644
--- a/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
+++ b/mlir/lib/Transforms/Utils/GreedyPatternRewriteDriver.cpp
@@ -809,8 +809,7 @@ LogicalResult RegionPatternRewriteDriver::simplify(bool *changed) && {
       // accidentally reversing the constant order during processing.
       Attribute constValue;
       if (matchPattern(op, m_Constant(&constValue)))
-        if (!folder.insertKnownConstant(op, constValue))
-          return true;
+        return !folder.insertKnownConstant(op, constValue);
       return false;
     };
 

``````````

</details>


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


More information about the llvm-commits mailing list