[clang] [clang][AST] Treat unsigned _BitInt(1) as boolean-valued (PR #195793)

Yanzuo Liu via cfe-commits cfe-commits at lists.llvm.org
Tue May 5 07:19:33 PDT 2026


================
@@ -142,6 +142,11 @@ bool Expr::isKnownToHaveBooleanValue(bool Semantic) const {
   // If this is a non-scalar-integer type, we don't care enough to try.
   if (!E->getType()->isIntegralOrEnumerationType()) return false;
 
+  if (!Semantic)
+    if (const auto *BIT = E->getType()->getAs<BitIntType>())
+      if (BIT->isUnsigned() && BIT->getNumBits() == 1)
----------------
zwuis wrote:

```cpp
if (const auto *BIT = ...;
    BIT && ...)
```

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


More information about the cfe-commits mailing list