[clang-tools-extra] [clang-tidy] Add QtEnabled option to modernize-use-integer-sign-comprison (PR #122127)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Sat Jan 11 00:38:45 PST 2025


================
@@ -154,8 +156,16 @@ void UseIntegerSignComparisonCheck::check(
   DiagnosticBuilder Diag =
       diag(BinaryOp->getBeginLoc(),
            "comparison between 'signed' and 'unsigned' integers");
-  const std::string CmpNamespace = ("std::" + parseOpCode(OpCode)).str();
-  const std::string CmpHeader = "<utility>";
+  std::string CmpNamespace;
+  std::string CmpHeader;
+  if (getLangOpts().CPlusPlus17 && QtFrameworkEnabled) {
+    CmpHeader = "<QtCore/q20utility.h>";
+    CmpNamespace = llvm::Twine("q20::" + parseOpCode(OpCode)).str();
+  }
+  if (getLangOpts().CPlusPlus20) {
+    CmpHeader = "<utility>";
+    CmpNamespace = llvm::Twine("std::" + parseOpCode(OpCode)).str();
+  }
----------------
PiotrZSL wrote:

When CPlusPlus20 is set, CPlusPlus17 will be set too, in such case you execute part for Qt and then override it with C++20 stuff, change order of ifs and add `else if `

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


More information about the cfe-commits mailing list