clang  17.0.0git
Nodes.h
Go to the documentation of this file.
1 //===- Nodes.h - syntax nodes for C/C++ grammar constructs ----*- C++ -*-=====//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 // Syntax tree nodes for C, C++ and Objective-C grammar constructs.
9 //
10 // Nodes provide access to their syntactic components, e.g. IfStatement provides
11 // a way to get its condition, then and else branches, tokens for 'if' and
12 // 'else' keywords.
13 // When using the accessors, please assume they can return null. This happens
14 // because:
15 // - the corresponding subnode is optional in the C++ grammar, e.g. an else
16 // branch of an if statement,
17 // - syntactic errors occurred while parsing the corresponding subnode.
18 // One notable exception is "introducer" keywords, e.g. the accessor for the
19 // 'if' keyword of an if statement will never return null.
20 //===----------------------------------------------------------------------===//
21 #ifndef LLVM_CLANG_TOOLING_SYNTAX_NODES_H
22 #define LLVM_CLANG_TOOLING_SYNTAX_NODES_H
23 
24 #include "clang/Basic/LLVM.h"
26 namespace clang {
27 namespace syntax {
28 
29 /// A kind of a syntax node, used for implementing casts. The ordering and
30 /// blocks of enumerator constants must correspond to the inheritance hierarchy
31 /// of syntax::Node.
32 enum class NodeKind : uint16_t {
33 #define CONCRETE_NODE(Kind, Base) Kind,
34 #include "clang/Tooling/Syntax/Nodes.inc"
35 };
36 /// For debugging purposes.
37 raw_ostream &operator<<(raw_ostream &OS, NodeKind K);
38 
39 /// A relation between a parent and child node, e.g. 'left-hand-side of
40 /// a binary expression'. Used for implementing accessors.
41 ///
42 /// In general `NodeRole`s should be named the same as their accessors.
43 ///
44 /// Some roles describe parent/child relations that occur multiple times in
45 /// language grammar. We define only one role to describe all instances of such
46 /// recurring relations. For example, grammar for both "if" and "while"
47 /// statements requires an opening paren and a closing paren. The opening
48 /// paren token is assigned the OpenParen role regardless of whether it appears
49 /// as a child of IfStatement or WhileStatement node. More generally, when
50 /// grammar requires a certain fixed token (like a specific keyword, or an
51 /// opening paren), we define a role for this token and use it across all
52 /// grammar rules with the same requirement. Names of such reusable roles end
53 /// with a ~Token or a ~Keyword suffix.
54 enum class NodeRole : uint8_t {
55  // Roles common to multiple node kinds.
56  /// A node without a parent
57  Detached,
58  /// Children of an unknown semantic nature, e.g. skipped tokens, comments.
59  Unknown,
60  /// An opening parenthesis in argument lists and blocks, e.g. '{', '(', etc.
61  OpenParen,
62  /// A closing parenthesis in argument lists and blocks, e.g. '}', ')', etc.
63  CloseParen,
64  /// A keywords that introduces some grammar construct, e.g. 'if', 'try', etc.
66  /// A token that represents a literal, e.g. 'nullptr', '1', 'true', etc.
68  /// Tokens or Keywords.
69  ArrowToken,
72  /// An inner statement for those that have only a single child of kind
73  /// statement, e.g. loop body for while, for, etc; inner statement for case,
74  /// default, etc.
76  /// List API roles.
79 
80  // Roles specific to particular node kinds.
82  Operand,
86  CaseValue,
90  Expression,
91  Statement,
92  Condition,
93  Message,
94  Declarator,
96  Size,
97  Parameters,
100  Qualifier,
102  Object,
103  AccessToken,
104  Member,
105  Callee,
106  Arguments,
108 };
109 /// For debugging purposes.
110 raw_ostream &operator<<(raw_ostream &OS, NodeRole R);
111 
112 #include "clang/Tooling/Syntax/NodeClasses.inc"
113 
114 /// Models a `nested-name-specifier`. C++ [expr.prim.id.qual]
115 /// e.g. the `std::vector<int>::` in `std::vector<int>::size`.
116 class NestedNameSpecifier final : public List {
117 public:
119  static bool classof(const Node *N);
120  std::vector<NameSpecifier *> getSpecifiers();
121  std::vector<List::ElementAndDelimiter<syntax::NameSpecifier>>
123 };
124 
125 /// Models an `unqualified-id`. C++ [expr.prim.id.unqual]
126 /// e.g. the `size` in `std::vector<int>::size`.
127 class UnqualifiedId final : public Tree {
128 public:
130  static bool classof(const Node *N);
131 };
132 
133 /// An expression of an unknown kind, i.e. one not currently handled by the
134 /// syntax tree.
135 class UnknownExpression final : public Expression {
136 public:
138  static bool classof(const Node *N);
139 };
140 
141 /// Models arguments of a function call.
142 /// call-arguments:
143 /// delimited_list(expression, ',')
144 /// Note: This construct is a simplification of the grammar rule for
145 /// `expression-list`, that is used in the definition of `call-expression`
146 class CallArguments final : public List {
147 public:
149  static bool classof(const Node *N);
150  std::vector<Expression *> getArguments();
151  std::vector<List::ElementAndDelimiter<Expression>> getArgumentsAndCommas();
152 };
153 
154 /// An abstract class for prefix and postfix unary operators.
156 public:
158  static bool classof(const Node *N);
161 };
162 
163 /// <operator> <operand>
164 ///
165 /// For example:
166 /// +a -b
167 /// !c not c
168 /// ~d compl d
169 /// *e &f
170 /// ++h --h
171 /// __real i __imag i
173 public:
176  static bool classof(const Node *N);
177 };
178 
179 /// <operand> <operator>
180 ///
181 /// For example:
182 /// a++
183 /// b--
185 public:
188  static bool classof(const Node *N);
189 };
190 
191 /// <lhs> <operator> <rhs>
192 ///
193 /// For example:
194 /// a + b
195 /// a bitor 1
196 /// a |= b
197 /// a and_eq b
198 class BinaryOperatorExpression final : public Expression {
199 public:
201  static bool classof(const Node *N);
202  Expression *getLhs();
204  Expression *getRhs();
205 };
206 
207 /// An abstract node for C++ statements, e.g. 'while', 'if', etc.
208 /// FIXME: add accessors for semicolon of statements that have it.
209 class Statement : public Tree {
210 public:
212  static bool classof(const Node *N);
213 };
214 
215 /// A statement of an unknown kind, i.e. one not currently handled by the syntax
216 /// tree.
217 class UnknownStatement final : public Statement {
218 public:
220  static bool classof(const Node *N);
221 };
222 
223 /// E.g. 'int a, b = 10;'
224 class DeclarationStatement final : public Statement {
225 public:
227  static bool classof(const Node *N);
228 };
229 
230 /// The no-op statement, i.e. ';'.
231 class EmptyStatement final : public Statement {
232 public:
234  static bool classof(const Node *N);
235 };
236 
237 /// switch (<cond>) <body>
238 class SwitchStatement final : public Statement {
239 public:
241  static bool classof(const Node *N);
243  Statement *getBody();
244 };
245 
246 /// case <value>: <body>
247 class CaseStatement final : public Statement {
248 public:
250  static bool classof(const Node *N);
251  Leaf *getCaseKeyword();
253  Statement *getBody();
254 };
255 
256 /// default: <body>
257 class DefaultStatement final : public Statement {
258 public:
260  static bool classof(const Node *N);
262  Statement *getBody();
263 };
264 
265 /// if (cond) <then-statement> else <else-statement>
266 /// FIXME: add condition that models 'expression or variable declaration'
267 class IfStatement final : public Statement {
268 public:
270  static bool classof(const Node *N);
271  Leaf *getIfKeyword();
273  Leaf *getElseKeyword();
275 };
276 
277 /// for (<init>; <cond>; <increment>) <body>
278 class ForStatement final : public Statement {
279 public:
281  static bool classof(const Node *N);
282  Leaf *getForKeyword();
283  Statement *getBody();
284 };
285 
286 /// while (<cond>) <body>
287 class WhileStatement final : public Statement {
288 public:
290  static bool classof(const Node *N);
292  Statement *getBody();
293 };
294 
295 /// continue;
296 class ContinueStatement final : public Statement {
297 public:
299  static bool classof(const Node *N);
301 };
302 
303 /// break;
304 class BreakStatement final : public Statement {
305 public:
307  static bool classof(const Node *N);
309 };
310 
311 /// return <expr>;
312 /// return;
313 class ReturnStatement final : public Statement {
314 public:
316  static bool classof(const Node *N);
319 };
320 
321 /// for (<decl> : <init>) <body>
322 class RangeBasedForStatement final : public Statement {
323 public:
325  static bool classof(const Node *N);
326  Leaf *getForKeyword();
327  Statement *getBody();
328 };
329 
330 /// Expression in a statement position, e.g. functions calls inside compound
331 /// statements or inside a loop body.
332 class ExpressionStatement final : public Statement {
333 public:
335  static bool classof(const Node *N);
337 };
338 
339 /// { statement1; statement2; … }
340 class CompoundStatement final : public Statement {
341 public:
343  static bool classof(const Node *N);
344  Leaf *getLbrace();
345  /// FIXME: use custom iterator instead of 'vector'.
346  std::vector<Statement *> getStatements();
347  Leaf *getRbrace();
348 };
349 
350 /// A declaration that can appear at the top-level. Note that this does *not*
351 /// correspond 1-to-1 to clang::Decl. Syntax trees distinguish between top-level
352 /// declarations (e.g. namespace definitions) and declarators (e.g. variables,
353 /// typedefs, etc.). Declarators are stored inside SimpleDeclaration.
354 class Declaration : public Tree {
355 public:
357  static bool classof(const Node *N);
358 };
359 
360 /// Declaration of an unknown kind, e.g. not yet supported in syntax trees.
361 class UnknownDeclaration final : public Declaration {
362 public:
364  static bool classof(const Node *N);
365 };
366 
367 /// A semicolon in the top-level context. Does not declare anything.
368 class EmptyDeclaration final : public Declaration {
369 public:
371  static bool classof(const Node *N);
372 };
373 
374 /// static_assert(<condition>, <message>)
375 /// static_assert(<condition>)
376 class StaticAssertDeclaration final : public Declaration {
377 public:
379  static bool classof(const Node *N);
382 };
383 
384 /// extern <string-literal> declaration
385 /// extern <string-literal> { <decls> }
387 public:
390  static bool classof(const Node *N);
391 };
392 
393 class DeclaratorList final : public List {
394 public:
396  static bool classof(const Node *N);
397  std::vector<SimpleDeclarator *> getDeclarators();
398  std::vector<List::ElementAndDelimiter<syntax::SimpleDeclarator>>
400 };
401 
402 /// Groups multiple declarators (e.g. variables, typedefs, etc.) together. All
403 /// grouped declarators share the same declaration specifiers (e.g. 'int' or
404 /// 'typedef').
405 class SimpleDeclaration final : public Declaration {
406 public:
408  static bool classof(const Node *N);
409  /// FIXME: use custom iterator instead of 'vector'.
410  std::vector<SimpleDeclarator *> getDeclarators();
411 };
412 
413 /// template <template-parameters> <declaration>
414 class TemplateDeclaration final : public Declaration {
415 public:
417  static bool classof(const Node *N);
420 };
421 
422 /// template <declaration>
423 /// Examples:
424 /// template struct X<int>
425 /// template void foo<int>()
426 /// template int var<double>
428 public:
431  static bool classof(const Node *N);
435 };
436 
437 /// namespace <name> { <decls> }
438 class NamespaceDefinition final : public Declaration {
439 public:
441  static bool classof(const Node *N);
442 };
443 
444 /// namespace <name> = <namespace-reference>
445 class NamespaceAliasDefinition final : public Declaration {
446 public:
449  static bool classof(const Node *N);
450 };
451 
452 /// using namespace <name>
453 class UsingNamespaceDirective final : public Declaration {
454 public:
456  static bool classof(const Node *N);
457 };
458 
459 /// using <scope>::<name>
460 /// using typename <scope>::<name>
461 class UsingDeclaration final : public Declaration {
462 public:
464  static bool classof(const Node *N);
465 };
466 
467 /// using <name> = <type>
468 class TypeAliasDeclaration final : public Declaration {
469 public:
471  static bool classof(const Node *N);
472 };
473 
474 /// Covers a name, an initializer and a part of the type outside declaration
475 /// specifiers. Examples are:
476 /// `*a` in `int *a`
477 /// `a[10]` in `int a[10]`
478 /// `*a = nullptr` in `int *a = nullptr`
479 /// Declarators can be unnamed too:
480 /// `**` in `new int**`
481 /// `* = nullptr` in `void foo(int* = nullptr)`
482 /// Most declarators you encounter are instances of SimpleDeclarator. They may
483 /// contain an inner declarator inside parentheses, we represent it as
484 /// ParenDeclarator. E.g.
485 /// `(*a)` in `int (*a) = 10`
486 class Declarator : public Tree {
487 public:
489  static bool classof(const Node *N);
490 };
491 
492 /// A top-level declarator without parentheses. See comment of Declarator for
493 /// more details.
494 class SimpleDeclarator final : public Declarator {
495 public:
497  static bool classof(const Node *N);
498 };
499 
500 /// Declarator inside parentheses.
501 /// E.g. `(***a)` from `int (***a) = nullptr;`
502 /// See comment of Declarator for more details.
503 class ParenDeclarator final : public Declarator {
504 public:
506  static bool classof(const Node *N);
507  Leaf *getLparen();
508  Leaf *getRparen();
509 };
510 
511 /// Array size specified inside a declarator.
512 /// E.g:
513 /// `[10]` in `int a[10];`
514 /// `[static 10]` in `void f(int xs[static 10]);`
515 class ArraySubscript final : public Tree {
516 public:
518  static bool classof(const Node *N);
519  // TODO: add an accessor for the "static" keyword.
520  Leaf *getLbracket();
521  Expression *getSize();
522  Leaf *getRbracket();
523 };
524 
525 /// Trailing return type after the parameter list, including the arrow token.
526 /// E.g. `-> int***`.
527 class TrailingReturnType final : public Tree {
528 public:
530  static bool classof(const Node *N);
531  // TODO: add accessors for specifiers.
532  Leaf *getArrowToken();
533  // FIXME: This should be a `type-id` following the grammar. Fix this once we
534  // have a representation of `type-id`s.
536 };
537 
538 /// Models a `parameter-declaration-list` which appears within
539 /// `parameters-and-qualifiers`. See C++ [dcl.fct]
540 class ParameterDeclarationList final : public List {
541 public:
543  static bool classof(const Node *N);
544  std::vector<SimpleDeclaration *> getParameterDeclarations();
545  std::vector<List::ElementAndDelimiter<syntax::SimpleDeclaration>>
547 };
548 
549 /// Parameter list for a function type and a trailing return type, if the
550 /// function has one.
551 /// E.g.:
552 /// `(int a) volatile ` in `int foo(int a) volatile;`
553 /// `(int a) &&` in `int foo(int a) &&;`
554 /// `() -> int` in `auto foo() -> int;`
555 /// `() const` in `int foo() const;`
556 /// `() noexcept` in `int foo() noexcept;`
557 /// `() throw()` in `int foo() throw();`
558 ///
559 /// (!) override doesn't belong here.
560 class ParametersAndQualifiers final : public Tree {
561 public:
563  static bool classof(const Node *N);
564  Leaf *getLparen();
566  Leaf *getRparen();
568 };
569 
570 /// Member pointer inside a declarator
571 /// E.g. `X::*` in `int X::* a = 0;`
572 class MemberPointer final : public Tree {
573 public:
575  static bool classof(const Node *N);
576 };
577 
578 #define CONCRETE_NODE(Kind, Base) \
579  inline bool Kind::classof(const Node *N) { \
580  return N->getKind() == NodeKind::Kind; \
581  }
582 #define ABSTRACT_NODE(Kind, Base, First, Last) \
583  inline bool Kind::classof(const Node *N) { \
584  return N->getKind() >= NodeKind::First && N->getKind() <= NodeKind::Last; \
585  }
586 #include "clang/Tooling/Syntax/Nodes.inc"
587 
588 } // namespace syntax
589 } // namespace clang
590 #endif
clang::syntax::TemplateDeclaration
template <template-parameters> <declaration>
Definition: Nodes.h:414
clang::syntax::ForStatement::getBody
Statement * getBody()
Definition: Nodes.cpp:280
clang::syntax::WhileStatement::getWhileKeyword
Leaf * getWhileKeyword()
Definition: Nodes.cpp:285
clang::syntax::ExpressionStatement::classof
static bool classof(const Node *N)
clang::syntax::ForStatement
for (<init>; <cond>; <increment>) <body>
Definition: Nodes.h:278
clang::syntax::BinaryOperatorExpression::getRhs
Expression * getRhs()
Definition: Nodes.cpp:216
clang::syntax::ParametersAndQualifiers::getLparen
Leaf * getLparen()
Definition: Nodes.cpp:419
clang::syntax::ReturnStatement::getReturnKeyword
Leaf * getReturnKeyword()
Definition: Nodes.cpp:305
clang::syntax::NodeRole::ElseStatement
@ ElseStatement
clang::syntax::ParametersAndQualifiers::classof
static bool classof(const Node *N)
clang::syntax::ParameterDeclarationList::getParameterDeclarations
std::vector< SimpleDeclaration * > getParameterDeclarations()
Definition: Nodes.cpp:154
clang::syntax::ParameterDeclarationList::ParameterDeclarationList
ParameterDeclarationList()
Definition: Nodes.h:542
clang::syntax::ExplicitTemplateInstantiation::getTemplateKeyword
Leaf * getTemplateKeyword()
Definition: Nodes.cpp:376
clang::syntax::NodeRole::RightHandSide
@ RightHandSide
clang::syntax::ForStatement::classof
static bool classof(const Node *N)
clang::syntax::CompoundStatement::CompoundStatement
CompoundStatement()
Definition: Nodes.h:342
clang::syntax::NodeRole::Expression
@ Expression
clang::syntax::SimpleDeclarator::SimpleDeclarator
SimpleDeclarator()
Definition: Nodes.h:496
clang::syntax::UsingDeclaration::UsingDeclaration
UsingDeclaration()
Definition: Nodes.h:463
clang::syntax::EmptyStatement::EmptyStatement
EmptyStatement()
Definition: Nodes.h:233
clang::syntax::CaseStatement::classof
static bool classof(const Node *N)
clang::syntax::NodeRole::UnqualifiedId
@ UnqualifiedId
clang::syntax::ExplicitTemplateInstantiation::classof
static bool classof(const Node *N)
clang::syntax::NamespaceDefinition
namespace <name> { <decls> }
Definition: Nodes.h:438
clang::syntax::CompoundStatement::classof
static bool classof(const Node *N)
clang::syntax::RangeBasedForStatement
for (<decl> : <init>) <body>
Definition: Nodes.h:322
clang::syntax::operator<<
raw_ostream & operator<<(raw_ostream &OS, NodeKind K)
For debugging purposes.
Definition: Nodes.cpp:13
clang::syntax::UnknownExpression
An expression of an unknown kind, i.e.
Definition: Nodes.h:135
clang::syntax::RangeBasedForStatement::classof
static bool classof(const Node *N)
clang::syntax::ContinueStatement
continue;
Definition: Nodes.h:296
clang::syntax::Node
A node in a syntax tree.
Definition: Tree.h:54
clang::syntax::DeclaratorList
Definition: Nodes.h:393
clang::syntax::ParenDeclarator
Declarator inside parentheses.
Definition: Nodes.h:503
clang::syntax::RangeBasedForStatement::RangeBasedForStatement
RangeBasedForStatement()
Definition: Nodes.h:324
clang::syntax::TrailingReturnType::getArrowToken
Leaf * getArrowToken()
Definition: Nodes.cpp:410
clang::syntax::SimpleDeclaration::SimpleDeclaration
SimpleDeclaration()
Definition: Nodes.h:407
clang::syntax::RangeBasedForStatement::getForKeyword
Leaf * getForKeyword()
Definition: Nodes.cpp:315
clang::syntax::NodeRole::Detached
@ Detached
A node without a parent.
clang::syntax::ForStatement::ForStatement
ForStatement()
Definition: Nodes.h:280
clang::syntax::NamespaceAliasDefinition
namespace <name> = <namespace-reference>
Definition: Nodes.h:445
clang::syntax::ReturnStatement::getReturnValue
Expression * getReturnValue()
Definition: Nodes.cpp:310
clang::syntax::NodeRole::CloseParen
@ CloseParen
A closing parenthesis in argument lists and blocks, e.g. '}', ')', etc.
clang::syntax::UnknownStatement::UnknownStatement
UnknownStatement()
Definition: Nodes.h:219
clang::syntax::ParameterDeclarationList::getParametersAndCommas
std::vector< List::ElementAndDelimiter< syntax::SimpleDeclaration > > getParametersAndCommas()
Definition: Nodes.cpp:164
clang::syntax::DeclarationStatement::classof
static bool classof(const Node *N)
clang::syntax::Declaration::Declaration
Declaration(NodeKind K)
Definition: Nodes.h:356
Expression
clang::syntax::NestedNameSpecifier::getSpecifiersAndDoubleColons
std::vector< List::ElementAndDelimiter< syntax::NameSpecifier > > getSpecifiersAndDoubleColons()
Definition: Nodes.cpp:120
clang::syntax::IfStatement::getThenStatement
Statement * getThenStatement()
Definition: Nodes.cpp:261
clang::syntax::CompoundStatement::getRbrace
Leaf * getRbrace()
Definition: Nodes.cpp:343
clang::syntax::UnqualifiedId
Models an unqualified-id.
Definition: Nodes.h:127
clang::syntax::NamespaceAliasDefinition::NamespaceAliasDefinition
NamespaceAliasDefinition()
Definition: Nodes.h:447
clang::syntax::NodeRole::TrailingReturn
@ TrailingReturn
clang::syntax::UsingNamespaceDirective
using namespace <name>
Definition: Nodes.h:453
clang::syntax::EmptyDeclaration::EmptyDeclaration
EmptyDeclaration()
Definition: Nodes.h:370
clang::syntax::BinaryOperatorExpression::BinaryOperatorExpression
BinaryOperatorExpression()
Definition: Nodes.h:200
clang::syntax::NodeRole::Statement
@ Statement
clang::syntax::PostfixUnaryOperatorExpression::PostfixUnaryOperatorExpression
PostfixUnaryOperatorExpression()
Definition: Nodes.h:186
clang::syntax::CaseStatement::getCaseValue
Expression * getCaseValue()
Definition: Nodes.cpp:236
clang::syntax::TemplateDeclaration::TemplateDeclaration
TemplateDeclaration()
Definition: Nodes.h:416
clang::syntax::NodeRole::Object
@ Object
clang::syntax::TrailingReturnType::getDeclarator
SimpleDeclarator * getDeclarator()
Definition: Nodes.cpp:414
clang::syntax::NodeRole::SubExpression
@ SubExpression
clang::syntax::ForStatement::getForKeyword
Leaf * getForKeyword()
Definition: Nodes.cpp:275
clang::syntax::Statement::Statement
Statement(NodeKind K)
Definition: Nodes.h:211
clang::syntax::StaticAssertDeclaration
static_assert(<condition>, <message>) static_assert(<condition>)
Definition: Nodes.h:376
clang::syntax::List
A list of Elements separated or terminated by a fixed token.
Definition: Tree.h:254
clang::syntax::CaseStatement::CaseStatement
CaseStatement()
Definition: Nodes.h:249
clang::syntax::NodeRole::ArrowToken
@ ArrowToken
Tokens or Keywords.
clang::syntax::NodeRole::Parameters
@ Parameters
clang::syntax::ReturnStatement::ReturnStatement
ReturnStatement()
Definition: Nodes.h:315
clang::syntax::ReturnStatement::classof
static bool classof(const Node *N)
clang::syntax::TrailingReturnType::classof
static bool classof(const Node *N)
clang::syntax::ContinueStatement::classof
static bool classof(const Node *N)
clang::syntax::BreakStatement
break;
Definition: Nodes.h:304
clang::syntax::ExpressionStatement::ExpressionStatement
ExpressionStatement()
Definition: Nodes.h:334
clang::syntax::NamespaceDefinition::NamespaceDefinition
NamespaceDefinition()
Definition: Nodes.h:440
clang::syntax::LinkageSpecificationDeclaration::classof
static bool classof(const Node *N)
clang::syntax::Tree
A node that has children and represents a syntactic language construct.
Definition: Tree.h:144
clang::syntax::UnknownExpression::UnknownExpression
UnknownExpression()
Definition: Nodes.h:137
clang::syntax::BreakStatement::BreakStatement
BreakStatement()
Definition: Nodes.h:306
clang::syntax::ExplicitTemplateInstantiation::getDeclaration
Declaration * getDeclaration()
Definition: Nodes.cpp:385
clang::syntax::ArraySubscript
Array size specified inside a declarator.
Definition: Nodes.h:515
clang::syntax::Declarator::classof
static bool classof(const Node *N)
clang::syntax::SimpleDeclaration::classof
static bool classof(const Node *N)
clang::syntax::CompoundStatement::getStatements
std::vector< Statement * > getStatements()
FIXME: use custom iterator instead of 'vector'.
Definition: Nodes.cpp:334
clang::syntax::ExplicitTemplateInstantiation::ExplicitTemplateInstantiation
ExplicitTemplateInstantiation()
Definition: Nodes.h:429
clang::syntax::NodeRole::ExternKeyword
@ ExternKeyword
clang::syntax::UnaryOperatorExpression::classof
static bool classof(const Node *N)
clang::syntax::ParametersAndQualifiers::getTrailingReturn
TrailingReturnType * getTrailingReturn()
Definition: Nodes.cpp:434
clang::syntax::NodeRole::Callee
@ Callee
clang::syntax::UnknownStatement::classof
static bool classof(const Node *N)
clang::syntax::IfStatement::getElseStatement
Statement * getElseStatement()
Definition: Nodes.cpp:270
clang::syntax::NodeRole::ReturnValue
@ ReturnValue
clang::syntax::Declarator::Declarator
Declarator(NodeKind K)
Definition: Nodes.h:488
clang::syntax::NodeRole::Qualifier
@ Qualifier
clang::syntax::ParenDeclarator::classof
static bool classof(const Node *N)
clang::syntax::ParenDeclarator::ParenDeclarator
ParenDeclarator()
Definition: Nodes.h:505
clang::syntax::DefaultStatement::getBody
Statement * getBody()
Definition: Nodes.cpp:251
clang::syntax::WhileStatement::WhileStatement
WhileStatement()
Definition: Nodes.h:289
clang::syntax::BinaryOperatorExpression::getOperatorToken
Leaf * getOperatorToken()
Definition: Nodes.cpp:212
clang::syntax::ParametersAndQualifiers::ParametersAndQualifiers
ParametersAndQualifiers()
Definition: Nodes.h:562
clang::syntax::NodeRole::ListElement
@ ListElement
List API roles.
clang::syntax::ArraySubscript::classof
static bool classof(const Node *N)
clang::syntax::BreakStatement::getBreakKeyword
Leaf * getBreakKeyword()
Definition: Nodes.cpp:300
clang::syntax::BinaryOperatorExpression
<lhs> <operator> <rhs>
Definition: Nodes.h:198
clang::syntax::TemplateDeclaration::classof
static bool classof(const Node *N)
clang::syntax::SimpleDeclaration
Groups multiple declarators (e.g.
Definition: Nodes.h:405
clang::syntax::WhileStatement::getBody
Statement * getBody()
Definition: Nodes.cpp:290
clang::syntax::CallArguments::CallArguments
CallArguments()
Definition: Nodes.h:148
clang::syntax::NodeRole::ElseKeyword
@ ElseKeyword
clang::syntax::DeclarationStatement
E.g. 'int a, b = 10;'.
Definition: Nodes.h:224
clang::syntax::DeclarationStatement::DeclarationStatement
DeclarationStatement()
Definition: Nodes.h:226
clang::syntax::NodeRole::ThenStatement
@ ThenStatement
clang::syntax::UnaryOperatorExpression::getOperatorToken
Leaf * getOperatorToken()
Definition: Nodes.cpp:204
clang::syntax::IfStatement::IfStatement
IfStatement()
Definition: Nodes.h:269
clang::syntax::NodeRole::Unknown
@ Unknown
Children of an unknown semantic nature, e.g. skipped tokens, comments.
clang::syntax::SimpleDeclarator::classof
static bool classof(const Node *N)
clang::syntax::DeclaratorList::getDeclarators
std::vector< SimpleDeclarator * > getDeclarators()
Definition: Nodes.cpp:177
clang::syntax::IfStatement::classof
static bool classof(const Node *N)
clang::syntax::BinaryOperatorExpression::classof
static bool classof(const Node *N)
clang::syntax::ParameterDeclarationList::classof
static bool classof(const Node *N)
clang::syntax::ExpressionStatement::getExpression
Expression * getExpression()
Definition: Nodes.cpp:325
clang::syntax::UnaryOperatorExpression::getOperand
Expression * getOperand()
Definition: Nodes.cpp:208
clang::syntax::UnqualifiedId::UnqualifiedId
UnqualifiedId()
Definition: Nodes.h:129
clang::syntax::EmptyStatement
The no-op statement, i.e. ';'.
Definition: Nodes.h:231
clang::syntax::ContinueStatement::ContinueStatement
ContinueStatement()
Definition: Nodes.h:298
clang::syntax::WhileStatement::classof
static bool classof(const Node *N)
clang::syntax::CallArguments::getArguments
std::vector< Expression * > getArguments()
Definition: Nodes.cpp:132
clang::syntax::DefaultStatement::DefaultStatement
DefaultStatement()
Definition: Nodes.h:259
clang::syntax::NestedNameSpecifier::NestedNameSpecifier
NestedNameSpecifier()
Definition: Nodes.h:118
clang::syntax::IfStatement::getElseKeyword
Leaf * getElseKeyword()
Definition: Nodes.cpp:266
clang::syntax::ExpressionStatement
Expression in a statement position, e.g.
Definition: Nodes.h:332
clang::syntax::DefaultStatement::classof
static bool classof(const Node *N)
clang::syntax::NodeRole::Operand
@ Operand
clang::syntax::IfStatement
if (cond) <then-statement> else <else-statement> FIXME: add condition that models 'expression or vari...
Definition: Nodes.h:267
clang::syntax::ArraySubscript::getSize
Expression * getSize()
Definition: Nodes.cpp:402
clang::syntax::SwitchStatement::SwitchStatement
SwitchStatement()
Definition: Nodes.h:240
clang::syntax::Declaration::classof
static bool classof(const Node *N)
clang::syntax::UnknownDeclaration::classof
static bool classof(const Node *N)
clang::syntax::NodeRole::CaseValue
@ CaseValue
clang::syntax::PrefixUnaryOperatorExpression::classof
static bool classof(const Node *N)
clang::syntax::ParametersAndQualifiers::getParameters
ParameterDeclarationList * getParameters()
Definition: Nodes.cpp:424
clang::syntax::UsingDeclaration::classof
static bool classof(const Node *N)
clang::syntax::PostfixUnaryOperatorExpression::classof
static bool classof(const Node *N)
clang::syntax::NodeRole::Size
@ Size
clang::syntax::StaticAssertDeclaration::classof
static bool classof(const Node *N)
clang::syntax::CallArguments
Models arguments of a function call.
Definition: Nodes.h:146
clang::syntax::NodeRole::ListDelimiter
@ ListDelimiter
clang::syntax::NodeRole::Declarator
@ Declarator
clang::syntax::BinaryOperatorExpression::getLhs
Expression * getLhs()
Definition: Nodes.cpp:199
clang::syntax::DeclaratorList::classof
static bool classof(const Node *N)
clang::syntax::StaticAssertDeclaration::getCondition
Expression * getCondition()
Definition: Nodes.cpp:347
clang::syntax::IfStatement::getIfKeyword
Leaf * getIfKeyword()
Definition: Nodes.cpp:256
clang::syntax::TypeAliasDeclaration
using <name> = <type>
Definition: Nodes.h:468
clang::syntax::SimpleDeclaration::getDeclarators
std::vector< SimpleDeclarator * > getDeclarators()
FIXME: use custom iterator instead of 'vector'.
Definition: Nodes.cpp:357
clang::syntax::NodeRole::Message
@ Message
clang::syntax::Statement::classof
static bool classof(const Node *N)
clang::syntax::MemberPointer::classof
static bool classof(const Node *N)
clang::syntax::NodeRole::OpenParen
@ OpenParen
An opening parenthesis in argument lists and blocks, e.g. '{', '(', etc.
LLVM.h
clang::syntax::UnaryOperatorExpression::UnaryOperatorExpression
UnaryOperatorExpression(NodeKind K)
Definition: Nodes.h:157
clang::syntax::Declarator
Covers a name, an initializer and a part of the type outside declaration specifiers.
Definition: Nodes.h:486
clang::syntax::UnknownDeclaration::UnknownDeclaration
UnknownDeclaration()
Definition: Nodes.h:363
clang::syntax::LinkageSpecificationDeclaration::LinkageSpecificationDeclaration
LinkageSpecificationDeclaration()
Definition: Nodes.h:388
clang::syntax::LinkageSpecificationDeclaration
extern <string-literal> declaration extern <string-literal> { <decls> }
Definition: Nodes.h:386
clang::syntax::CallArguments::getArgumentsAndCommas
std::vector< List::ElementAndDelimiter< Expression > > getArgumentsAndCommas()
Definition: Nodes.cpp:142
clang::syntax::BreakStatement::classof
static bool classof(const Node *N)
Tree.h
clang::syntax::TemplateDeclaration::getDeclaration
Declaration * getDeclaration()
Definition: Nodes.cpp:371
clang::syntax::SimpleDeclarator
A top-level declarator without parentheses.
Definition: Nodes.h:494
clang::syntax::NodeRole::Member
@ Member
clang::syntax::NestedNameSpecifier::classof
static bool classof(const Node *N)
clang::syntax::Leaf
A leaf node points to a single token.
Definition: Tree.h:132
clang::syntax::DeclaratorList::DeclaratorList
DeclaratorList()
Definition: Nodes.h:395
clang::syntax::UnaryOperatorExpression
An abstract class for prefix and postfix unary operators.
Definition: Nodes.h:155
clang::syntax::UnknownExpression::classof
static bool classof(const Node *N)
clang::syntax::NodeRole::Declarators
@ Declarators
clang::syntax::CaseStatement
case : <body>
Definition: Nodes.h:247
clang::syntax::NodeRole::Arguments
@ Arguments
clang::syntax::CaseStatement::getBody
Statement * getBody()
Definition: Nodes.cpp:241
clang::syntax::MemberPointer
Member pointer inside a declarator E.g.
Definition: Nodes.h:572
clang::syntax::NodeRole::OperatorToken
@ OperatorToken
clang::syntax::UsingNamespaceDirective::classof
static bool classof(const Node *N)
clang::syntax::NodeRole
NodeRole
A relation between a parent and child node, e.g.
Definition: Nodes.h:54
clang::syntax::MemberPointer::MemberPointer
MemberPointer()
Definition: Nodes.h:574
clang::syntax::ContinueStatement::getContinueKeyword
Leaf * getContinueKeyword()
Definition: Nodes.cpp:295
clang::syntax::ArraySubscript::ArraySubscript
ArraySubscript()
Definition: Nodes.h:517
clang
Definition: CalledOnceCheck.h:17
clang::syntax::NodeKind
NodeKind
A kind of a syntax node, used for implementing casts.
Definition: Nodes.h:32
clang::syntax::StaticAssertDeclaration::StaticAssertDeclaration
StaticAssertDeclaration()
Definition: Nodes.h:378
clang::syntax::TrailingReturnType::TrailingReturnType
TrailingReturnType()
Definition: Nodes.h:529
clang::syntax::ExplicitTemplateInstantiation::getExternKeyword
Leaf * getExternKeyword()
Definition: Nodes.cpp:381
clang::syntax::NodeRole::IntroducerKeyword
@ IntroducerKeyword
A keywords that introduces some grammar construct, e.g. 'if', 'try', etc.
clang::syntax::ExplicitTemplateInstantiation
template <declaration> Examples: template struct X<int> template void foo<int>() template int var<dou...
Definition: Nodes.h:427
clang::syntax::UnqualifiedId::classof
static bool classof(const Node *N)
clang::syntax::PrefixUnaryOperatorExpression
<operator> <operand>
Definition: Nodes.h:172
clang::syntax::ArraySubscript::getLbracket
Leaf * getLbracket()
Definition: Nodes.cpp:398
clang::syntax::CompoundStatement::getLbrace
Leaf * getLbrace()
Definition: Nodes.cpp:330
clang::syntax::ParametersAndQualifiers::getRparen
Leaf * getRparen()
Definition: Nodes.cpp:429
clang::syntax::CallArguments::classof
static bool classof(const Node *N)
clang::syntax::NodeRole::BodyStatement
@ BodyStatement
An inner statement for those that have only a single child of kind statement, e.g.
clang::syntax::UsingNamespaceDirective::UsingNamespaceDirective
UsingNamespaceDirective()
Definition: Nodes.h:455
clang::syntax::TrailingReturnType
Trailing return type after the parameter list, including the arrow token.
Definition: Nodes.h:527
clang::syntax::NodeRole::LiteralToken
@ LiteralToken
A token that represents a literal, e.g. 'nullptr', '1', 'true', etc.
clang::syntax::EmptyStatement::classof
static bool classof(const Node *N)
clang::syntax::ReturnStatement
return <expr>; return;
Definition: Nodes.h:313
clang::syntax::TypeAliasDeclaration::TypeAliasDeclaration
TypeAliasDeclaration()
Definition: Nodes.h:470
clang::syntax::NodeRole::LeftHandSide
@ LeftHandSide
clang::syntax::DeclaratorList::getDeclaratorsAndCommas
std::vector< List::ElementAndDelimiter< syntax::SimpleDeclarator > > getDeclaratorsAndCommas()
Definition: Nodes.cpp:187
clang::syntax::PostfixUnaryOperatorExpression
<operand> <operator>
Definition: Nodes.h:184
clang::syntax::TemplateDeclaration::getTemplateKeyword
Leaf * getTemplateKeyword()
Definition: Nodes.cpp:366
clang::syntax::ParenDeclarator::getRparen
Leaf * getRparen()
Definition: Nodes.cpp:394
clang::syntax::NestedNameSpecifier::getSpecifiers
std::vector< NameSpecifier * > getSpecifiers()
Definition: Nodes.cpp:110
clang::syntax::NamespaceAliasDefinition::classof
static bool classof(const Node *N)
clang::syntax::NamespaceDefinition::classof
static bool classof(const Node *N)
clang::syntax::UnknownDeclaration
Declaration of an unknown kind, e.g. not yet supported in syntax trees.
Definition: Nodes.h:361
clang::syntax::Declaration
A declaration that can appear at the top-level.
Definition: Nodes.h:354
clang::syntax::TypeAliasDeclaration::classof
static bool classof(const Node *N)
clang::syntax::CaseStatement::getCaseKeyword
Leaf * getCaseKeyword()
Definition: Nodes.cpp:231
clang::syntax::EmptyDeclaration
A semicolon in the top-level context. Does not declare anything.
Definition: Nodes.h:368
clang::syntax::NodeRole::Condition
@ Condition
clang::syntax::ParametersAndQualifiers
Parameter list for a function type and a trailing return type, if the function has one.
Definition: Nodes.h:560
clang::syntax::ParenDeclarator::getLparen
Leaf * getLparen()
Definition: Nodes.cpp:390
clang::syntax::SwitchStatement::getSwitchKeyword
Leaf * getSwitchKeyword()
Definition: Nodes.cpp:221
clang::syntax::PrefixUnaryOperatorExpression::PrefixUnaryOperatorExpression
PrefixUnaryOperatorExpression()
Definition: Nodes.h:174
clang::syntax::ParameterDeclarationList
Models a parameter-declaration-list which appears within parameters-and-qualifiers.
Definition: Nodes.h:540
clang::syntax::NodeRole::Declaration
@ Declaration
clang::syntax::RangeBasedForStatement::getBody
Statement * getBody()
Definition: Nodes.cpp:320
clang::syntax::StaticAssertDeclaration::getMessage
Expression * getMessage()
Definition: Nodes.cpp:352
clang::syntax::Statement
An abstract node for C++ statements, e.g.
Definition: Nodes.h:209
clang::syntax::DefaultStatement
default: <body>
Definition: Nodes.h:257
clang::syntax::WhileStatement
while (<cond>) <body>
Definition: Nodes.h:287
clang::syntax::UsingDeclaration
using <scope>::<name> using typename <scope>::<name>
Definition: Nodes.h:461
clang::syntax::DefaultStatement::getDefaultKeyword
Leaf * getDefaultKeyword()
Definition: Nodes.cpp:246
clang::syntax::EmptyDeclaration::classof
static bool classof(const Node *N)
clang::syntax::UnknownStatement
A statement of an unknown kind, i.e.
Definition: Nodes.h:217
clang::syntax::SwitchStatement::getBody
Statement * getBody()
Definition: Nodes.cpp:226
clang::syntax::CompoundStatement
{ statement1; statement2; … }
Definition: Nodes.h:340
clang::syntax::ArraySubscript::getRbracket
Leaf * getRbracket()
Definition: Nodes.cpp:406
clang::syntax::SwitchStatement
switch (<cond>) <body>
Definition: Nodes.h:238
clang::syntax::NodeRole::AccessToken
@ AccessToken
clang::syntax::SwitchStatement::classof
static bool classof(const Node *N)
clang::syntax::NodeRole::TemplateKeyword
@ TemplateKeyword
clang::syntax::NestedNameSpecifier
Models a nested-name-specifier.
Definition: Nodes.h:116