================
@@ -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)) {
+    // Incomplete enum types are not treated as integer types.
+    // FIXME: In C++, enum types are never integer types.
+    return IsEnumDeclComplete(ET->getDecl()) &&
+           !IsEnumDeclScoped(ET->getDecl()) &&
----------------
rjmccall wrote:

Okay. My understanding is that supporting CodeGen and its dual-representation 
handling of boolean types is the immediate purpose of this method. 
"Representation" is a good name for such a method because this really is about 
lower-level representation.

At a high level, scoped enums with an underlying type of `bool` either need to 
use i8 as both their memory and their scalar lowered type or they need to be 
doing toMemory/fromMemory operations when moving to/from memory. I think the 
latter is probably the better situation overall. So I think we really want this 
method to ignored scoped-ness of enums.

The immediate problem this creates is that we have a bunch of existing methods 
that are arguably misnamed: they're named something involving "representation", 
but they're not really being used to ask about low-level representation. 
Instead, they're vector-inclusive variants of other predicates. I agree this is 
a bad place to have ended up, because people will naturally expect all the 
similarly-named methods to behave consistently.

Since the existing methods are arguably misnamed, I wonder if we could 
reasonably just change them. Since the difference is (AFAIK) purely to make 
them vector-inclusive, perhaps we should just remove them and have a 
`getNonVectorType()` method that clients are expected to call before using the 
existing predicates.

https://github.com/llvm/llvm-project/pull/136038
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to