[clang] [clang] Rework `hasBooleanRepresentation`. (PR #136038)
Michele Scandale via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 17 11:02:46 PDT 2025
================
@@ -2336,16 +2336,9 @@ bool Type::isArithmeticType() const {
}
bool Type::hasBooleanRepresentation() const {
- if (isBooleanType())
- return true;
-
- if (const EnumType *ET = getAs<EnumType>())
- return ET->getDecl()->getIntegerType()->isBooleanType();
-
- if (const AtomicType *AT = getAs<AtomicType>())
- return AT->getValueType()->hasBooleanRepresentation();
-
- return false;
+ if (const auto *VT = dyn_cast<VectorType>(CanonicalType))
----------------
michele-scandale wrote:
I don't think referring to the how the type is lowered in IR make sense for a function in `Type`.
The overall question should be about this family of functions:
```
/// Determine whether this type has an integer representation
/// of some sort, e.g., it is an integer type or a vector.
bool hasIntegerRepresentation() const;
/// Determine whether this type has an signed integer representation
/// of some sort, e.g., it is an signed integer type or a vector.
bool hasSignedIntegerRepresentation() const;
/// Determine whether this type has an unsigned integer representation
/// of some sort, e.g., it is an unsigned integer type or a vector.
bool hasUnsignedIntegerRepresentation() const;
/// Determine whether this type has a floating-point representation
/// of some sort, e.g., it is a floating-point type or a vector thereof.
bool hasFloatingRepresentation() const;
```
In here I'm just trying to have `hasBooleanRepresentation` be consistent with those.
https://github.com/llvm/llvm-project/pull/136038
More information about the cfe-commits
mailing list