Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions clang/lib/AST/ByteCode/InterpBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ bool Block::hasPointer(const Pointer *P) const {
}
#endif

void Block::movePointersTo(Block *B) {
assert(B != this);

while (Pointers) {
Pointer *P = Pointers;

this->removePointer(P);
P->BS.Pointee = B;
B->addPointer(P);
}
assert(!this->hasPointers());
}

DeadBlock::DeadBlock(DeadBlock *&Root, Block *Blk)
: Root(Root), B(~0u, Blk->Desc, Blk->isExtern(), Blk->IsStatic,
Blk->isWeak(), Blk->isDummy(), /*IsDead=*/true) {
Expand Down
2 changes: 2 additions & 0 deletions clang/lib/AST/ByteCode/InterpBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ class Block final {
bool isInitialized() const { return IsInitialized; }
/// The Evaluation ID this block was created in.
unsigned getEvalID() const { return EvalID; }
/// Move all pointers from this block to \param B.
void movePointersTo(Block *B);

/// Returns a pointer to the stored data.
/// You are allowed to read Desc->getSize() bytes from this address.
Expand Down
6 changes: 1 addition & 5 deletions clang/lib/AST/ByteCode/Program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,7 @@ UnsignedOrNone Program::createGlobal(const ValueDecl *VD, const Expr *Init) {
Globals[PIdx] = NewGlobal;
// All pointers pointing to the previous extern decl now point to the
// new decl.
for (Pointer *Ptr = RedeclBlock->Pointers; Ptr; Ptr = Ptr->BS.Next) {
RedeclBlock->removePointer(Ptr);
Ptr->BS.Pointee = NewGlobal->block();
NewGlobal->block()->addPointer(Ptr);
}
RedeclBlock->movePointersTo(NewGlobal->block());
}
}
PIdx = *Idx;
Expand Down