1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 14:48:14 +00:00

JSSpecCompiler: Restrict usage of NodeSubtreePointer

This class stores a non-owning raw pointer to a member of `Node`, so
extra care is needed to ensure that referenced `Node`s will be alive
by the time `NodeSubtreePointer` is used. Since we only need to use this
class while traversing AST in `RecursiveASTVisitor`, access to class
methods can be restricted using `Badge<RecursiveASTVisitor>`.
This commit is contained in:
Dan Klishch 2023-09-02 14:33:35 -04:00 committed by Andrew Kaster
parent f789d26e37
commit 1c4cd34320
3 changed files with 8 additions and 4 deletions

View file

@ -18,7 +18,7 @@ void RecursiveASTVisitor::run_in_subtree(Tree& tree)
void RecursiveASTVisitor::replace_current_node_with(Tree tree)
{
m_current_subtree_pointer->replace_subtree(move(tree));
m_current_subtree_pointer->replace_subtree({}, move(tree));
}
RecursionDecision RecursiveASTVisitor::recurse(Tree root, NodeSubtreePointer& pointer)
@ -30,7 +30,7 @@ RecursionDecision RecursiveASTVisitor::recurse(Tree root, NodeSubtreePointer& po
if (decision == RecursionDecision::Recurse) {
for (auto& child : root->subtrees()) {
if (recurse(child.get(), child) == RecursionDecision::Break)
if (recurse(child.get({}), child) == RecursionDecision::Break)
return RecursionDecision::Break;
}
}