Skip to content

Commit 163ad9f

Browse files
tbaederrAlexisPerry
authored andcommitted
[clang][Interp][NFC] Destroy InitMap when moving contents to DeadBlock
1 parent 5672a7c commit 163ad9f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

clang/lib/AST/Interp/Descriptor.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,14 @@ static void dtorArrayTy(Block *, std::byte *Ptr, const Descriptor *D) {
6464
template <typename T>
6565
static void moveArrayTy(Block *, const std::byte *Src, std::byte *Dst,
6666
const Descriptor *D) {
67-
// FIXME: Need to copy the InitMap?
67+
// FIXME: Get rid of the const_cast.
68+
InitMapPtr &SrcIMP =
69+
*reinterpret_cast<InitMapPtr *>(const_cast<std::byte *>(Src));
70+
if (SrcIMP) {
71+
// We only ever invoke the moveFunc when moving block contents to a
72+
// DeadBlock. DeadBlocks don't need InitMaps, so we destroy them here.
73+
SrcIMP = std::nullopt;
74+
}
6875
Src += sizeof(InitMapPtr);
6976
Dst += sizeof(InitMapPtr);
7077
for (unsigned I = 0, NE = D->getNumElems(); I < NE; ++I) {

0 commit comments

Comments
 (0)