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