[clang] [clang][bytecode] Fix CXXConstructExpr for multidim arrays (PR #164760)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 16 22:58:05 PST 2025
================
@@ -3274,34 +3274,43 @@ bool Compiler<Emitter>::VisitCXXConstructExpr(const CXXConstructExpr *E) {
}
if (T->isArrayType()) {
- const ConstantArrayType *CAT =
- Ctx.getASTContext().getAsConstantArrayType(E->getType());
- if (!CAT)
- return false;
-
- size_t NumElems = CAT->getZExtSize();
const Function *Func = getFunction(E->getConstructor());
if (!Func)
return false;
- // FIXME(perf): We're calling the constructor once per array element here,
- // in the old intepreter we had a special-case for trivial constructors.
- for (size_t I = 0; I != NumElems; ++I) {
- if (!this->emitConstUint64(I, E))
- return false;
- if (!this->emitArrayElemPtrUint64(E))
- return false;
+ if (!this->emitDupPtr(E))
+ return false;
- // Constructor arguments.
- for (const auto *Arg : E->arguments()) {
- if (!this->visit(Arg))
- return false;
+ std::function<bool(QualType)> initArrayDimension;
+ initArrayDimension = [&](QualType T) -> bool {
+ if (!T->isArrayType()) {
+ // Constructor arguments.
+ for (const auto *Arg : E->arguments()) {
+ if (!this->visit(Arg))
----------------
tbaederr wrote:
The `return false` case is hit when direct expression evaluation fails or when we hit the size limit of the bytecode emitter. It's not tested in the here attached test case I think, but at least the expression case is tested in an existing test.
https://github.com/llvm/llvm-project/pull/164760
More information about the cfe-commits
mailing list