17#include "llvm/ADT/ArrayRef.h"
18#include "llvm/ADT/STLExtras.h"
19#include "llvm/Support/Casting.h"
31 assert(Anchor !=
nullptr);
32 assert(Anchor->Parent !=
nullptr);
33 assert(New->Parent ==
nullptr);
34 assert(New->NextSibling ==
nullptr);
35 assert(New->PreviousSibling ==
nullptr);
40 auto *
P = Anchor->getParent();
41 P->replaceChildRangeLowLevel(Anchor->getNextSibling(),
42 Anchor->getNextSibling(), New);
44 P->assertInvariants();
49 assert(Old !=
nullptr);
50 assert(Old->Parent !=
nullptr);
52 assert(New->Parent ==
nullptr);
53 assert(New->NextSibling ==
nullptr);
54 assert(New->PreviousSibling ==
nullptr);
57 New->Role = Old->Role;
61 P->assertInvariants();
67 assert(N->Parent !=
nullptr);
74 P->assertInvariants();
82 assert(S->canModify());
84 if (isa<CompoundStatement>(S->getParent())) {
86 MutationsImpl::remove(S);
90 if (isa<EmptyStatement>(S))
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Defines the clang::SourceLocation class and associated facilities.
A memory arena for syntax trees.
void assertInvariants() const
Asserts invariants on this node of the tree and its immediate children.
bool canModify() const
If this function return false, the tree cannot be modified because there is no reasonable way to prod...
const Node * getNextSibling() const
const Tree * getParent() const
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 TokenBuffer-powered token manager.
static void addAfter(syntax::Node *Anchor, syntax::Node *New, NodeRole Role)
Add a new node with a specified role.
static void remove(syntax::Node *N)
Completely remove the node from its parent.
static void replace(syntax::Node *Old, syntax::Node *New)
Replace the node, keeping the role.
NodeRole
A relation between a parent and child node, e.g.
@ Detached
A node without a parent.
syntax::EmptyStatement * createEmptyStatement(syntax::Arena &A, TokenBufferTokenManager &TBTM)
void removeStatement(syntax::Arena &A, TokenBufferTokenManager &TBTM, syntax::Statement *S)
Removes a statement or replaces it with an empty statement where one is required syntactically.
The JSON file list parser is used to communicate input to InstallAPI.