File indexing completed on 2026-05-10 08:37:11
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #ifndef LLVM_CLANG_TOOLING_SYNTAX_NODES_H
0022 #define LLVM_CLANG_TOOLING_SYNTAX_NODES_H
0023
0024 #include "clang/Basic/LLVM.h"
0025 #include "clang/Tooling/Syntax/Tree.h"
0026 namespace clang {
0027 namespace syntax {
0028
0029
0030
0031
0032 enum class NodeKind : uint16_t {
0033 #define CONCRETE_NODE(Kind, Base) Kind,
0034 #include "clang/Tooling/Syntax/Nodes.inc"
0035 };
0036
0037 raw_ostream &operator<<(raw_ostream &OS, NodeKind K);
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054 enum class NodeRole : uint8_t {
0055
0056
0057 Detached,
0058
0059 Unknown,
0060
0061 OpenParen,
0062
0063 CloseParen,
0064
0065 IntroducerKeyword,
0066
0067 LiteralToken,
0068
0069 ArrowToken,
0070 ExternKeyword,
0071 TemplateKeyword,
0072
0073
0074
0075 BodyStatement,
0076
0077 ListElement,
0078 ListDelimiter,
0079
0080
0081 OperatorToken,
0082 Operand,
0083 LeftHandSide,
0084 RightHandSide,
0085 ReturnValue,
0086 CaseValue,
0087 ThenStatement,
0088 ElseKeyword,
0089 ElseStatement,
0090 Expression,
0091 Statement,
0092 Condition,
0093 Message,
0094 Declarator,
0095 Declaration,
0096 Size,
0097 Parameters,
0098 TrailingReturn,
0099 UnqualifiedId,
0100 Qualifier,
0101 SubExpression,
0102 Object,
0103 AccessToken,
0104 Member,
0105 Callee,
0106 Arguments,
0107 Declarators
0108 };
0109
0110 raw_ostream &operator<<(raw_ostream &OS, NodeRole R);
0111
0112 #include "clang/Tooling/Syntax/NodeClasses.inc"
0113
0114
0115
0116 class NestedNameSpecifier final : public List {
0117 public:
0118 NestedNameSpecifier() : List(NodeKind::NestedNameSpecifier) {}
0119 static bool classof(const Node *N);
0120 std::vector<NameSpecifier *> getSpecifiers();
0121 std::vector<List::ElementAndDelimiter<syntax::NameSpecifier>>
0122 getSpecifiersAndDoubleColons();
0123 };
0124
0125
0126
0127 class UnqualifiedId final : public Tree {
0128 public:
0129 UnqualifiedId() : Tree(NodeKind::UnqualifiedId) {}
0130 static bool classof(const Node *N);
0131 };
0132
0133
0134
0135 class UnknownExpression final : public Expression {
0136 public:
0137 UnknownExpression() : Expression(NodeKind::UnknownExpression) {}
0138 static bool classof(const Node *N);
0139 };
0140
0141
0142
0143
0144
0145
0146 class CallArguments final : public List {
0147 public:
0148 CallArguments() : List(NodeKind::CallArguments) {}
0149 static bool classof(const Node *N);
0150 std::vector<Expression *> getArguments();
0151 std::vector<List::ElementAndDelimiter<Expression>> getArgumentsAndCommas();
0152 };
0153
0154
0155 class UnaryOperatorExpression : public Expression {
0156 public:
0157 UnaryOperatorExpression(NodeKind K) : Expression(K) {}
0158 static bool classof(const Node *N);
0159 Leaf *getOperatorToken();
0160 Expression *getOperand();
0161 };
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172 class PrefixUnaryOperatorExpression final : public UnaryOperatorExpression {
0173 public:
0174 PrefixUnaryOperatorExpression()
0175 : UnaryOperatorExpression(NodeKind::PrefixUnaryOperatorExpression) {}
0176 static bool classof(const Node *N);
0177 };
0178
0179
0180
0181
0182
0183
0184 class PostfixUnaryOperatorExpression final : public UnaryOperatorExpression {
0185 public:
0186 PostfixUnaryOperatorExpression()
0187 : UnaryOperatorExpression(NodeKind::PostfixUnaryOperatorExpression) {}
0188 static bool classof(const Node *N);
0189 };
0190
0191
0192
0193
0194
0195
0196
0197
0198 class BinaryOperatorExpression final : public Expression {
0199 public:
0200 BinaryOperatorExpression() : Expression(NodeKind::BinaryOperatorExpression) {}
0201 static bool classof(const Node *N);
0202 Expression *getLhs();
0203 Leaf *getOperatorToken();
0204 Expression *getRhs();
0205 };
0206
0207
0208
0209 class Statement : public Tree {
0210 public:
0211 Statement(NodeKind K) : Tree(K) {}
0212 static bool classof(const Node *N);
0213 };
0214
0215
0216
0217 class UnknownStatement final : public Statement {
0218 public:
0219 UnknownStatement() : Statement(NodeKind::UnknownStatement) {}
0220 static bool classof(const Node *N);
0221 };
0222
0223
0224 class DeclarationStatement final : public Statement {
0225 public:
0226 DeclarationStatement() : Statement(NodeKind::DeclarationStatement) {}
0227 static bool classof(const Node *N);
0228 };
0229
0230
0231 class EmptyStatement final : public Statement {
0232 public:
0233 EmptyStatement() : Statement(NodeKind::EmptyStatement) {}
0234 static bool classof(const Node *N);
0235 };
0236
0237
0238 class SwitchStatement final : public Statement {
0239 public:
0240 SwitchStatement() : Statement(NodeKind::SwitchStatement) {}
0241 static bool classof(const Node *N);
0242 Leaf *getSwitchKeyword();
0243 Statement *getBody();
0244 };
0245
0246
0247 class CaseStatement final : public Statement {
0248 public:
0249 CaseStatement() : Statement(NodeKind::CaseStatement) {}
0250 static bool classof(const Node *N);
0251 Leaf *getCaseKeyword();
0252 Expression *getCaseValue();
0253 Statement *getBody();
0254 };
0255
0256
0257 class DefaultStatement final : public Statement {
0258 public:
0259 DefaultStatement() : Statement(NodeKind::DefaultStatement) {}
0260 static bool classof(const Node *N);
0261 Leaf *getDefaultKeyword();
0262 Statement *getBody();
0263 };
0264
0265
0266
0267 class IfStatement final : public Statement {
0268 public:
0269 IfStatement() : Statement(NodeKind::IfStatement) {}
0270 static bool classof(const Node *N);
0271 Leaf *getIfKeyword();
0272 Statement *getThenStatement();
0273 Leaf *getElseKeyword();
0274 Statement *getElseStatement();
0275 };
0276
0277
0278 class ForStatement final : public Statement {
0279 public:
0280 ForStatement() : Statement(NodeKind::ForStatement) {}
0281 static bool classof(const Node *N);
0282 Leaf *getForKeyword();
0283 Statement *getBody();
0284 };
0285
0286
0287 class WhileStatement final : public Statement {
0288 public:
0289 WhileStatement() : Statement(NodeKind::WhileStatement) {}
0290 static bool classof(const Node *N);
0291 Leaf *getWhileKeyword();
0292 Statement *getBody();
0293 };
0294
0295
0296 class ContinueStatement final : public Statement {
0297 public:
0298 ContinueStatement() : Statement(NodeKind::ContinueStatement) {}
0299 static bool classof(const Node *N);
0300 Leaf *getContinueKeyword();
0301 };
0302
0303
0304 class BreakStatement final : public Statement {
0305 public:
0306 BreakStatement() : Statement(NodeKind::BreakStatement) {}
0307 static bool classof(const Node *N);
0308 Leaf *getBreakKeyword();
0309 };
0310
0311
0312
0313 class ReturnStatement final : public Statement {
0314 public:
0315 ReturnStatement() : Statement(NodeKind::ReturnStatement) {}
0316 static bool classof(const Node *N);
0317 Leaf *getReturnKeyword();
0318 Expression *getReturnValue();
0319 };
0320
0321
0322 class RangeBasedForStatement final : public Statement {
0323 public:
0324 RangeBasedForStatement() : Statement(NodeKind::RangeBasedForStatement) {}
0325 static bool classof(const Node *N);
0326 Leaf *getForKeyword();
0327 Statement *getBody();
0328 };
0329
0330
0331
0332 class ExpressionStatement final : public Statement {
0333 public:
0334 ExpressionStatement() : Statement(NodeKind::ExpressionStatement) {}
0335 static bool classof(const Node *N);
0336 Expression *getExpression();
0337 };
0338
0339
0340 class CompoundStatement final : public Statement {
0341 public:
0342 CompoundStatement() : Statement(NodeKind::CompoundStatement) {}
0343 static bool classof(const Node *N);
0344 Leaf *getLbrace();
0345
0346 std::vector<Statement *> getStatements();
0347 Leaf *getRbrace();
0348 };
0349
0350
0351
0352
0353
0354 class Declaration : public Tree {
0355 public:
0356 Declaration(NodeKind K) : Tree(K) {}
0357 static bool classof(const Node *N);
0358 };
0359
0360
0361 class UnknownDeclaration final : public Declaration {
0362 public:
0363 UnknownDeclaration() : Declaration(NodeKind::UnknownDeclaration) {}
0364 static bool classof(const Node *N);
0365 };
0366
0367
0368 class EmptyDeclaration final : public Declaration {
0369 public:
0370 EmptyDeclaration() : Declaration(NodeKind::EmptyDeclaration) {}
0371 static bool classof(const Node *N);
0372 };
0373
0374
0375
0376 class StaticAssertDeclaration final : public Declaration {
0377 public:
0378 StaticAssertDeclaration() : Declaration(NodeKind::StaticAssertDeclaration) {}
0379 static bool classof(const Node *N);
0380 Expression *getCondition();
0381 Expression *getMessage();
0382 };
0383
0384
0385
0386 class LinkageSpecificationDeclaration final : public Declaration {
0387 public:
0388 LinkageSpecificationDeclaration()
0389 : Declaration(NodeKind::LinkageSpecificationDeclaration) {}
0390 static bool classof(const Node *N);
0391 };
0392
0393 class DeclaratorList final : public List {
0394 public:
0395 DeclaratorList() : List(NodeKind::DeclaratorList) {}
0396 static bool classof(const Node *N);
0397 std::vector<SimpleDeclarator *> getDeclarators();
0398 std::vector<List::ElementAndDelimiter<syntax::SimpleDeclarator>>
0399 getDeclaratorsAndCommas();
0400 };
0401
0402
0403
0404
0405 class SimpleDeclaration final : public Declaration {
0406 public:
0407 SimpleDeclaration() : Declaration(NodeKind::SimpleDeclaration) {}
0408 static bool classof(const Node *N);
0409
0410 std::vector<SimpleDeclarator *> getDeclarators();
0411 };
0412
0413
0414 class TemplateDeclaration final : public Declaration {
0415 public:
0416 TemplateDeclaration() : Declaration(NodeKind::TemplateDeclaration) {}
0417 static bool classof(const Node *N);
0418 Leaf *getTemplateKeyword();
0419 Declaration *getDeclaration();
0420 };
0421
0422
0423
0424
0425
0426
0427 class ExplicitTemplateInstantiation final : public Declaration {
0428 public:
0429 ExplicitTemplateInstantiation()
0430 : Declaration(NodeKind::ExplicitTemplateInstantiation) {}
0431 static bool classof(const Node *N);
0432 Leaf *getTemplateKeyword();
0433 Leaf *getExternKeyword();
0434 Declaration *getDeclaration();
0435 };
0436
0437
0438 class NamespaceDefinition final : public Declaration {
0439 public:
0440 NamespaceDefinition() : Declaration(NodeKind::NamespaceDefinition) {}
0441 static bool classof(const Node *N);
0442 };
0443
0444
0445 class NamespaceAliasDefinition final : public Declaration {
0446 public:
0447 NamespaceAliasDefinition()
0448 : Declaration(NodeKind::NamespaceAliasDefinition) {}
0449 static bool classof(const Node *N);
0450 };
0451
0452
0453 class UsingNamespaceDirective final : public Declaration {
0454 public:
0455 UsingNamespaceDirective() : Declaration(NodeKind::UsingNamespaceDirective) {}
0456 static bool classof(const Node *N);
0457 };
0458
0459
0460
0461 class UsingDeclaration final : public Declaration {
0462 public:
0463 UsingDeclaration() : Declaration(NodeKind::UsingDeclaration) {}
0464 static bool classof(const Node *N);
0465 };
0466
0467
0468 class TypeAliasDeclaration final : public Declaration {
0469 public:
0470 TypeAliasDeclaration() : Declaration(NodeKind::TypeAliasDeclaration) {}
0471 static bool classof(const Node *N);
0472 };
0473
0474
0475
0476
0477
0478
0479
0480
0481
0482
0483
0484
0485
0486 class Declarator : public Tree {
0487 public:
0488 Declarator(NodeKind K) : Tree(K) {}
0489 static bool classof(const Node *N);
0490 };
0491
0492
0493
0494 class SimpleDeclarator final : public Declarator {
0495 public:
0496 SimpleDeclarator() : Declarator(NodeKind::SimpleDeclarator) {}
0497 static bool classof(const Node *N);
0498 };
0499
0500
0501
0502
0503 class ParenDeclarator final : public Declarator {
0504 public:
0505 ParenDeclarator() : Declarator(NodeKind::ParenDeclarator) {}
0506 static bool classof(const Node *N);
0507 Leaf *getLparen();
0508 Leaf *getRparen();
0509 };
0510
0511
0512
0513
0514
0515 class ArraySubscript final : public Tree {
0516 public:
0517 ArraySubscript() : Tree(NodeKind::ArraySubscript) {}
0518 static bool classof(const Node *N);
0519
0520 Leaf *getLbracket();
0521 Expression *getSize();
0522 Leaf *getRbracket();
0523 };
0524
0525
0526
0527 class TrailingReturnType final : public Tree {
0528 public:
0529 TrailingReturnType() : Tree(NodeKind::TrailingReturnType) {}
0530 static bool classof(const Node *N);
0531
0532 Leaf *getArrowToken();
0533
0534
0535 SimpleDeclarator *getDeclarator();
0536 };
0537
0538
0539
0540 class ParameterDeclarationList final : public List {
0541 public:
0542 ParameterDeclarationList() : List(NodeKind::ParameterDeclarationList) {}
0543 static bool classof(const Node *N);
0544 std::vector<SimpleDeclaration *> getParameterDeclarations();
0545 std::vector<List::ElementAndDelimiter<syntax::SimpleDeclaration>>
0546 getParametersAndCommas();
0547 };
0548
0549
0550
0551
0552
0553
0554
0555
0556
0557
0558
0559
0560 class ParametersAndQualifiers final : public Tree {
0561 public:
0562 ParametersAndQualifiers() : Tree(NodeKind::ParametersAndQualifiers) {}
0563 static bool classof(const Node *N);
0564 Leaf *getLparen();
0565 ParameterDeclarationList *getParameters();
0566 Leaf *getRparen();
0567 TrailingReturnType *getTrailingReturn();
0568 };
0569
0570
0571
0572 class MemberPointer final : public Tree {
0573 public:
0574 MemberPointer() : Tree(NodeKind::MemberPointer) {}
0575 static bool classof(const Node *N);
0576 };
0577
0578 #define CONCRETE_NODE(Kind, Base) \
0579 inline bool Kind::classof(const Node *N) { \
0580 return N->getKind() == NodeKind::Kind; \
0581 }
0582 #define ABSTRACT_NODE(Kind, Base, First, Last) \
0583 inline bool Kind::classof(const Node *N) { \
0584 return N->getKind() >= NodeKind::First && N->getKind() <= NodeKind::Last; \
0585 }
0586 #include "clang/Tooling/Syntax/Nodes.inc"
0587
0588 }
0589 }
0590 #endif