[clang] [clang][bytecode] Allocate operator new data as array (PR #146471)
Shafik Yaghmour via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 8 15:17:53 PDT 2025
================
@@ -1531,34 +1531,21 @@ static bool interp__builtin_operator_new(InterpState &S, CodePtr OpPC,
std::optional<PrimType> ElemT = S.getContext().classify(ElemType);
DynamicAllocator &Allocator = S.getAllocator();
if (ElemT) {
- if (IsArray) {
- Block *B = Allocator.allocate(NewCall, *ElemT, NumElems.getZExtValue(),
- S.Ctx.getEvalID(),
- DynamicAllocator::Form::Operator);
- assert(B);
- S.Stk.push<Pointer>(Pointer(B).atIndex(0));
- return true;
- }
-
- const Descriptor *Desc = S.P.createDescriptor(
- NewCall, *ElemT, ElemType.getTypePtr(), Descriptor::InlineDescMD,
- /*IsConst=*/false, /*IsTemporary=*/false,
- /*IsMutable=*/false);
- Block *B = Allocator.allocate(Desc, S.getContext().getEvalID(),
- DynamicAllocator::Form::Operator);
+ Block *B =
+ Allocator.allocate(NewCall, *ElemT, NumElems.getZExtValue(),
+ S.Ctx.getEvalID(), DynamicAllocator::Form::Operator);
assert(B);
-
- S.Stk.push<Pointer>(B);
+ S.Stk.push<Pointer>(Pointer(B).atIndex(0));
return true;
}
assert(!ElemT);
- // Structs etc.
- const Descriptor *Desc =
- S.P.createDescriptor(NewCall, ElemType.getTypePtr(),
- IsArray ? std::nullopt : Descriptor::InlineDescMD);
+ // Composite arrays
if (IsArray) {
+ const Descriptor *Desc =
+ S.P.createDescriptor(NewCall, ElemType.getTypePtr(),
+ IsArray ? std::nullopt : Descriptor::InlineDescMD);
----------------
shafik wrote:
This is in the `if (IsArray)` block so `IsArray` has to be `true`
https://github.com/llvm/llvm-project/pull/146471
More information about the cfe-commits
mailing list