[clang] [Clang] Support generic bit counting builtins on fixed boolean vectors (PR #154203)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 21 20:10:34 PDT 2025


================
@@ -141,6 +141,22 @@ static void diagnoseNonConstexprBuiltin(InterpState &S, CodePtr OpPC,
     S.CCEDiag(Loc, diag::note_invalid_subexpr_in_const_expr);
 }
 
+static llvm::APSInt convertBoolVectorToInt(const Pointer &Val) {
+  assert(Val.getFieldDesc()->isPrimitiveArray() &&
+         Val.getFieldDesc()->getElemQualType()->isBooleanType() &&
+         "Not a boolean vector");
+  unsigned NumElts = Val.getNumElems();
+
+  // Each element is one bit, so create an integer with NumElts bits.
+  llvm::APSInt Result(NumElts, 0);
+  for (unsigned I = 0; I < NumElts; ++I) {
----------------
tbaederr wrote:

```suggestion
  for (unsigned I = 0; I != NumElts; ++I) {
```

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


More information about the cfe-commits mailing list