;
24 T->prependChildLowLevel(Child, R);
28 T->appendChildLowLevel(Child, R);
31 staticstd::pair<FileID, ArrayRef<Token>>
33std::unique_ptr<llvm::MemoryBuffer> Buffer) {
34 returnTBTM.lexBuffer(std::move(Buffer));
44FactoryImpl::lexBuffer(TBTM, llvm::MemoryBuffer::getMemBufferCopy(Spelling))
46assert(Tokens.size() == 1);
47assert(Tokens.front().kind() == K &&
48 "spelling is not lexed into the expected kind of token");
64 "Cannot infer the spelling of the token from its token kind.");
72 casesyntax::NodeKind::Leaf:
75 casesyntax::NodeKind::TranslationUnit:
77 casesyntax::NodeKind::UnknownExpression:
79 casesyntax::NodeKind::ParenExpression:
81 casesyntax::NodeKind::ThisExpression:
83 casesyntax::NodeKind::IntegerLiteralExpression:
84 return new(A.
getAllocator()) syntax::IntegerLiteralExpression;
85 casesyntax::NodeKind::CharacterLiteralExpression:
86 return new(A.
getAllocator()) syntax::CharacterLiteralExpression;
87 casesyntax::NodeKind::FloatingLiteralExpression:
88 return new(A.
getAllocator()) syntax::FloatingLiteralExpression;
89 casesyntax::NodeKind::StringLiteralExpression:
90 return new(A.
getAllocator()) syntax::StringLiteralExpression;
91 casesyntax::NodeKind::BoolLiteralExpression:
92 return new(A.
getAllocator()) syntax::BoolLiteralExpression;
93 casesyntax::NodeKind::CxxNullPtrExpression:
94 return new(A.
getAllocator()) syntax::CxxNullPtrExpression;
95 casesyntax::NodeKind::IntegerUserDefinedLiteralExpression:
96 return new(A.
getAllocator()) syntax::IntegerUserDefinedLiteralExpression;
97 casesyntax::NodeKind::FloatUserDefinedLiteralExpression:
98 return new(A.
getAllocator()) syntax::FloatUserDefinedLiteralExpression;
99 casesyntax::NodeKind::CharUserDefinedLiteralExpression:
100 return new(A.
getAllocator()) syntax::CharUserDefinedLiteralExpression;
101 casesyntax::NodeKind::StringUserDefinedLiteralExpression:
102 return new(A.
getAllocator()) syntax::StringUserDefinedLiteralExpression;
103 casesyntax::NodeKind::PrefixUnaryOperatorExpression:
105 casesyntax::NodeKind::PostfixUnaryOperatorExpression:
107 casesyntax::NodeKind::BinaryOperatorExpression:
109 casesyntax::NodeKind::UnqualifiedId:
111 casesyntax::NodeKind::IdExpression:
113 casesyntax::NodeKind::CallExpression:
115 casesyntax::NodeKind::UnknownStatement:
117 casesyntax::NodeKind::DeclarationStatement:
119 casesyntax::NodeKind::EmptyStatement:
121 casesyntax::NodeKind::SwitchStatement:
123 casesyntax::NodeKind::CaseStatement:
125 casesyntax::NodeKind::DefaultStatement:
127 casesyntax::NodeKind::IfStatement:
129 casesyntax::NodeKind::ForStatement:
131 casesyntax::NodeKind::WhileStatement:
133 casesyntax::NodeKind::ContinueStatement:
135 casesyntax::NodeKind::BreakStatement:
137 casesyntax::NodeKind::ReturnStatement:
139 casesyntax::NodeKind::RangeBasedForStatement:
141 casesyntax::NodeKind::ExpressionStatement:
143 casesyntax::NodeKind::CompoundStatement:
145 casesyntax::NodeKind::UnknownDeclaration:
147 casesyntax::NodeKind::EmptyDeclaration:
149 casesyntax::NodeKind::StaticAssertDeclaration:
151 casesyntax::NodeKind::LinkageSpecificationDeclaration:
153 casesyntax::NodeKind::SimpleDeclaration:
155 casesyntax::NodeKind::TemplateDeclaration:
157 casesyntax::NodeKind::ExplicitTemplateInstantiation:
159 casesyntax::NodeKind::NamespaceDefinition:
161 casesyntax::NodeKind::NamespaceAliasDefinition:
163 casesyntax::NodeKind::UsingNamespaceDirective:
165 casesyntax::NodeKind::UsingDeclaration:
167 casesyntax::NodeKind::TypeAliasDeclaration:
169 casesyntax::NodeKind::SimpleDeclarator:
171 casesyntax::NodeKind::ParenDeclarator:
173 casesyntax::NodeKind::ArraySubscript:
175 casesyntax::NodeKind::TrailingReturnType:
177 casesyntax::NodeKind::ParametersAndQualifiers:
179 casesyntax::NodeKind::MemberPointer:
181 casesyntax::NodeKind::GlobalNameSpecifier:
182 return new(A.
getAllocator()) syntax::GlobalNameSpecifier;
183 casesyntax::NodeKind::DecltypeNameSpecifier:
184 return new(A.
getAllocator()) syntax::DecltypeNameSpecifier;
185 casesyntax::NodeKind::IdentifierNameSpecifier:
186 return new(A.
getAllocator()) syntax::IdentifierNameSpecifier;
187 casesyntax::NodeKind::SimpleTemplateNameSpecifier:
188 return new(A.
getAllocator()) syntax::SimpleTemplateNameSpecifier;
189 casesyntax::NodeKind::NestedNameSpecifier:
191 casesyntax::NodeKind::MemberExpression:
192 return new(A.
getAllocator()) syntax::MemberExpression;
193 casesyntax::NodeKind::CallArguments:
195 casesyntax::NodeKind::ParameterDeclarationList:
197 casesyntax::NodeKind::DeclaratorList:
200llvm_unreachable(
"unknown node kind");
206 ArrayRef<std::pair<syntax::Node *, syntax::NodeRole>> Children,
208 auto*
T= allocateTree(A, K);
209FactoryImpl::setCanModify(
T);
210 for(
const auto&Child : Children)
211FactoryImpl::appendChildLowLevel(
T, Child.first, Child.second);
213 T->assertInvariants();
220 if(
const auto*L = dyn_cast<syntax::Leaf>(N))
224TBTM.
getText(L->getTokenKey()));
226 const auto*
T= cast<syntax::Tree>(N);
227std::vector<std::pair<syntax::Node *, syntax::NodeRole>> Children;
228 for(
const auto*Child =
T->getFirstChild(); Child;
229Child = Child->getNextSibling())
236 returncast<EmptyStatement>(
238NodeKind::EmptyStatement));
Defines the clang::TokenKind enum and support functions.
A memory arena for syntax trees.
llvm::BumpPtrAllocator & getAllocator()
Array size specified inside a declarator.
Models arguments of a function call.
{ statement1; statement2; ⦠}
A semicolon in the top-level context. Does not declare anything.
The no-op statement, i.e. ';'.
template <declaration> Examples: template struct X<int> template void foo<int>() template int var<dou...
Expression in a statement position, e.g.
Exposes private syntax tree APIs required to implement node synthesis.
static void appendChildLowLevel(syntax::Tree *T, syntax::Node *Child, syntax::NodeRole R)
static void setCanModify(syntax::Node *N)
static std::pair< FileID, ArrayRef< Token > > lexBuffer(TokenBufferTokenManager &TBTM, std::unique_ptr< llvm::MemoryBuffer > Buffer)
static void prependChildLowLevel(syntax::Tree *T, syntax::Node *Child, syntax::NodeRole R)
for (<init>; <cond>; <increment>) <body>
if (cond) <then-statement> else <else-statement> FIXME: add condition that models 'expression or vari...
A leaf node points to a single token.
extern <string-literal> declaration extern <string-literal> { <decls> }
Member pointer inside a declarator E.g.
namespace <name> = <namespace-reference>
namespace <name> { <decls> }
Models a nested-name-specifier.
void assertInvariants() const
Asserts invariants on this node of the tree and its immediate children.
Models a parameter-declaration-list which appears within parameters-and-qualifiers.
Parameter list for a function type and a trailing return type, if the function has one.
Declarator inside parentheses.
for (<decl> : <init>) <body>
Groups multiple declarators (e.g.
A top-level declarator without parentheses.
static_assert(<condition>, <message>) static_assert(<condition>)
template <template-parameters> <declaration>
A TokenBuffer-powered token manager.
const syntax::Token * getToken(Key I) const
llvm::StringRef getText(Key I) const override
uintptr_t Key
A key to identify a specific token.
tok::TokenKind kind() const
Trailing return type after the parameter list, including the arrow token.
A node that has children and represents a syntactic language construct.
Declaration of an unknown kind, e.g. not yet supported in syntax trees.
An expression of an unknown kind, i.e.
A statement of an unknown kind, i.e.
Models an unqualified-id.
using <scope>::<name> using typename <scope>::<name>
NodeRole
A relation between a parent and child node, e.g.
syntax::Node * deepCopyExpandingMacros(syntax::Arena &A, TokenBufferTokenManager &TBTM, const syntax::Node *N)
Creates a completely independent copy of N with its macros expanded.
syntax::EmptyStatement * createEmptyStatement(syntax::Arena &A, TokenBufferTokenManager &TBTM)
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.
NodeKind
A kind of a syntax node, used for implementing casts.
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.
const char * getKeywordSpelling(TokenKind Kind) LLVM_READNONE
Determines the spelling of simple keyword and contextual keyword tokens like 'int' and 'dynamic_cast'...
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
const char * getPunctuatorSpelling(TokenKind Kind) LLVM_READNONE
Determines the spelling of simple punctuation tokens like '!' or '', and returns NULL for literal and...
The JSON file list parser is used to communicate input to InstallAPI.
const FunctionProtoType * T
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4