[all-commits] [llvm/llvm-project] eff57e: [clang][CodeGen] Fix assertion failure with #embed...
Akash Manna via All-commits
all-commits at lists.llvm.org
Wed Sep 9 09:49:17 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: eff57ef78633c2eff5ae2cb7e4fa8e11e14d4b46
https://github.com/llvm/llvm-project/commit/eff57ef78633c2eff5ae2cb7e4fa8e11e14d4b46
Author: Akash Manna <akash.manna.mymail at gmail.com>
Date: 2026-09-09 (Wed, 09 Sep 2026)
Changed paths:
M clang/docs/ReleaseNotes.md
M clang/include/clang/AST/Expr.h
M clang/lib/CodeGen/CGExprCXX.cpp
M clang/lib/Sema/SemaInit.cpp
A clang/test/CodeGenCXX/GH128985.cpp
A clang/test/CodeGenCXX/Inputs/embed-data.txt
A clang/test/SemaCXX/GH128985.cpp
Log Message:
-----------
[clang][CodeGen] Fix assertion failure with #embed in array new-expression initializers (#218262)
Fixes #128985
An `EmbedExpr` in a semantic initializer list can represent many array
elements at once, and every consumer of such lists has to expand it. The
array `new` emitter, `EmitNewArrayInitializer`, never did: it counted
the `EmbedExpr` as one element and emitted it through the scalar path,
hitting `assert(E->getDataElementCount() == 1)`. The undercount also
made the runtime minimum allocation check too lax and miscomputed the
trailing zero-fill size.
`Codegen` now emits one store per embed data element, converted to the
element type, and counts initializers with
`getNumInitsWithEmbedExpanded()` in both places. That helper also
learned to look through implicit casts, since Sema wraps a multi-element
`EmbedExpr` in a conversion when the element type isn't `int` — the
other embed consumers already strip casts before checking.
LLM tools were used for this contribution. I've reviewed, built, and
tested the change myself before pushing to GitHub.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list