[clang] [clang] Rework `hasBooleanRepresentation`. (PR #136038)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 17 17:36:15 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))
----------------
andykaylor wrote:
@AaronBallman In case you haven't dug into the background, I move this function here from CGExpr.cpp (where it was a static function) with the goal of sharing the implementation between the LLVM IR codegen and the ClangIR codegen. It's used a couple of different ways there (and the CIR uses will be equivalent), but I think "will this end up as an i1" is a fair summary.
I just moved the function without changing it in any other way. However, that created the potential problem that it might not have been doing what people familiar with the other has*Representation functions would expect, so the question of consistency, or at least congruency, comes into play for people who weren't already using the function.
https://github.com/llvm/llvm-project/pull/136038
More information about the cfe-commits
mailing list