Go to the documentation of this file.
17 #include "llvm/ADT/ArrayRef.h"
18 #include "llvm/ADT/Optional.h"
19 #include "llvm/ADT/STLExtras.h"
20 #include "llvm/Support/Casting.h"
24 using namespace clang;
32 assert(Anchor !=
nullptr);
33 assert(Anchor->Parent !=
nullptr);
34 assert(New->Parent ==
nullptr);
35 assert(New->NextSibling ==
nullptr);
36 assert(New->PreviousSibling ==
nullptr);
45 P->assertInvariants();
50 assert(Old !=
nullptr);
51 assert(Old->Parent !=
nullptr);
53 assert(New->Parent ==
nullptr);
54 assert(New->NextSibling ==
nullptr);
55 assert(New->PreviousSibling ==
nullptr);
58 New->Role = Old->Role;
62 P->assertInvariants();
68 assert(N->Parent !=
nullptr);
75 P->assertInvariants();
82 assert(S->canModify());
84 if (isa<CompoundStatement>(S->getParent())) {
90 if (isa<EmptyStatement>(S))
const Tree * getParent() const
@ Detached
A node without a parent.
bool canModify() const
If this function return false, the tree cannot be modified because there is no reasonable way to prod...
static void addAfter(syntax::Node *Anchor, syntax::Node *New, NodeRole Role)
Add a new node with a specified role.
bool isDetached() const
Whether the node is detached from a tree, i.e. does not have a parent.
static void replace(syntax::Node *Old, syntax::Node *New)
Replace the node, keeping the role.
void removeStatement(syntax::Arena &A, syntax::Statement *S)
Removes a statement or replaces it with an empty statement where one is required syntactically.
static void remove(syntax::Node *N)
Completely remove the node from its parent.
A memory arena for syntax trees.
syntax::EmptyStatement * createEmptyStatement(syntax::Arena &A)
NodeRole
A relation between a parent and child node, e.g.
const Node * getNextSibling() const
void assertInvariants() const
Asserts invariants on this node of the tree and its immediate children.
An abstract node for C++ statements, e.g.