clang  10.0.0svn
Classes | Enumerations | Functions
clang::syntax Namespace Reference

Classes

class  Arena
 A memory arena for syntax trees. More...
 
class  CompoundStatement
 { statement1; statement2; … } More...
 
struct  FileRange
 A half-open character range inside a particular file, the start offset is included and the end offset is excluded from the range. More...
 
class  Leaf
 A leaf node points to a single token inside the expanded token stream. More...
 
class  Node
 A node in a syntax tree. More...
 
class  Statement
 An abstract node for C++ statements, e.g. 'while', 'if', etc. More...
 
class  Token
 A token coming directly from a file or from a macro invocation. More...
 
class  TokenBuffer
 A list of tokens obtained by preprocessing a text buffer and operations to map between the expanded and spelled tokens, i.e. More...
 
class  TokenCollector
 Collects tokens for the main file while running the frontend action. More...
 
class  TopLevelDeclaration
 FIXME: this node is temporary and will be replaced with nodes for various 'declarations' and 'declarators' from the C/C++ grammar. More...
 
class  TranslationUnit
 A root node for a translation unit. Parent is always null. More...
 
class  Tree
 A node that has children and represents a syntactic language construct. More...
 
class  TreeBuilder
 A helper class for constructing the syntax tree while traversing a clang AST. More...
 

Enumerations

enum  NodeKind : uint16_t { NodeKind::Leaf, NodeKind::TranslationUnit, NodeKind::TopLevelDeclaration, NodeKind::CompoundStatement }
 A kind of a syntax node, used for implementing casts. More...
 
enum  NodeRole : uint8_t { NodeRole::Detached, NodeRole::Unknown, NodeRole::CompoundStatement_lbrace, NodeRole::CompoundStatement_rbrace }
 A relation between a parent and child node. Used for implementing accessors. More...
 

Functions

syntax::TranslationUnitbuildSyntaxTree (Arena &A, const clang::TranslationUnitDecl &TU)
 Build a syntax tree for the main file. More...
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &OS, NodeKind K)
 For debugging purposes. More...
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &OS, const FileRange &R)
 For debugging purposes. More...
 
llvm::raw_ostream & operator<< (llvm::raw_ostream &OS, const Token &T)
 For debugging purposes. Equivalent to a call to Token::str(). More...
 
std::vector< syntax::Tokentokenize (FileID FID, const SourceManager &SM, const LangOptions &LO)
 Lex the text buffer, corresponding to FID, in raw mode and record the resulting spelled tokens. More...
 

Enumeration Type Documentation

◆ NodeKind

enum clang::syntax::NodeKind : uint16_t
strong

A kind of a syntax node, used for implementing casts.

Enumerator
Leaf 
TranslationUnit 
TopLevelDeclaration 
CompoundStatement 

Definition at line 25 of file Nodes.h.

◆ NodeRole

enum clang::syntax::NodeRole : uint8_t
strong

A relation between a parent and child node. Used for implementing accessors.

Enumerator
Detached 
Unknown 
CompoundStatement_lbrace 
CompoundStatement_rbrace 

Definition at line 35 of file Nodes.h.

Function Documentation

◆ buildSyntaxTree()

syntax::TranslationUnit * clang::syntax::buildSyntaxTree ( Arena A,
const clang::TranslationUnitDecl TU 
)

Build a syntax tree for the main file.

Definition at line 273 of file BuildTree.cpp.

◆ operator<<() [1/3]

llvm::raw_ostream & clang::syntax::operator<< ( llvm::raw_ostream &  OS,
NodeKind  K 
)

For debugging purposes.

Definition at line 13 of file Nodes.cpp.

Referenced by clang::syntax::Token::length().

◆ operator<<() [2/3]

llvm::raw_ostream & clang::syntax::operator<< ( llvm::raw_ostream &  OS,
const FileRange R 
)

◆ operator<<() [3/3]

llvm::raw_ostream & clang::syntax::operator<< ( llvm::raw_ostream &  OS,
const Token T 
)

For debugging purposes. Equivalent to a call to Token::str().

Definition at line 74 of file Tokens.cpp.

References clang::syntax::Token::str().

◆ tokenize()

std::vector< syntax::Token > clang::syntax::tokenize ( FileID  FID,
const SourceManager SM,
const LangOptions LO 
)

Lex the text buffer, corresponding to FID, in raw mode and record the resulting spelled tokens.

Does minimal post-processing on raw identifiers, setting the appropriate token kind (instead of the raw_identifier reported by lexer in raw mode). This is a very low-level function, most users should prefer to use TokenCollector. Lexing in raw mode produces wildly different results from what one might expect when running a C++ frontend, e.g. preprocessor does not run at all. The result will not have a 'eof' token at the end.

Definition at line 250 of file Tokens.cpp.

Referenced by TokenCollector::Builder::build(), and clang::syntax::Arena::lexBuffer().