struct TreeBuilder::Forest

Declaration

struct TreeBuilder::Forest { /* full declaration omitted */ };

Description

A collection of trees covering the input tokens. When created, each tree corresponds to a single token in the file. Clients call 'foldChildren' to attach one or more subtrees to a parent node and update the list of trees accordingly. Ensures that added nodes properly nest and cover the whole token stream.

Declared at: clang/lib/Tooling/Syntax/BuildTree.cpp:570

Member Variables

private std::map<const syntax::Token*, syntax::Node*> Trees
Maps from the start token to a subtree starting at that token. Keys in the map are pointers into the array of expanded tokens, so pointer order corresponds to the order of preprocessor tokens.

Method Overview

  • public Forest(syntax::Arena & A, const syntax::TokenBuffer & TB)
  • public void assignRole(ArrayRef<syntax::Token> Range, syntax::NodeRole Role)
  • public syntax::Node * finalize() &&
  • public void foldChildren(const syntax::TokenBuffer & TB, ArrayRef<syntax::Token> Tokens, syntax::Tree * Node)
  • public ArrayRef<syntax::Token> shrinkToFitList(ArrayRef<syntax::Token> Range)
  • public std::string str(const syntax::TokenBufferTokenManager & STM) const

Methods

Forest(syntax::Arena& A,
       const syntax::TokenBuffer& TB)

Declared at: clang/lib/Tooling/Syntax/BuildTree.cpp:571

Parameters

syntax::Arena& A
const syntax::TokenBuffer& TB

void assignRole(ArrayRef<syntax::Token> Range,
                syntax::NodeRole Role)

Declared at: clang/lib/Tooling/Syntax/BuildTree.cpp:585

Parameters

ArrayRef<syntax::Token> Range
syntax::NodeRole Role

syntax::Node* finalize() &&

Declared at: clang/lib/Tooling/Syntax/BuildTree.cpp:661

void foldChildren(const syntax::TokenBuffer& TB,
                  ArrayRef<syntax::Token> Tokens,
                  syntax::Tree* Node)

Description

Add \p Node to the forest and attach child nodes based on \p Tokens.

Declared at: clang/lib/Tooling/Syntax/BuildTree.cpp:628

Parameters

const syntax::TokenBuffer& TB
ArrayRef<syntax::Token> Tokens
syntax::Tree* Node

ArrayRef<syntax::Token> shrinkToFitList(
    ArrayRef<syntax::Token> Range)

Description

Shrink \p Range to a subrange that only contains tokens of a list. List elements and delimiters should already have correct roles.

Declared at: clang/lib/Tooling/Syntax/BuildTree.cpp:600

Parameters

ArrayRef<syntax::Token> Range

std::string str(
    const syntax::TokenBufferTokenManager& STM)
    const

Declared at: clang/lib/Tooling/Syntax/BuildTree.cpp:668

Parameters

const syntax::TokenBufferTokenManager& STM