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(New->Parent ==
nullptr);
34 assert(New->NextSibling ==
nullptr);
38 New->Role =
static_cast<unsigned>(Role);
40 P->replaceChildRangeLowLevel(Anchor, Anchor, New);
42 P->assertInvariants();
47 assert(Old !=
nullptr);
48 assert(Old->Parent !=
nullptr);
50 assert(New->Parent ==
nullptr);
51 assert(New->NextSibling ==
nullptr);
54 New->Role = Old->Role;
56 P->replaceChildRangeLowLevel(findPrevious(Old), Old->
nextSibling(), New);
58 P->assertInvariants();
63 auto *
P = N->parent();
64 P->replaceChildRangeLowLevel(findPrevious(N), N->nextSibling(),
67 P->assertInvariants();
68 N->assertInvariants();
76 C = C->nextSibling()) {
77 if (C->nextSibling() == N)
80 llvm_unreachable(
"could not find a child node");
88 if (isa<CompoundStatement>(S->
parent())) {
94 if (isa<EmptyStatement>(S))
static void addAfter(syntax::Node *Anchor, syntax::Node *New, NodeRole Role)
Add a new node with a specified role.
void removeStatement(syntax::Arena &A, syntax::Statement *S)
Removes a statement or replaces it with an empty statement where one is required syntactically.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified...
static void replace(syntax::Node *Old, syntax::Node *New)
Replace the node, keeping the role.
bool isDetached() const
Whether the node is detached from a tree, i.e. does not have a parent.
An abstract node for C++ statements, e.g.
A memory arena for syntax trees.
bool canModify() const
If this function return false, the tree cannot be modified because there is no reasonable way to prod...
static void remove(syntax::Node *N)
Completely remove the node from its parent.
const Node * nextSibling() const
clang::syntax::EmptyStatement * createEmptyStatement(clang::syntax::Arena &A)
const Tree * parent() const
NodeRole
A relation between a parent and child node, e.g.
Dataflow Directional Tag Classes.
Defines the clang::SourceLocation class and associated facilities.