clang: clang::syntax Namespace Reference (original) (raw)
Classes | |
---|---|
class | Arena |
A memory arena for syntax trees. More... | |
class | ArraySubscript |
Array size specified inside a declarator. More... | |
class | BinaryOperatorExpression |
More... | |
class | BreakStatement |
break; More... | |
class | CallArguments |
Models arguments of a function call. More... | |
class | CaseStatement |
case : More... | |
class | CompoundStatement |
{ statement1; statement2; … } More... | |
class | ContinueStatement |
continue; More... | |
class | Declaration |
A declaration that can appear at the top-level. More... | |
class | DeclarationStatement |
E.g. 'int a, b = 10;'. More... | |
class | Declarator |
Covers a name, an initializer and a part of the type outside declaration specifiers. More... | |
class | DeclaratorList |
class | DefaultStatement |
default: More... | |
class | EmptyDeclaration |
A semicolon in the top-level context. Does not declare anything. More... | |
class | EmptyStatement |
The no-op statement, i.e. ';'. More... | |
class | ExplicitTemplateInstantiation |
template Examples: template struct X template void foo() template int var More... | |
class | ExpressionStatement |
Expression in a statement position, e.g. More... | |
class | FactoryImpl |
Exposes private syntax tree APIs required to implement node synthesis. 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 | ForStatement |
for (; ; ) More... | |
class | IfStatement |
if (cond) else FIXME: add condition that models 'expression or variable declaration' More... | |
class | Leaf |
A leaf node points to a single token. More... | |
class | LinkageSpecificationDeclaration |
extern declaration extern { } More... | |
class | List |
A list of Elements separated or terminated by a fixed token. More... | |
class | MemberPointer |
Member pointer inside a declarator E.g. More... | |
class | MutationsImpl |
class | NamespaceAliasDefinition |
namespace = More... | |
class | NamespaceDefinition |
namespace { } More... | |
class | NestedNameSpecifier |
Models a nested-name-specifier. More... | |
class | Node |
A node in a syntax tree. More... | |
class | ParameterDeclarationList |
Models a parameter-declaration-list which appears within parameters-and-qualifiers. More... | |
class | ParametersAndQualifiers |
Parameter list for a function type and a trailing return type, if the function has one. More... | |
class | ParenDeclarator |
Declarator inside parentheses. More... | |
class | PostfixUnaryOperatorExpression |
More... | |
class | PrefixUnaryOperatorExpression |
More... | |
class | RangeBasedForStatement |
for ( : ) More... | |
class | ReturnStatement |
return ; return; More... | |
class | SimpleDeclaration |
Groups multiple declarators (e.g. More... | |
class | SimpleDeclarator |
A top-level declarator without parentheses. More... | |
class | Statement |
An abstract node for C++ statements, e.g. More... | |
class | StaticAssertDeclaration |
static_assert(, ) static_assert() More... | |
class | SwitchStatement |
switch () More... | |
class | TemplateDeclaration |
template 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 | TokenBufferTokenManager |
A TokenBuffer-powered token manager. More... | |
class | TokenCollector |
Collects tokens for the main file while running the frontend action. More... | |
class | TokenManager |
Defines interfaces for operating "Token" in the clang syntax-tree. More... | |
class | TrailingReturnType |
Trailing return type after the parameter list, including the arrow token. 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... | |
class | TypeAliasDeclaration |
using = More... | |
class | UnaryOperatorExpression |
An abstract class for prefix and postfix unary operators. More... | |
class | UnknownDeclaration |
Declaration of an unknown kind, e.g. not yet supported in syntax trees. More... | |
class | UnknownExpression |
An expression of an unknown kind, i.e. More... | |
class | UnknownStatement |
A statement of an unknown kind, i.e. More... | |
class | UnqualifiedId |
Models an unqualified-id. More... | |
class | UsingDeclaration |
using :: using typename :: More... | |
class | UsingNamespaceDirective |
using namespace More... | |
class | WhileStatement |
while () More... | |
Enumerations | |
---|---|
enum class | NodeKind : uint16_t { CONCRETE_NODE } |
A kind of a syntax node, used for implementing casts. More... | |
enum class | NodeRole : uint8_t { Detached, Unknown, OpenParen, CloseParen, IntroducerKeyword, LiteralToken, ArrowToken, ExternKeyword, TemplateKeyword, BodyStatement, ListElement, ListDelimiter, OperatorToken, Operand, LeftHandSide, RightHandSide, ReturnValue, CaseValue, ThenStatement, ElseKeyword, ElseStatement, Expression, Statement, Condition, Message, Declarator, Declaration, Size, Parameters, TrailingReturn, UnqualifiedId, Qualifier, SubExpression, Object, AccessToken, Member, Callee, Arguments, Declarators } |
A relation between a parent and child node, e.g. More... | |
Functions | |
---|---|
syntax::TranslationUnit * | buildSyntaxTree (Arena &A, TokenBufferTokenManager &TBTM, ASTContext &Context) |
Build a syntax tree for the main file. | |
syntax::Leaf * | createLeaf (syntax::Arena &A, TokenBufferTokenManager &TBTM, tok::TokenKind K, StringRef Spelling) |
Create Leaf from token with Spelling and assert it has the desired TokenKind. | |
syntax::Leaf * | createLeaf (syntax::Arena &A, TokenBufferTokenManager &TBTM, tok::TokenKind K) |
Infer the token spelling from its TokenKind, then create Leaf from this token. | |
syntax::Tree * | createTree (syntax::Arena &A, ArrayRef< std::pair< syntax::Node *, syntax::NodeRole > > Children, syntax::NodeKind K) |
Creates the concrete syntax node according to the specified NodeKind K. | |
syntax::EmptyStatement * | createEmptyStatement (syntax::Arena &A, TokenBufferTokenManager &TBTM) |
syntax::Node * | deepCopyExpandingMacros (syntax::Arena &A, TokenBufferTokenManager &TBTM, const syntax::Node *N) |
Creates a completely independent copy of N with its macros expanded. | |
tooling::Replacements | computeReplacements (const TokenBufferTokenManager &TBTM, const syntax::TranslationUnit &TU) |
Computes textual replacements required to mimic the tree modifications made to the syntax tree. | |
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. | |
raw_ostream & | operator<< (raw_ostream &OS, NodeKind K) |
For debugging purposes. | |
raw_ostream & | operator<< (raw_ostream &OS, NodeRole R) |
For debugging purposes. | |
llvm::raw_ostream & | operator<< (llvm::raw_ostream &OS, const FileRange &R) |
For debugging purposes. | |
llvm::raw_ostream & | operator<< (llvm::raw_ostream &OS, const Token &T) |
For debugging purposes. Equivalent to a call to Token::str(). | |
llvm::ArrayRef< syntax::Token > | spelledTokensTouching (SourceLocation Loc, const syntax::TokenBuffer &Tokens) |
The spelled tokens that overlap or touch a spelling location Loc. | |
llvm::ArrayRef< syntax::Token > | spelledTokensTouching (SourceLocation Loc, llvm::ArrayRef< syntax::Token > Tokens) |
const syntax::Token * | spelledIdentifierTouching (SourceLocation Loc, llvm::ArrayRef< syntax::Token > Tokens) |
The identifier token that overlaps or touches a spelling location Loc. | |
const syntax::Token * | spelledIdentifierTouching (SourceLocation Loc, const syntax::TokenBuffer &Tokens) |
std::vector< syntax::Token > | 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. | |
std::vector< syntax::Token > | tokenize (const FileRange &FR, const SourceManager &SM, const LangOptions &LO) |
Similar to one above, instead of whole file tokenizes a part of it. | |
◆ NodeKind
A kind of a syntax node, used for implementing casts.
The ordering and blocks of enumerator constants must correspond to the inheritance hierarchy of syntax::Node.
Enumerator |
---|
CONCRETE_NODE |
Definition at line 32 of file Nodes.h.
◆ NodeRole
A relation between a parent and child node, e.g.
'left-hand-side of a binary expression'. Used for implementing accessors.
In general NodeRole
s should be named the same as their accessors.
Some roles describe parent/child relations that occur multiple times in language grammar. We define only one role to describe all instances of such recurring relations. For example, grammar for both "if" and "while" statements requires an opening paren and a closing paren. The opening paren token is assigned the OpenParen role regardless of whether it appears as a child of IfStatement or WhileStatement node. More generally, when grammar requires a certain fixed token (like a specific keyword, or an opening paren), we define a role for this token and use it across all grammar rules with the same requirement. Names of such reusable roles end with a ~Token or a ~Keyword suffix.
Enumerator | |
---|---|
Detached | A node without a parent. |
Unknown | Children of an unknown semantic nature, e.g. skipped tokens, comments. |
OpenParen | An opening parenthesis in argument lists and blocks, e.g. '{', '(', etc. |
CloseParen | A closing parenthesis in argument lists and blocks, e.g. '}', ')', etc. |
IntroducerKeyword | A keywords that introduces some grammar construct, e.g. 'if', 'try', etc. |
LiteralToken | A token that represents a literal, e.g. 'nullptr', '1', 'true', etc. |
ArrowToken | Tokens or Keywords. |
ExternKeyword | |
TemplateKeyword | |
BodyStatement | An inner statement for those that have only a single child of kind statement, e.g. loop body for while, for, etc; inner statement for case, default, etc. |
ListElement | List API roles. |
ListDelimiter | |
OperatorToken | |
Operand | |
LeftHandSide | |
RightHandSide | |
ReturnValue | |
CaseValue | |
ThenStatement | |
ElseKeyword | |
ElseStatement | |
Expression | |
Statement | |
Condition | |
Message | |
Declarator | |
Declaration | |
Size | |
Parameters | |
TrailingReturn | |
UnqualifiedId | |
Qualifier | |
SubExpression | |
Object | |
AccessToken | |
Member | |
Callee | |
Arguments | |
Declarators |
Definition at line 54 of file Nodes.h.
◆ buildSyntaxTree()
◆ computeReplacements()
◆ createEmptyStatement()
◆ createLeaf() [1/2]
◆ createLeaf() [2/2]
◆ createTree()
◆ deepCopyExpandingMacros()
◆ operator<<() [1/4]
llvm::raw_ostream & clang::syntax::operator<< | ( | llvm::raw_ostream & | OS, |
---|---|---|---|
const FileRange & | R | ||
) |
◆ operator<<() [2/4]
llvm::raw_ostream & clang::syntax::operator<< | ( | llvm::raw_ostream & | OS, |
---|---|---|---|
const Token & | T | ||
) |
◆ operator<<() [3/4]
raw_ostream & clang::syntax::operator<< | ( | raw_ostream & | OS, |
---|---|---|---|
NodeKind | K | ||
) |
For debugging purposes.
Definition at line 13 of file Nodes.cpp.
◆ operator<<() [4/4]
raw_ostream & clang::syntax::operator<< | ( | raw_ostream & | OS, |
---|---|---|---|
NodeRole | R | ||
) |
For debugging purposes.
Definition at line 23 of file Nodes.cpp.
◆ removeStatement()
Removes a statement or replaces it with an empty statement where one is required syntactically.
E.g., in the following example: if (cond) { foo(); } else bar(); One can remove foo();
completely and to remove bar();
we would need to replace it with an empty statement. EXPECTS: S->canModify() == true
Definition at line 79 of file Mutations.cpp.
References createEmptyStatement().
◆ spelledIdentifierTouching() [1/2]
◆ spelledIdentifierTouching() [2/2]
◆ spelledTokensTouching() [1/2]
◆ spelledTokensTouching() [2/2]
◆ tokenize() [1/2]
Similar to one above, instead of whole file tokenizes a part of it.
Note that, the first token might be incomplete if FR.startOffset is not at the beginning of a token, and the last token returned will start before the FR.endOffset but might end after it.
Definition at line 575 of file Tokens.cpp.
References clang::syntax::FileRange::beginOffset(), clang::syntax::FileRange::endOffset(), clang::syntax::FileRange::file(), clang::IdentifierTable::get(), clang::Lexer::getCurrentBufferOffset(), clang::IdentifierInfo::getTokenID(), clang::Lexer::LexFromRawLexer(), SM, and clang::T.
◆ tokenize() [2/2]
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 608 of file Tokens.cpp.
References SM, and tokenize().
Referenced by tokenize().