[PATCH] D133753: [clang][Interp] WIP: Array fillers
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 14 03:59:41 PDT 2022
tbaeder added inline comments.
================
Comment at: clang/lib/AST/Interp/Context.cpp:54
+ assert(Stk.empty());
+ return true;
}
----------------
The additional asserts I inserted here could be in another patch. However, I added them because I ran into a peculiar problem: when creating a `Pointer`, it calls `Pointee->addPointer(this)`. It will only remove itself from the pointee again in its destructor. //But// the destructor is not (necessarily) being called at all because the `Pointer` is constructed in the stack (or otherwise placement-new'ed into a larger memory region).
================
Comment at: clang/lib/AST/Interp/Interp.h:832
+ _B->invokeCtor();
+
+ memcpy(_B->data(), Pointee->data(), Desc->getAllocSize());
----------------
Note here that both the block and the descriptor are leaked. They are usually allocated in `Program`, which uses its own allocator for them. I'm not 100% sure what to do about this, since the blocks have different lifetimes depending on if they are for global or local variables (or parameters).
Short of introducing a `Program::managesBlock(Block* B)` that just does a linear search for the blocks.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133753/new/
https://reviews.llvm.org/D133753
More information about the cfe-commits
mailing list