[clang] [Clang][OpenMP] Fix crashes on a `braced-init-list` in the `init` or increment of a loop (PR #233248)

Akash Manna via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 31 09:59:19 PDT 2026


================
@@ -6033,6 +6033,26 @@ static QualType getIntTypeForBitwidthOrBitInt(ASTContext &C, unsigned Bits,
   return Ty;
 }
 
+static Expr *buildInitListValue(Sema &SemaRef, Expr *E) {
+  auto *ILE = dyn_cast<InitListExpr>(E);
+  if (!ILE)
+    return E;
+  if (ILE->isTransparent())
+    return buildInitListValue(SemaRef, ILE->getInit(0));
+  ASTContext &Context = SemaRef.Context;
+  QualType Ty = ILE->getType();
+  bool IsEmptyScalar = ILE->getNumInits() == 0 && Ty->isScalarType();
+  if (!SemaRef.getLangOpts().CPlusPlus)
+    return IsEmptyScalar ? new (Context) ImplicitValueInitExpr(Ty) : E;
+  if (!IsEmptyScalar && !Ty->isRecordType())
+    return E;
+  return CXXFunctionalCastExpr::Create(
+      Context, Ty, VK_PRValue,
+      Context.getTrivialTypeSourceInfo(Ty, ILE->getLBraceLoc()), CK_NoOp, ILE,
+      /*Path=*/nullptr, SemaRef.CurFPFeatureOverrides(), SourceLocation(),
+      SourceLocation());
----------------
akash-manna-sky wrote:

I replaced it by `BuildCXXTypeConstructExpr` form Sema, on a copy of the syntactic list. A plain implicit conversion of a list returns a list. 


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


More information about the cfe-commits mailing list