class Node

Declaration

class Node { /* full declaration omitted */ };

Description

A node in a syntax tree. Each node is either a Leaf (representing tokens) or a Tree (representing language constructrs).

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:54

Member Variables

private clang::syntax::Tree* Parent
private clang::syntax::Node* NextSibling
private clang::syntax::Node* PreviousSibling
private unsigned int Kind
private unsigned int Role
private unsigned int Original
private unsigned int CanModify

Method Overview

Methods

Node(clang::syntax::NodeKind Kind)

Description

Newly created nodes are detached from a tree, parent and sibling links are set when the node is added as a child to another one.

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:58

Parameters

clang::syntax::NodeKind Kind

Node(const clang::syntax::Node&)

Description

Nodes cannot simply be copied without violating tree invariants.

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:64

Parameters

const clang::syntax::Node&

Node(clang::syntax::Node&&)

Description

Idiomatically, nodes are allocated on an Arena and never moved.

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:67

Parameters

clang::syntax::Node&&

void assertInvariants() const

Description

Asserts invariants on this node of the tree and its immediate children. Will not recurse into the subtree. No-op if NDEBUG is set.

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:105

void assertInvariantsRecursive() const

Description

Runs checkInvariants on all nodes in the subtree. No-op if NDEBUG is set.

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:107

bool canModify() const

Description

If this function return false, the tree cannot be modified because there is no reasonable way to produce the corresponding textual replacements. This can happen when the node crosses macro expansion boundaries. Note that even if the node is not modifiable, its child nodes can be modifiable.

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:88

std::string dump(
    const clang::syntax::TokenManager& SM) const

Description

Dumps the structure of a subtree. For debugging and testing purposes.

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:99

Parameters

const clang::syntax::TokenManager& SM

std::string dumpTokens(
    const clang::syntax::TokenManager& SM) const

Description

Dumps the tokens forming this subtree.

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:101

Parameters

const clang::syntax::TokenManager& SM

clang::syntax::NodeKind getKind() const

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:70

const clang::syntax::Node* getNextSibling() const

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:93

clang::syntax::Node* getNextSibling()

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:94

const clang::syntax::Tree* getParent() const

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:90

clang::syntax::Tree* getParent()

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:91

const clang::syntax::Node* getPreviousSibling()
    const

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:95

clang::syntax::Node* getPreviousSibling()

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:96

clang::syntax::NodeRole getRole() const

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:71

bool isDetached() const

Description

Whether the node is detached from a tree, i.e. does not have a parent.

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:74

bool isOriginal() const

Description

Whether the node was created from the AST backed by the source code rather than added later through mutation APIs or created with factory functions. When this flag is true, all subtrees are also original. This flag is set to false on any modifications to the node or any of its subtrees, even if this simply involves swapping existing subtrees.

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:81

void setRole(clang::syntax::NodeRole NR)

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:119

Parameters

clang::syntax::NodeRole NR

~Node()

Description

Nodes are allocated on Arenas; the destructor is never called.

Declared at: clang/include/clang/Tooling/Syntax/Tree.h:60