diff options
author | Timm Baeder <tbaeder@redhat.com> | 2025-07-01 15:45:50 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-01 15:45:50 +0200 |
commit | 1fe993c251966697d75123eb38fa710cdb346c8d (patch) | |
tree | 4c1b42825ed9b3a3be50c84ad67dc4b55e4bef5b /clang/lib/AST/ByteCode/Pointer.cpp | |
parent | 8cfd9b88215acd1bff339c0d4ed60d688dcbcfdd (diff) | |
download | llvm-1fe993c251966697d75123eb38fa710cdb346c8d.zip llvm-1fe993c251966697d75123eb38fa710cdb346c8d.tar.gz llvm-1fe993c251966697d75123eb38fa710cdb346c8d.tar.bz2 |
[clang][bytecode] Allocate operator new data as array (#146471)
Even if we only allocate one element, we still need to allocate it as a
single-element array. This matches what the current interpreter does.
Diffstat (limited to 'clang/lib/AST/ByteCode/Pointer.cpp')
-rw-r--r-- | clang/lib/AST/ByteCode/Pointer.cpp | 15 |
1 files changed, 2 insertions, 13 deletions
diff --git a/clang/lib/AST/ByteCode/Pointer.cpp b/clang/lib/AST/ByteCode/Pointer.cpp index f0b0384..0ad4764 100644 --- a/clang/lib/AST/ByteCode/Pointer.cpp +++ b/clang/lib/AST/ByteCode/Pointer.cpp @@ -176,19 +176,8 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const { if (const auto *VD = Desc->asValueDecl()) Base = VD; else if (const auto *E = Desc->asExpr()) { - // Create a DynamicAlloc base of the right type. - if (const auto *NewExpr = dyn_cast<CXXNewExpr>(E)) { - QualType AllocatedType; - if (NewExpr->isArray()) { - assert(Desc->isArray()); - APInt ArraySize(64, static_cast<uint64_t>(Desc->getNumElems()), - /*IsSigned=*/false); - AllocatedType = - ASTCtx.getConstantArrayType(NewExpr->getAllocatedType(), ArraySize, - nullptr, ArraySizeModifier::Normal, 0); - } else { - AllocatedType = NewExpr->getAllocatedType(); - } + if (block()->isDynamic()) { + QualType AllocatedType = getDeclPtr().getFieldDesc()->getDataType(ASTCtx); // FIXME: Suboptimal counting of dynamic allocations. Move this to Context // or InterpState? static int ReportedDynamicAllocs = 0; |