[clang-tools-extra] [clang-tidy][NFC] fix compilation by disambiguating equality operator (PR #147048)

Gregor Jasny via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 7 01:17:24 PDT 2025


https://github.com/gjasny updated https://github.com/llvm/llvm-project/pull/147048

>From f1ff857dd5a6751255884b4fa4c347f7fe7b7a2a Mon Sep 17 00:00:00 2001
From: Gregor Jasny <gjasny at googlemail.com>
Date: Fri, 4 Jul 2025 13:19:22 +0100
Subject: [PATCH] [clang-tidy] fix compilation by disambiguating equality
 operator

This fixes a compilation issue on Ubuntu 22.04 with the Ubuntu
provided Clang 14 and C++20. That's probably happening due to
incomplete C++20 support in either Clang 14 or the GNU libstdc++ 12.

Signed-off-by: Gregor Jasny <gjasny at googlemail.com>
---
 .../clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp       | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
index db0ac281ddfcf..0cb6971e3efcf 100644
--- a/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/TaggedUnionMemberCountCheck.cpp
@@ -144,7 +144,9 @@ TaggedUnionMemberCountCheck::getNumberOfEnumValues(const EnumDecl *ED) {
 
   if (EnableCountingEnumHeuristic && LastEnumConstant &&
       isCountingEnumLikeName(LastEnumConstant->getName()) &&
-      (LastEnumConstant->getInitVal() == (EnumValues.size() - 1))) {
+      llvm::APSInt::compareValues(LastEnumConstant->getInitVal(),
+                                  llvm::APSInt::get(EnumValues.size() - 1)) ==
+          0) {
     return {EnumValues.size() - 1, LastEnumConstant};
   }
 



More information about the cfe-commits mailing list