[clang] [clang] Rework `hasBooleanRepresentation`. (PR #136038)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 17 04:23:49 PDT 2025


================
@@ -8623,6 +8624,13 @@ inline bool Type::isIntegralOrEnumerationType() const {
 inline bool Type::isBooleanType() const {
   if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
     return BT->getKind() == BuiltinType::Bool;
+  if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
----------------
AaronBallman wrote:

> I'm not entirely sure it makes sense to handle enums here

I don't believe it makes sense to report true for an enum type. An enumeration type is never a boolean type in C or in C++. An enumeration can have a boolean underlying type, but it's still an enumeration type rather than a boolean type.

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


More information about the cfe-commits mailing list