[clang] [clang][ExprConst] Check for array size of initlists (PR #138673)

via cfe-commits cfe-commits at lists.llvm.org
Wed May 7 05:18:30 PDT 2025


================
@@ -11919,6 +11924,11 @@ bool ArrayExprEvaluator::VisitCXXConstructExpr(const CXXConstructExpr *E,
   if (const ConstantArrayType *CAT = Info.Ctx.getAsConstantArrayType(Type)) {
     unsigned FinalSize = CAT->getZExtSize();
 
+    if (!Info.CheckArraySize(E->getExprLoc(),
+                             CAT->getNumAddressingBits(Info.Ctx), FinalSize,
+                             /*Diag=*/true))
----------------
Sirraide wrote:

I think there’s also a helper that takes the CAT and calls `getZExtSize` and `getNumAddressingBits` for you.

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


More information about the cfe-commits mailing list