[Mlir-commits] [mlir] b7167c7 - [mlir] Fix incorrect comparison due to -Wtautological-constant-out-of-range-compare (NFC)

Jie Fu llvmlistbot at llvm.org
Wed Sep 11 20:59:15 PDT 2024


Author: Jie Fu
Date: 2024-09-12T11:57:29+08:00
New Revision: b7167c784486581dad3f3188232951b79c6d0fd9

URL: https://github.com/llvm/llvm-project/commit/b7167c784486581dad3f3188232951b79c6d0fd9
DIFF: https://github.com/llvm/llvm-project/commit/b7167c784486581dad3f3188232951b79c6d0fd9.diff

LOG: [mlir] Fix incorrect comparison due to -Wtautological-constant-out-of-range-compare (NFC)

/llvm-project/mlir/include/mlir/Analysis/Presburger/Utils.h:320:26:
error: result of comparison of constant 18446744073709551615 with expression of type 'unsigned int' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
  preIndent = (preIndent != std::string::npos) ? preIndent + 1 : 0;
               ~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~
/llvm-project/mlir/include/mlir/Analysis/Presburger/Utils.h:335:28:
error: result of comparison of constant 18446744073709551615 with expression of type 'unsigned int' is always true [-Werror,-Wtautological-constant-out-of-range-compare]
    preIndent = (preIndent != std::string::npos) ? preIndent + 1 : 0;
                 ~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~
2 errors generated.

Added: 
    

Modified: 
    mlir/include/mlir/Analysis/Presburger/Utils.h

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir/Analysis/Presburger/Utils.h b/mlir/include/mlir/Analysis/Presburger/Utils.h
index 69a5ce4e70178f..0e6d18279d67ed 100644
--- a/mlir/include/mlir/Analysis/Presburger/Utils.h
+++ b/mlir/include/mlir/Analysis/Presburger/Utils.h
@@ -317,7 +317,7 @@ void updatePrintMetrics(T val, PrintTableMetrics &m) {
   if (str.empty())
     return;
   unsigned preIndent = str.find(m.preAlign);
-  preIndent = (preIndent != std::string::npos) ? preIndent + 1 : 0;
+  preIndent = (preIndent != (unsigned)std::string::npos) ? preIndent + 1 : 0;
   m.maxPreIndent = std::max(m.maxPreIndent, preIndent);
   m.maxPostIndent =
       std::max(m.maxPostIndent, (unsigned int)(str.length() - preIndent));
@@ -332,7 +332,7 @@ void printWithPrintMetrics(raw_ostream &os, T val, unsigned minSpacing,
   unsigned preIndent;
   if (!str.empty()) {
     preIndent = str.find(m.preAlign);
-    preIndent = (preIndent != std::string::npos) ? preIndent + 1 : 0;
+    preIndent = (preIndent != (unsigned)std::string::npos) ? preIndent + 1 : 0;
   } else {
     preIndent = 0;
   }


        


More information about the Mlir-commits mailing list