forked from OSchip/llvm-project
Revert "[Syntax] Add minimal TableGen for syntax nodes. NFC"
This reverts commit 55120f74ca
.
Segfaults during build:
http://lab.llvm.org:8011/#/builders/36/builds/1310
This commit is contained in:
parent
2319c49339
commit
09c6259d6d
|
@ -5,4 +5,3 @@ add_subdirectory(Parse)
|
||||||
add_subdirectory(Sema)
|
add_subdirectory(Sema)
|
||||||
add_subdirectory(Serialization)
|
add_subdirectory(Serialization)
|
||||||
add_subdirectory(StaticAnalyzer/Checkers)
|
add_subdirectory(StaticAnalyzer/Checkers)
|
||||||
add_subdirectory(Tooling/Syntax)
|
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
clang_tablegen(Nodes.inc -gen-clang-syntax-node-list
|
|
||||||
SOURCE Nodes.td
|
|
||||||
TARGET ClangSyntaxNodeList)
|
|
||||||
|
|
|
@ -35,8 +35,82 @@ namespace syntax {
|
||||||
/// blocks of enumerator constants must correspond to the inheritance hierarchy
|
/// blocks of enumerator constants must correspond to the inheritance hierarchy
|
||||||
/// of syntax::Node.
|
/// of syntax::Node.
|
||||||
enum class NodeKind : uint16_t {
|
enum class NodeKind : uint16_t {
|
||||||
#define CONCRETE_NODE(Kind, Base) Kind,
|
Leaf,
|
||||||
#include "clang/Tooling/Syntax/Nodes.inc"
|
TranslationUnit,
|
||||||
|
|
||||||
|
// Expressions.
|
||||||
|
UnknownExpression,
|
||||||
|
PrefixUnaryOperatorExpression,
|
||||||
|
PostfixUnaryOperatorExpression,
|
||||||
|
BinaryOperatorExpression,
|
||||||
|
ParenExpression,
|
||||||
|
IntegerLiteralExpression,
|
||||||
|
CharacterLiteralExpression,
|
||||||
|
FloatingLiteralExpression,
|
||||||
|
StringLiteralExpression,
|
||||||
|
BoolLiteralExpression,
|
||||||
|
CxxNullPtrExpression,
|
||||||
|
IntegerUserDefinedLiteralExpression,
|
||||||
|
FloatUserDefinedLiteralExpression,
|
||||||
|
CharUserDefinedLiteralExpression,
|
||||||
|
StringUserDefinedLiteralExpression,
|
||||||
|
IdExpression,
|
||||||
|
MemberExpression,
|
||||||
|
ThisExpression,
|
||||||
|
CallExpression,
|
||||||
|
|
||||||
|
// Statements.
|
||||||
|
UnknownStatement,
|
||||||
|
DeclarationStatement,
|
||||||
|
EmptyStatement,
|
||||||
|
SwitchStatement,
|
||||||
|
CaseStatement,
|
||||||
|
DefaultStatement,
|
||||||
|
IfStatement,
|
||||||
|
ForStatement,
|
||||||
|
WhileStatement,
|
||||||
|
ContinueStatement,
|
||||||
|
BreakStatement,
|
||||||
|
ReturnStatement,
|
||||||
|
RangeBasedForStatement,
|
||||||
|
ExpressionStatement,
|
||||||
|
CompoundStatement,
|
||||||
|
|
||||||
|
// Declarations.
|
||||||
|
UnknownDeclaration,
|
||||||
|
EmptyDeclaration,
|
||||||
|
StaticAssertDeclaration,
|
||||||
|
LinkageSpecificationDeclaration,
|
||||||
|
SimpleDeclaration,
|
||||||
|
TemplateDeclaration,
|
||||||
|
ExplicitTemplateInstantiation,
|
||||||
|
NamespaceDefinition,
|
||||||
|
NamespaceAliasDefinition,
|
||||||
|
UsingNamespaceDirective,
|
||||||
|
UsingDeclaration,
|
||||||
|
TypeAliasDeclaration,
|
||||||
|
|
||||||
|
// Declarators.
|
||||||
|
SimpleDeclarator,
|
||||||
|
ParenDeclarator,
|
||||||
|
|
||||||
|
ArraySubscript,
|
||||||
|
TrailingReturnType,
|
||||||
|
ParametersAndQualifiers,
|
||||||
|
MemberPointer,
|
||||||
|
UnqualifiedId,
|
||||||
|
|
||||||
|
// Lists
|
||||||
|
DeclaratorList,
|
||||||
|
ParameterDeclarationList,
|
||||||
|
CallArguments,
|
||||||
|
NestedNameSpecifier,
|
||||||
|
|
||||||
|
// Name Specifiers.
|
||||||
|
GlobalNameSpecifier,
|
||||||
|
DecltypeNameSpecifier,
|
||||||
|
IdentifierNameSpecifier,
|
||||||
|
SimpleTemplateNameSpecifier,
|
||||||
};
|
};
|
||||||
/// For debugging purposes.
|
/// For debugging purposes.
|
||||||
raw_ostream &operator<<(raw_ostream &OS, NodeKind K);
|
raw_ostream &operator<<(raw_ostream &OS, NodeKind K);
|
||||||
|
@ -120,7 +194,9 @@ class SimpleDeclarator;
|
||||||
class TranslationUnit final : public Tree {
|
class TranslationUnit final : public Tree {
|
||||||
public:
|
public:
|
||||||
TranslationUnit() : Tree(NodeKind::TranslationUnit) {}
|
TranslationUnit() : Tree(NodeKind::TranslationUnit) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::TranslationUnit;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A base class for all expressions. Note that expressions are not statements,
|
/// A base class for all expressions. Note that expressions are not statements,
|
||||||
|
@ -128,7 +204,10 @@ public:
|
||||||
class Expression : public Tree {
|
class Expression : public Tree {
|
||||||
public:
|
public:
|
||||||
Expression(NodeKind K) : Tree(K) {}
|
Expression(NodeKind K) : Tree(K) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return NodeKind::UnknownExpression <= N->getKind() &&
|
||||||
|
N->getKind() <= NodeKind::CallExpression;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A sequence of these specifiers make a `nested-name-specifier`.
|
/// A sequence of these specifiers make a `nested-name-specifier`.
|
||||||
|
@ -136,7 +215,12 @@ public:
|
||||||
class NameSpecifier : public Tree {
|
class NameSpecifier : public Tree {
|
||||||
public:
|
public:
|
||||||
NameSpecifier(NodeKind K) : Tree(K) {}
|
NameSpecifier(NodeKind K) : Tree(K) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::GlobalNameSpecifier ||
|
||||||
|
N->getKind() == NodeKind::DecltypeNameSpecifier ||
|
||||||
|
N->getKind() == NodeKind::IdentifierNameSpecifier ||
|
||||||
|
N->getKind() == NodeKind::SimpleTemplateNameSpecifier;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The global namespace name specifier, this specifier doesn't correspond to a
|
/// The global namespace name specifier, this specifier doesn't correspond to a
|
||||||
|
@ -146,7 +230,9 @@ public:
|
||||||
class GlobalNameSpecifier final : public NameSpecifier {
|
class GlobalNameSpecifier final : public NameSpecifier {
|
||||||
public:
|
public:
|
||||||
GlobalNameSpecifier() : NameSpecifier(NodeKind::GlobalNameSpecifier) {}
|
GlobalNameSpecifier() : NameSpecifier(NodeKind::GlobalNameSpecifier) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::GlobalNameSpecifier;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A name specifier holding a decltype, of the form: `decltype ( expression ) `
|
/// A name specifier holding a decltype, of the form: `decltype ( expression ) `
|
||||||
|
@ -154,7 +240,9 @@ public:
|
||||||
class DecltypeNameSpecifier final : public NameSpecifier {
|
class DecltypeNameSpecifier final : public NameSpecifier {
|
||||||
public:
|
public:
|
||||||
DecltypeNameSpecifier() : NameSpecifier(NodeKind::DecltypeNameSpecifier) {}
|
DecltypeNameSpecifier() : NameSpecifier(NodeKind::DecltypeNameSpecifier) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::DecltypeNameSpecifier;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A identifier name specifier, of the form `identifier`
|
/// A identifier name specifier, of the form `identifier`
|
||||||
|
@ -163,7 +251,9 @@ class IdentifierNameSpecifier final : public NameSpecifier {
|
||||||
public:
|
public:
|
||||||
IdentifierNameSpecifier()
|
IdentifierNameSpecifier()
|
||||||
: NameSpecifier(NodeKind::IdentifierNameSpecifier) {}
|
: NameSpecifier(NodeKind::IdentifierNameSpecifier) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::IdentifierNameSpecifier;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A name specifier with a simple-template-id, of the form `template_opt
|
/// A name specifier with a simple-template-id, of the form `template_opt
|
||||||
|
@ -173,7 +263,9 @@ class SimpleTemplateNameSpecifier final : public NameSpecifier {
|
||||||
public:
|
public:
|
||||||
SimpleTemplateNameSpecifier()
|
SimpleTemplateNameSpecifier()
|
||||||
: NameSpecifier(NodeKind::SimpleTemplateNameSpecifier) {}
|
: NameSpecifier(NodeKind::SimpleTemplateNameSpecifier) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::SimpleTemplateNameSpecifier;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Models a `nested-name-specifier`. C++ [expr.prim.id.qual]
|
/// Models a `nested-name-specifier`. C++ [expr.prim.id.qual]
|
||||||
|
@ -181,7 +273,9 @@ public:
|
||||||
class NestedNameSpecifier final : public List {
|
class NestedNameSpecifier final : public List {
|
||||||
public:
|
public:
|
||||||
NestedNameSpecifier() : List(NodeKind::NestedNameSpecifier) {}
|
NestedNameSpecifier() : List(NodeKind::NestedNameSpecifier) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() <= NodeKind::NestedNameSpecifier;
|
||||||
|
}
|
||||||
std::vector<NameSpecifier *> getSpecifiers();
|
std::vector<NameSpecifier *> getSpecifiers();
|
||||||
std::vector<List::ElementAndDelimiter<syntax::NameSpecifier>>
|
std::vector<List::ElementAndDelimiter<syntax::NameSpecifier>>
|
||||||
getSpecifiersAndDoubleColons();
|
getSpecifiersAndDoubleColons();
|
||||||
|
@ -192,7 +286,9 @@ public:
|
||||||
class UnqualifiedId final : public Tree {
|
class UnqualifiedId final : public Tree {
|
||||||
public:
|
public:
|
||||||
UnqualifiedId() : Tree(NodeKind::UnqualifiedId) {}
|
UnqualifiedId() : Tree(NodeKind::UnqualifiedId) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::UnqualifiedId;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Models an `id-expression`, e.g. `std::vector<int>::size`.
|
/// Models an `id-expression`, e.g. `std::vector<int>::size`.
|
||||||
|
@ -205,7 +301,9 @@ public:
|
||||||
class IdExpression final : public Expression {
|
class IdExpression final : public Expression {
|
||||||
public:
|
public:
|
||||||
IdExpression() : Expression(NodeKind::IdExpression) {}
|
IdExpression() : Expression(NodeKind::IdExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::IdExpression;
|
||||||
|
}
|
||||||
NestedNameSpecifier *getQualifier();
|
NestedNameSpecifier *getQualifier();
|
||||||
Leaf *getTemplateKeyword();
|
Leaf *getTemplateKeyword();
|
||||||
UnqualifiedId *getUnqualifiedId();
|
UnqualifiedId *getUnqualifiedId();
|
||||||
|
@ -216,14 +314,18 @@ public:
|
||||||
class UnknownExpression final : public Expression {
|
class UnknownExpression final : public Expression {
|
||||||
public:
|
public:
|
||||||
UnknownExpression() : Expression(NodeKind::UnknownExpression) {}
|
UnknownExpression() : Expression(NodeKind::UnknownExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::UnknownExpression;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Models a this expression `this`. C++ [expr.prim.this]
|
/// Models a this expression `this`. C++ [expr.prim.this]
|
||||||
class ThisExpression final : public Expression {
|
class ThisExpression final : public Expression {
|
||||||
public:
|
public:
|
||||||
ThisExpression() : Expression(NodeKind::ThisExpression) {}
|
ThisExpression() : Expression(NodeKind::ThisExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::ThisExpression;
|
||||||
|
}
|
||||||
Leaf *getThisKeyword();
|
Leaf *getThisKeyword();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -235,7 +337,9 @@ public:
|
||||||
class CallArguments final : public List {
|
class CallArguments final : public List {
|
||||||
public:
|
public:
|
||||||
CallArguments() : List(NodeKind::CallArguments) {}
|
CallArguments() : List(NodeKind::CallArguments) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() <= NodeKind::CallArguments;
|
||||||
|
}
|
||||||
std::vector<Expression *> getArguments();
|
std::vector<Expression *> getArguments();
|
||||||
std::vector<List::ElementAndDelimiter<Expression>> getArgumentsAndCommas();
|
std::vector<List::ElementAndDelimiter<Expression>> getArgumentsAndCommas();
|
||||||
};
|
};
|
||||||
|
@ -247,7 +351,9 @@ public:
|
||||||
class CallExpression final : public Expression {
|
class CallExpression final : public Expression {
|
||||||
public:
|
public:
|
||||||
CallExpression() : Expression(NodeKind::CallExpression) {}
|
CallExpression() : Expression(NodeKind::CallExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::CallExpression;
|
||||||
|
}
|
||||||
Expression *getCallee();
|
Expression *getCallee();
|
||||||
Leaf *getOpenParen();
|
Leaf *getOpenParen();
|
||||||
CallArguments *getArguments();
|
CallArguments *getArguments();
|
||||||
|
@ -259,7 +365,9 @@ public:
|
||||||
class ParenExpression final : public Expression {
|
class ParenExpression final : public Expression {
|
||||||
public:
|
public:
|
||||||
ParenExpression() : Expression(NodeKind::ParenExpression) {}
|
ParenExpression() : Expression(NodeKind::ParenExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::ParenExpression;
|
||||||
|
}
|
||||||
Leaf *getOpenParen();
|
Leaf *getOpenParen();
|
||||||
Expression *getSubExpression();
|
Expression *getSubExpression();
|
||||||
Leaf *getCloseParen();
|
Leaf *getCloseParen();
|
||||||
|
@ -276,7 +384,9 @@ public:
|
||||||
class MemberExpression final : public Expression {
|
class MemberExpression final : public Expression {
|
||||||
public:
|
public:
|
||||||
MemberExpression() : Expression(NodeKind::MemberExpression) {}
|
MemberExpression() : Expression(NodeKind::MemberExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::MemberExpression;
|
||||||
|
}
|
||||||
Expression *getObject();
|
Expression *getObject();
|
||||||
Leaf *getAccessToken();
|
Leaf *getAccessToken();
|
||||||
Leaf *getTemplateKeyword();
|
Leaf *getTemplateKeyword();
|
||||||
|
@ -287,7 +397,18 @@ public:
|
||||||
class LiteralExpression : public Expression {
|
class LiteralExpression : public Expression {
|
||||||
public:
|
public:
|
||||||
LiteralExpression(NodeKind K) : Expression(K) {}
|
LiteralExpression(NodeKind K) : Expression(K) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::IntegerLiteralExpression ||
|
||||||
|
N->getKind() == NodeKind::CharacterLiteralExpression ||
|
||||||
|
N->getKind() == NodeKind::FloatingLiteralExpression ||
|
||||||
|
N->getKind() == NodeKind::StringLiteralExpression ||
|
||||||
|
N->getKind() == NodeKind::BoolLiteralExpression ||
|
||||||
|
N->getKind() == NodeKind::CxxNullPtrExpression ||
|
||||||
|
N->getKind() == NodeKind::IntegerUserDefinedLiteralExpression ||
|
||||||
|
N->getKind() == NodeKind::FloatUserDefinedLiteralExpression ||
|
||||||
|
N->getKind() == NodeKind::CharUserDefinedLiteralExpression ||
|
||||||
|
N->getKind() == NodeKind::StringUserDefinedLiteralExpression;
|
||||||
|
}
|
||||||
Leaf *getLiteralToken();
|
Leaf *getLiteralToken();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -296,7 +417,9 @@ class IntegerLiteralExpression final : public LiteralExpression {
|
||||||
public:
|
public:
|
||||||
IntegerLiteralExpression()
|
IntegerLiteralExpression()
|
||||||
: LiteralExpression(NodeKind::IntegerLiteralExpression) {}
|
: LiteralExpression(NodeKind::IntegerLiteralExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::IntegerLiteralExpression;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Expression for character literals. C++ [lex.ccon]
|
/// Expression for character literals. C++ [lex.ccon]
|
||||||
|
@ -304,7 +427,9 @@ class CharacterLiteralExpression final : public LiteralExpression {
|
||||||
public:
|
public:
|
||||||
CharacterLiteralExpression()
|
CharacterLiteralExpression()
|
||||||
: LiteralExpression(NodeKind::CharacterLiteralExpression) {}
|
: LiteralExpression(NodeKind::CharacterLiteralExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::CharacterLiteralExpression;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Expression for floating-point literals. C++ [lex.fcon]
|
/// Expression for floating-point literals. C++ [lex.fcon]
|
||||||
|
@ -312,7 +437,9 @@ class FloatingLiteralExpression final : public LiteralExpression {
|
||||||
public:
|
public:
|
||||||
FloatingLiteralExpression()
|
FloatingLiteralExpression()
|
||||||
: LiteralExpression(NodeKind::FloatingLiteralExpression) {}
|
: LiteralExpression(NodeKind::FloatingLiteralExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::FloatingLiteralExpression;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Expression for string-literals. C++ [lex.string]
|
/// Expression for string-literals. C++ [lex.string]
|
||||||
|
@ -320,7 +447,9 @@ class StringLiteralExpression final : public LiteralExpression {
|
||||||
public:
|
public:
|
||||||
StringLiteralExpression()
|
StringLiteralExpression()
|
||||||
: LiteralExpression(NodeKind::StringLiteralExpression) {}
|
: LiteralExpression(NodeKind::StringLiteralExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::StringLiteralExpression;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Expression for boolean literals. C++ [lex.bool]
|
/// Expression for boolean literals. C++ [lex.bool]
|
||||||
|
@ -328,14 +457,18 @@ class BoolLiteralExpression final : public LiteralExpression {
|
||||||
public:
|
public:
|
||||||
BoolLiteralExpression()
|
BoolLiteralExpression()
|
||||||
: LiteralExpression(NodeKind::BoolLiteralExpression) {}
|
: LiteralExpression(NodeKind::BoolLiteralExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::BoolLiteralExpression;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Expression for the `nullptr` literal. C++ [lex.nullptr]
|
/// Expression for the `nullptr` literal. C++ [lex.nullptr]
|
||||||
class CxxNullPtrExpression final : public LiteralExpression {
|
class CxxNullPtrExpression final : public LiteralExpression {
|
||||||
public:
|
public:
|
||||||
CxxNullPtrExpression() : LiteralExpression(NodeKind::CxxNullPtrExpression) {}
|
CxxNullPtrExpression() : LiteralExpression(NodeKind::CxxNullPtrExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::CxxNullPtrExpression;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Expression for user-defined literal. C++ [lex.ext]
|
/// Expression for user-defined literal. C++ [lex.ext]
|
||||||
|
@ -347,7 +480,12 @@ public:
|
||||||
class UserDefinedLiteralExpression : public LiteralExpression {
|
class UserDefinedLiteralExpression : public LiteralExpression {
|
||||||
public:
|
public:
|
||||||
UserDefinedLiteralExpression(NodeKind K) : LiteralExpression(K) {}
|
UserDefinedLiteralExpression(NodeKind K) : LiteralExpression(K) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::IntegerUserDefinedLiteralExpression ||
|
||||||
|
N->getKind() == NodeKind::FloatUserDefinedLiteralExpression ||
|
||||||
|
N->getKind() == NodeKind::CharUserDefinedLiteralExpression ||
|
||||||
|
N->getKind() == NodeKind::StringUserDefinedLiteralExpression;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Expression for user-defined-integer-literal. C++ [lex.ext]
|
/// Expression for user-defined-integer-literal. C++ [lex.ext]
|
||||||
|
@ -357,7 +495,9 @@ public:
|
||||||
IntegerUserDefinedLiteralExpression()
|
IntegerUserDefinedLiteralExpression()
|
||||||
: UserDefinedLiteralExpression(
|
: UserDefinedLiteralExpression(
|
||||||
NodeKind::IntegerUserDefinedLiteralExpression) {}
|
NodeKind::IntegerUserDefinedLiteralExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::IntegerUserDefinedLiteralExpression;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Expression for user-defined-floating-point-literal. C++ [lex.ext]
|
/// Expression for user-defined-floating-point-literal. C++ [lex.ext]
|
||||||
|
@ -367,7 +507,9 @@ public:
|
||||||
FloatUserDefinedLiteralExpression()
|
FloatUserDefinedLiteralExpression()
|
||||||
: UserDefinedLiteralExpression(
|
: UserDefinedLiteralExpression(
|
||||||
NodeKind::FloatUserDefinedLiteralExpression) {}
|
NodeKind::FloatUserDefinedLiteralExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::FloatUserDefinedLiteralExpression;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Expression for user-defined-character-literal. C++ [lex.ext]
|
/// Expression for user-defined-character-literal. C++ [lex.ext]
|
||||||
|
@ -377,7 +519,9 @@ public:
|
||||||
CharUserDefinedLiteralExpression()
|
CharUserDefinedLiteralExpression()
|
||||||
: UserDefinedLiteralExpression(
|
: UserDefinedLiteralExpression(
|
||||||
NodeKind::CharUserDefinedLiteralExpression) {}
|
NodeKind::CharUserDefinedLiteralExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::CharUserDefinedLiteralExpression;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Expression for user-defined-string-literal. C++ [lex.ext]
|
/// Expression for user-defined-string-literal. C++ [lex.ext]
|
||||||
|
@ -387,14 +531,19 @@ public:
|
||||||
StringUserDefinedLiteralExpression()
|
StringUserDefinedLiteralExpression()
|
||||||
: UserDefinedLiteralExpression(
|
: UserDefinedLiteralExpression(
|
||||||
NodeKind::StringUserDefinedLiteralExpression) {}
|
NodeKind::StringUserDefinedLiteralExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::StringUserDefinedLiteralExpression;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// An abstract class for prefix and postfix unary operators.
|
/// An abstract class for prefix and postfix unary operators.
|
||||||
class UnaryOperatorExpression : public Expression {
|
class UnaryOperatorExpression : public Expression {
|
||||||
public:
|
public:
|
||||||
UnaryOperatorExpression(NodeKind K) : Expression(K) {}
|
UnaryOperatorExpression(NodeKind K) : Expression(K) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::PrefixUnaryOperatorExpression ||
|
||||||
|
N->getKind() == NodeKind::PostfixUnaryOperatorExpression;
|
||||||
|
}
|
||||||
Leaf *getOperatorToken();
|
Leaf *getOperatorToken();
|
||||||
Expression *getOperand();
|
Expression *getOperand();
|
||||||
};
|
};
|
||||||
|
@ -412,7 +561,9 @@ class PrefixUnaryOperatorExpression final : public UnaryOperatorExpression {
|
||||||
public:
|
public:
|
||||||
PrefixUnaryOperatorExpression()
|
PrefixUnaryOperatorExpression()
|
||||||
: UnaryOperatorExpression(NodeKind::PrefixUnaryOperatorExpression) {}
|
: UnaryOperatorExpression(NodeKind::PrefixUnaryOperatorExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::PrefixUnaryOperatorExpression;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <operand> <operator>
|
/// <operand> <operator>
|
||||||
|
@ -424,7 +575,9 @@ class PostfixUnaryOperatorExpression final : public UnaryOperatorExpression {
|
||||||
public:
|
public:
|
||||||
PostfixUnaryOperatorExpression()
|
PostfixUnaryOperatorExpression()
|
||||||
: UnaryOperatorExpression(NodeKind::PostfixUnaryOperatorExpression) {}
|
: UnaryOperatorExpression(NodeKind::PostfixUnaryOperatorExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::PostfixUnaryOperatorExpression;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <lhs> <operator> <rhs>
|
/// <lhs> <operator> <rhs>
|
||||||
|
@ -437,7 +590,9 @@ public:
|
||||||
class BinaryOperatorExpression final : public Expression {
|
class BinaryOperatorExpression final : public Expression {
|
||||||
public:
|
public:
|
||||||
BinaryOperatorExpression() : Expression(NodeKind::BinaryOperatorExpression) {}
|
BinaryOperatorExpression() : Expression(NodeKind::BinaryOperatorExpression) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::BinaryOperatorExpression;
|
||||||
|
}
|
||||||
Expression *getLhs();
|
Expression *getLhs();
|
||||||
Leaf *getOperatorToken();
|
Leaf *getOperatorToken();
|
||||||
Expression *getRhs();
|
Expression *getRhs();
|
||||||
|
@ -448,7 +603,10 @@ public:
|
||||||
class Statement : public Tree {
|
class Statement : public Tree {
|
||||||
public:
|
public:
|
||||||
Statement(NodeKind K) : Tree(K) {}
|
Statement(NodeKind K) : Tree(K) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return NodeKind::UnknownStatement <= N->getKind() &&
|
||||||
|
N->getKind() <= NodeKind::CompoundStatement;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A statement of an unknown kind, i.e. one not currently handled by the syntax
|
/// A statement of an unknown kind, i.e. one not currently handled by the syntax
|
||||||
|
@ -456,28 +614,36 @@ public:
|
||||||
class UnknownStatement final : public Statement {
|
class UnknownStatement final : public Statement {
|
||||||
public:
|
public:
|
||||||
UnknownStatement() : Statement(NodeKind::UnknownStatement) {}
|
UnknownStatement() : Statement(NodeKind::UnknownStatement) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::UnknownStatement;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// E.g. 'int a, b = 10;'
|
/// E.g. 'int a, b = 10;'
|
||||||
class DeclarationStatement final : public Statement {
|
class DeclarationStatement final : public Statement {
|
||||||
public:
|
public:
|
||||||
DeclarationStatement() : Statement(NodeKind::DeclarationStatement) {}
|
DeclarationStatement() : Statement(NodeKind::DeclarationStatement) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::DeclarationStatement;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The no-op statement, i.e. ';'.
|
/// The no-op statement, i.e. ';'.
|
||||||
class EmptyStatement final : public Statement {
|
class EmptyStatement final : public Statement {
|
||||||
public:
|
public:
|
||||||
EmptyStatement() : Statement(NodeKind::EmptyStatement) {}
|
EmptyStatement() : Statement(NodeKind::EmptyStatement) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::EmptyStatement;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// switch (<cond>) <body>
|
/// switch (<cond>) <body>
|
||||||
class SwitchStatement final : public Statement {
|
class SwitchStatement final : public Statement {
|
||||||
public:
|
public:
|
||||||
SwitchStatement() : Statement(NodeKind::SwitchStatement) {}
|
SwitchStatement() : Statement(NodeKind::SwitchStatement) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::SwitchStatement;
|
||||||
|
}
|
||||||
Leaf *getSwitchKeyword();
|
Leaf *getSwitchKeyword();
|
||||||
Statement *getBody();
|
Statement *getBody();
|
||||||
};
|
};
|
||||||
|
@ -486,7 +652,9 @@ public:
|
||||||
class CaseStatement final : public Statement {
|
class CaseStatement final : public Statement {
|
||||||
public:
|
public:
|
||||||
CaseStatement() : Statement(NodeKind::CaseStatement) {}
|
CaseStatement() : Statement(NodeKind::CaseStatement) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::CaseStatement;
|
||||||
|
}
|
||||||
Leaf *getCaseKeyword();
|
Leaf *getCaseKeyword();
|
||||||
Expression *getCaseValue();
|
Expression *getCaseValue();
|
||||||
Statement *getBody();
|
Statement *getBody();
|
||||||
|
@ -496,7 +664,9 @@ public:
|
||||||
class DefaultStatement final : public Statement {
|
class DefaultStatement final : public Statement {
|
||||||
public:
|
public:
|
||||||
DefaultStatement() : Statement(NodeKind::DefaultStatement) {}
|
DefaultStatement() : Statement(NodeKind::DefaultStatement) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::DefaultStatement;
|
||||||
|
}
|
||||||
Leaf *getDefaultKeyword();
|
Leaf *getDefaultKeyword();
|
||||||
Statement *getBody();
|
Statement *getBody();
|
||||||
};
|
};
|
||||||
|
@ -506,7 +676,9 @@ public:
|
||||||
class IfStatement final : public Statement {
|
class IfStatement final : public Statement {
|
||||||
public:
|
public:
|
||||||
IfStatement() : Statement(NodeKind::IfStatement) {}
|
IfStatement() : Statement(NodeKind::IfStatement) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::IfStatement;
|
||||||
|
}
|
||||||
Leaf *getIfKeyword();
|
Leaf *getIfKeyword();
|
||||||
Statement *getThenStatement();
|
Statement *getThenStatement();
|
||||||
Leaf *getElseKeyword();
|
Leaf *getElseKeyword();
|
||||||
|
@ -517,7 +689,9 @@ public:
|
||||||
class ForStatement final : public Statement {
|
class ForStatement final : public Statement {
|
||||||
public:
|
public:
|
||||||
ForStatement() : Statement(NodeKind::ForStatement) {}
|
ForStatement() : Statement(NodeKind::ForStatement) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::ForStatement;
|
||||||
|
}
|
||||||
Leaf *getForKeyword();
|
Leaf *getForKeyword();
|
||||||
Statement *getBody();
|
Statement *getBody();
|
||||||
};
|
};
|
||||||
|
@ -526,7 +700,9 @@ public:
|
||||||
class WhileStatement final : public Statement {
|
class WhileStatement final : public Statement {
|
||||||
public:
|
public:
|
||||||
WhileStatement() : Statement(NodeKind::WhileStatement) {}
|
WhileStatement() : Statement(NodeKind::WhileStatement) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::WhileStatement;
|
||||||
|
}
|
||||||
Leaf *getWhileKeyword();
|
Leaf *getWhileKeyword();
|
||||||
Statement *getBody();
|
Statement *getBody();
|
||||||
};
|
};
|
||||||
|
@ -535,7 +711,9 @@ public:
|
||||||
class ContinueStatement final : public Statement {
|
class ContinueStatement final : public Statement {
|
||||||
public:
|
public:
|
||||||
ContinueStatement() : Statement(NodeKind::ContinueStatement) {}
|
ContinueStatement() : Statement(NodeKind::ContinueStatement) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::ContinueStatement;
|
||||||
|
}
|
||||||
Leaf *getContinueKeyword();
|
Leaf *getContinueKeyword();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -543,7 +721,9 @@ public:
|
||||||
class BreakStatement final : public Statement {
|
class BreakStatement final : public Statement {
|
||||||
public:
|
public:
|
||||||
BreakStatement() : Statement(NodeKind::BreakStatement) {}
|
BreakStatement() : Statement(NodeKind::BreakStatement) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::BreakStatement;
|
||||||
|
}
|
||||||
Leaf *getBreakKeyword();
|
Leaf *getBreakKeyword();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -552,7 +732,9 @@ public:
|
||||||
class ReturnStatement final : public Statement {
|
class ReturnStatement final : public Statement {
|
||||||
public:
|
public:
|
||||||
ReturnStatement() : Statement(NodeKind::ReturnStatement) {}
|
ReturnStatement() : Statement(NodeKind::ReturnStatement) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::ReturnStatement;
|
||||||
|
}
|
||||||
Leaf *getReturnKeyword();
|
Leaf *getReturnKeyword();
|
||||||
Expression *getReturnValue();
|
Expression *getReturnValue();
|
||||||
};
|
};
|
||||||
|
@ -561,7 +743,9 @@ public:
|
||||||
class RangeBasedForStatement final : public Statement {
|
class RangeBasedForStatement final : public Statement {
|
||||||
public:
|
public:
|
||||||
RangeBasedForStatement() : Statement(NodeKind::RangeBasedForStatement) {}
|
RangeBasedForStatement() : Statement(NodeKind::RangeBasedForStatement) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::RangeBasedForStatement;
|
||||||
|
}
|
||||||
Leaf *getForKeyword();
|
Leaf *getForKeyword();
|
||||||
Statement *getBody();
|
Statement *getBody();
|
||||||
};
|
};
|
||||||
|
@ -571,7 +755,9 @@ public:
|
||||||
class ExpressionStatement final : public Statement {
|
class ExpressionStatement final : public Statement {
|
||||||
public:
|
public:
|
||||||
ExpressionStatement() : Statement(NodeKind::ExpressionStatement) {}
|
ExpressionStatement() : Statement(NodeKind::ExpressionStatement) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::ExpressionStatement;
|
||||||
|
}
|
||||||
Expression *getExpression();
|
Expression *getExpression();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -579,7 +765,9 @@ public:
|
||||||
class CompoundStatement final : public Statement {
|
class CompoundStatement final : public Statement {
|
||||||
public:
|
public:
|
||||||
CompoundStatement() : Statement(NodeKind::CompoundStatement) {}
|
CompoundStatement() : Statement(NodeKind::CompoundStatement) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::CompoundStatement;
|
||||||
|
}
|
||||||
Leaf *getLbrace();
|
Leaf *getLbrace();
|
||||||
/// FIXME: use custom iterator instead of 'vector'.
|
/// FIXME: use custom iterator instead of 'vector'.
|
||||||
std::vector<Statement *> getStatements();
|
std::vector<Statement *> getStatements();
|
||||||
|
@ -593,21 +781,28 @@ public:
|
||||||
class Declaration : public Tree {
|
class Declaration : public Tree {
|
||||||
public:
|
public:
|
||||||
Declaration(NodeKind K) : Tree(K) {}
|
Declaration(NodeKind K) : Tree(K) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return NodeKind::UnknownDeclaration <= N->getKind() &&
|
||||||
|
N->getKind() <= NodeKind::TypeAliasDeclaration;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Declaration of an unknown kind, e.g. not yet supported in syntax trees.
|
/// Declaration of an unknown kind, e.g. not yet supported in syntax trees.
|
||||||
class UnknownDeclaration final : public Declaration {
|
class UnknownDeclaration final : public Declaration {
|
||||||
public:
|
public:
|
||||||
UnknownDeclaration() : Declaration(NodeKind::UnknownDeclaration) {}
|
UnknownDeclaration() : Declaration(NodeKind::UnknownDeclaration) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::UnknownDeclaration;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A semicolon in the top-level context. Does not declare anything.
|
/// A semicolon in the top-level context. Does not declare anything.
|
||||||
class EmptyDeclaration final : public Declaration {
|
class EmptyDeclaration final : public Declaration {
|
||||||
public:
|
public:
|
||||||
EmptyDeclaration() : Declaration(NodeKind::EmptyDeclaration) {}
|
EmptyDeclaration() : Declaration(NodeKind::EmptyDeclaration) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::EmptyDeclaration;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// static_assert(<condition>, <message>)
|
/// static_assert(<condition>, <message>)
|
||||||
|
@ -615,7 +810,9 @@ public:
|
||||||
class StaticAssertDeclaration final : public Declaration {
|
class StaticAssertDeclaration final : public Declaration {
|
||||||
public:
|
public:
|
||||||
StaticAssertDeclaration() : Declaration(NodeKind::StaticAssertDeclaration) {}
|
StaticAssertDeclaration() : Declaration(NodeKind::StaticAssertDeclaration) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::StaticAssertDeclaration;
|
||||||
|
}
|
||||||
Expression *getCondition();
|
Expression *getCondition();
|
||||||
Expression *getMessage();
|
Expression *getMessage();
|
||||||
};
|
};
|
||||||
|
@ -626,13 +823,17 @@ class LinkageSpecificationDeclaration final : public Declaration {
|
||||||
public:
|
public:
|
||||||
LinkageSpecificationDeclaration()
|
LinkageSpecificationDeclaration()
|
||||||
: Declaration(NodeKind::LinkageSpecificationDeclaration) {}
|
: Declaration(NodeKind::LinkageSpecificationDeclaration) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::LinkageSpecificationDeclaration;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class DeclaratorList final : public List {
|
class DeclaratorList final : public List {
|
||||||
public:
|
public:
|
||||||
DeclaratorList() : List(NodeKind::DeclaratorList) {}
|
DeclaratorList() : List(NodeKind::DeclaratorList) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::DeclaratorList;
|
||||||
|
}
|
||||||
std::vector<SimpleDeclarator *> getDeclarators();
|
std::vector<SimpleDeclarator *> getDeclarators();
|
||||||
std::vector<List::ElementAndDelimiter<syntax::SimpleDeclarator>>
|
std::vector<List::ElementAndDelimiter<syntax::SimpleDeclarator>>
|
||||||
getDeclaratorsAndCommas();
|
getDeclaratorsAndCommas();
|
||||||
|
@ -644,7 +845,9 @@ public:
|
||||||
class SimpleDeclaration final : public Declaration {
|
class SimpleDeclaration final : public Declaration {
|
||||||
public:
|
public:
|
||||||
SimpleDeclaration() : Declaration(NodeKind::SimpleDeclaration) {}
|
SimpleDeclaration() : Declaration(NodeKind::SimpleDeclaration) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::SimpleDeclaration;
|
||||||
|
}
|
||||||
/// FIXME: use custom iterator instead of 'vector'.
|
/// FIXME: use custom iterator instead of 'vector'.
|
||||||
std::vector<SimpleDeclarator *> getDeclarators();
|
std::vector<SimpleDeclarator *> getDeclarators();
|
||||||
};
|
};
|
||||||
|
@ -653,7 +856,9 @@ public:
|
||||||
class TemplateDeclaration final : public Declaration {
|
class TemplateDeclaration final : public Declaration {
|
||||||
public:
|
public:
|
||||||
TemplateDeclaration() : Declaration(NodeKind::TemplateDeclaration) {}
|
TemplateDeclaration() : Declaration(NodeKind::TemplateDeclaration) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::TemplateDeclaration;
|
||||||
|
}
|
||||||
Leaf *getTemplateKeyword();
|
Leaf *getTemplateKeyword();
|
||||||
Declaration *getDeclaration();
|
Declaration *getDeclaration();
|
||||||
};
|
};
|
||||||
|
@ -667,7 +872,9 @@ class ExplicitTemplateInstantiation final : public Declaration {
|
||||||
public:
|
public:
|
||||||
ExplicitTemplateInstantiation()
|
ExplicitTemplateInstantiation()
|
||||||
: Declaration(NodeKind::ExplicitTemplateInstantiation) {}
|
: Declaration(NodeKind::ExplicitTemplateInstantiation) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::ExplicitTemplateInstantiation;
|
||||||
|
}
|
||||||
Leaf *getTemplateKeyword();
|
Leaf *getTemplateKeyword();
|
||||||
Leaf *getExternKeyword();
|
Leaf *getExternKeyword();
|
||||||
Declaration *getDeclaration();
|
Declaration *getDeclaration();
|
||||||
|
@ -677,7 +884,9 @@ public:
|
||||||
class NamespaceDefinition final : public Declaration {
|
class NamespaceDefinition final : public Declaration {
|
||||||
public:
|
public:
|
||||||
NamespaceDefinition() : Declaration(NodeKind::NamespaceDefinition) {}
|
NamespaceDefinition() : Declaration(NodeKind::NamespaceDefinition) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::NamespaceDefinition;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// namespace <name> = <namespace-reference>
|
/// namespace <name> = <namespace-reference>
|
||||||
|
@ -685,14 +894,18 @@ class NamespaceAliasDefinition final : public Declaration {
|
||||||
public:
|
public:
|
||||||
NamespaceAliasDefinition()
|
NamespaceAliasDefinition()
|
||||||
: Declaration(NodeKind::NamespaceAliasDefinition) {}
|
: Declaration(NodeKind::NamespaceAliasDefinition) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::NamespaceAliasDefinition;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// using namespace <name>
|
/// using namespace <name>
|
||||||
class UsingNamespaceDirective final : public Declaration {
|
class UsingNamespaceDirective final : public Declaration {
|
||||||
public:
|
public:
|
||||||
UsingNamespaceDirective() : Declaration(NodeKind::UsingNamespaceDirective) {}
|
UsingNamespaceDirective() : Declaration(NodeKind::UsingNamespaceDirective) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::UsingNamespaceDirective;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// using <scope>::<name>
|
/// using <scope>::<name>
|
||||||
|
@ -700,14 +913,18 @@ public:
|
||||||
class UsingDeclaration final : public Declaration {
|
class UsingDeclaration final : public Declaration {
|
||||||
public:
|
public:
|
||||||
UsingDeclaration() : Declaration(NodeKind::UsingDeclaration) {}
|
UsingDeclaration() : Declaration(NodeKind::UsingDeclaration) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::UsingDeclaration;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// using <name> = <type>
|
/// using <name> = <type>
|
||||||
class TypeAliasDeclaration final : public Declaration {
|
class TypeAliasDeclaration final : public Declaration {
|
||||||
public:
|
public:
|
||||||
TypeAliasDeclaration() : Declaration(NodeKind::TypeAliasDeclaration) {}
|
TypeAliasDeclaration() : Declaration(NodeKind::TypeAliasDeclaration) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::TypeAliasDeclaration;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Covers a name, an initializer and a part of the type outside declaration
|
/// Covers a name, an initializer and a part of the type outside declaration
|
||||||
|
@ -725,7 +942,10 @@ public:
|
||||||
class Declarator : public Tree {
|
class Declarator : public Tree {
|
||||||
public:
|
public:
|
||||||
Declarator(NodeKind K) : Tree(K) {}
|
Declarator(NodeKind K) : Tree(K) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return NodeKind::SimpleDeclarator <= N->getKind() &&
|
||||||
|
N->getKind() <= NodeKind::ParenDeclarator;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// A top-level declarator without parentheses. See comment of Declarator for
|
/// A top-level declarator without parentheses. See comment of Declarator for
|
||||||
|
@ -733,7 +953,9 @@ public:
|
||||||
class SimpleDeclarator final : public Declarator {
|
class SimpleDeclarator final : public Declarator {
|
||||||
public:
|
public:
|
||||||
SimpleDeclarator() : Declarator(NodeKind::SimpleDeclarator) {}
|
SimpleDeclarator() : Declarator(NodeKind::SimpleDeclarator) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::SimpleDeclarator;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Declarator inside parentheses.
|
/// Declarator inside parentheses.
|
||||||
|
@ -742,7 +964,9 @@ public:
|
||||||
class ParenDeclarator final : public Declarator {
|
class ParenDeclarator final : public Declarator {
|
||||||
public:
|
public:
|
||||||
ParenDeclarator() : Declarator(NodeKind::ParenDeclarator) {}
|
ParenDeclarator() : Declarator(NodeKind::ParenDeclarator) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::ParenDeclarator;
|
||||||
|
}
|
||||||
Leaf *getLparen();
|
Leaf *getLparen();
|
||||||
Leaf *getRparen();
|
Leaf *getRparen();
|
||||||
};
|
};
|
||||||
|
@ -754,7 +978,9 @@ public:
|
||||||
class ArraySubscript final : public Tree {
|
class ArraySubscript final : public Tree {
|
||||||
public:
|
public:
|
||||||
ArraySubscript() : Tree(NodeKind::ArraySubscript) {}
|
ArraySubscript() : Tree(NodeKind::ArraySubscript) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::ArraySubscript;
|
||||||
|
}
|
||||||
// TODO: add an accessor for the "static" keyword.
|
// TODO: add an accessor for the "static" keyword.
|
||||||
Leaf *getLbracket();
|
Leaf *getLbracket();
|
||||||
Expression *getSize();
|
Expression *getSize();
|
||||||
|
@ -766,7 +992,9 @@ public:
|
||||||
class TrailingReturnType final : public Tree {
|
class TrailingReturnType final : public Tree {
|
||||||
public:
|
public:
|
||||||
TrailingReturnType() : Tree(NodeKind::TrailingReturnType) {}
|
TrailingReturnType() : Tree(NodeKind::TrailingReturnType) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::TrailingReturnType;
|
||||||
|
}
|
||||||
// TODO: add accessors for specifiers.
|
// TODO: add accessors for specifiers.
|
||||||
Leaf *getArrowToken();
|
Leaf *getArrowToken();
|
||||||
// FIXME: This should be a `type-id` following the grammar. Fix this once we
|
// FIXME: This should be a `type-id` following the grammar. Fix this once we
|
||||||
|
@ -779,7 +1007,9 @@ public:
|
||||||
class ParameterDeclarationList final : public List {
|
class ParameterDeclarationList final : public List {
|
||||||
public:
|
public:
|
||||||
ParameterDeclarationList() : List(NodeKind::ParameterDeclarationList) {}
|
ParameterDeclarationList() : List(NodeKind::ParameterDeclarationList) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::ParameterDeclarationList;
|
||||||
|
}
|
||||||
std::vector<SimpleDeclaration *> getParameterDeclarations();
|
std::vector<SimpleDeclaration *> getParameterDeclarations();
|
||||||
std::vector<List::ElementAndDelimiter<syntax::SimpleDeclaration>>
|
std::vector<List::ElementAndDelimiter<syntax::SimpleDeclaration>>
|
||||||
getParametersAndCommas();
|
getParametersAndCommas();
|
||||||
|
@ -799,7 +1029,9 @@ public:
|
||||||
class ParametersAndQualifiers final : public Tree {
|
class ParametersAndQualifiers final : public Tree {
|
||||||
public:
|
public:
|
||||||
ParametersAndQualifiers() : Tree(NodeKind::ParametersAndQualifiers) {}
|
ParametersAndQualifiers() : Tree(NodeKind::ParametersAndQualifiers) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::ParametersAndQualifiers;
|
||||||
|
}
|
||||||
Leaf *getLparen();
|
Leaf *getLparen();
|
||||||
ParameterDeclarationList *getParameters();
|
ParameterDeclarationList *getParameters();
|
||||||
Leaf *getRparen();
|
Leaf *getRparen();
|
||||||
|
@ -811,19 +1043,11 @@ public:
|
||||||
class MemberPointer final : public Tree {
|
class MemberPointer final : public Tree {
|
||||||
public:
|
public:
|
||||||
MemberPointer() : Tree(NodeKind::MemberPointer) {}
|
MemberPointer() : Tree(NodeKind::MemberPointer) {}
|
||||||
static bool classof(const Node *N);
|
static bool classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::MemberPointer;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CONCRETE_NODE(Kind, Base) \
|
|
||||||
inline bool Kind::classof(const Node *N) { \
|
|
||||||
return N->getKind() == NodeKind::Kind; \
|
|
||||||
}
|
|
||||||
#define ABSTRACT_NODE(Kind, Base, First, Last) \
|
|
||||||
inline bool Kind::classof(const Node *N) { \
|
|
||||||
return N->getKind() >= NodeKind::First && N->getKind() <= NodeKind::Last; \
|
|
||||||
}
|
|
||||||
#include "clang/Tooling/Syntax/Nodes.inc"
|
|
||||||
|
|
||||||
} // namespace syntax
|
} // namespace syntax
|
||||||
} // namespace clang
|
} // namespace clang
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,106 +0,0 @@
|
||||||
//===- Nodes.td - Node types in the Syntax Tree grammar -------------------===//
|
|
||||||
//
|
|
||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
|
||||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// This file defines concrete nodes in the syntax tree.
|
|
||||||
// The archetypes they fall into (Sequence, List etc) are defined in Syntax.td.
|
|
||||||
//
|
|
||||||
// The C++ classes for the archetypes themselves are written by hand, and the
|
|
||||||
// concrete node classes will be generated. Migration to TableGen is not
|
|
||||||
// complete, so currently there is a mix of generated and hand-authored code.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
include "clang/Tooling/Syntax/Syntax.td"
|
|
||||||
|
|
||||||
def Node : External<?> {}
|
|
||||||
def Leaf : External<Node> {}
|
|
||||||
def Tree : External<Node> {}
|
|
||||||
|
|
||||||
def TranslationUnit : External<Tree> {}
|
|
||||||
|
|
||||||
def Expression : External<Tree> {}
|
|
||||||
def UnknownExpression : External<Expression> {}
|
|
||||||
def UnaryOperatorExpression : External<Tree> {}
|
|
||||||
def PrefixUnaryOperatorExpression : External<UnaryOperatorExpression> {}
|
|
||||||
def PostfixUnaryOperatorExpression : External<UnaryOperatorExpression> {}
|
|
||||||
def BinaryOperatorExpression : External<Expression> {}
|
|
||||||
def ParenExpression : External<Expression> {}
|
|
||||||
def LiteralExpression : External<Expression> {}
|
|
||||||
def IntegerLiteralExpression : External<LiteralExpression> {}
|
|
||||||
def CharacterLiteralExpression : External<LiteralExpression> {}
|
|
||||||
def FloatingLiteralExpression : External<LiteralExpression> {}
|
|
||||||
def StringLiteralExpression : External<LiteralExpression> {}
|
|
||||||
def BoolLiteralExpression : External<LiteralExpression> {}
|
|
||||||
def CxxNullPtrExpression : External<LiteralExpression> {}
|
|
||||||
def UserDefinedLiteralExpression : External<LiteralExpression> {}
|
|
||||||
def IntegerUserDefinedLiteralExpression : External<UserDefinedLiteralExpression> {}
|
|
||||||
def FloatUserDefinedLiteralExpression : External<UserDefinedLiteralExpression> {}
|
|
||||||
def CharUserDefinedLiteralExpression : External<UserDefinedLiteralExpression> {}
|
|
||||||
def StringUserDefinedLiteralExpression : External<UserDefinedLiteralExpression> {}
|
|
||||||
def IdExpression : External<Expression> {}
|
|
||||||
def MemberExpression : External<Expression> {}
|
|
||||||
def ThisExpression : External<Expression> {}
|
|
||||||
def CallExpression : External<Expression> {}
|
|
||||||
|
|
||||||
// Statements.
|
|
||||||
def Statement : External<Tree> {}
|
|
||||||
def UnknownStatement : External<Statement> {}
|
|
||||||
def DeclarationStatement : External<Statement> {}
|
|
||||||
def EmptyStatement : External<Statement> {}
|
|
||||||
def SwitchStatement : External<Statement> {}
|
|
||||||
def CaseStatement : External<Statement> {}
|
|
||||||
def DefaultStatement : External<Statement> {}
|
|
||||||
def IfStatement : External<Statement> {}
|
|
||||||
def ForStatement : External<Statement> {}
|
|
||||||
def WhileStatement : External<Statement> {}
|
|
||||||
def ContinueStatement : External<Statement> {}
|
|
||||||
def BreakStatement : External<Statement> {}
|
|
||||||
def ReturnStatement : External<Statement> {}
|
|
||||||
def RangeBasedForStatement : External<Statement> {}
|
|
||||||
def ExpressionStatement : External<Statement> {}
|
|
||||||
def CompoundStatement : External<Statement> {}
|
|
||||||
|
|
||||||
// Declarations.
|
|
||||||
def Declaration : External<Tree> {}
|
|
||||||
def UnknownDeclaration : External<Declaration> {}
|
|
||||||
def EmptyDeclaration : External<Declaration> {}
|
|
||||||
def StaticAssertDeclaration : External<Declaration> {}
|
|
||||||
def LinkageSpecificationDeclaration : External<Declaration> {}
|
|
||||||
def SimpleDeclaration : External<Declaration> {}
|
|
||||||
def TemplateDeclaration : External<Declaration> {}
|
|
||||||
def ExplicitTemplateInstantiation : External<Declaration> {}
|
|
||||||
def NamespaceDefinition : External<Declaration> {}
|
|
||||||
def NamespaceAliasDefinition : External<Declaration> {}
|
|
||||||
def UsingNamespaceDirective : External<Declaration> {}
|
|
||||||
def UsingDeclaration : External<Declaration> {}
|
|
||||||
def TypeAliasDeclaration : External<Declaration> {}
|
|
||||||
|
|
||||||
// Declarators.
|
|
||||||
def Declarator : External<Tree> {}
|
|
||||||
def SimpleDeclarator : External<Declarator> {}
|
|
||||||
def ParenDeclarator : External<Declarator> {}
|
|
||||||
|
|
||||||
def ArraySubscript : External<Tree> {}
|
|
||||||
def TrailingReturnType : External<Tree> {}
|
|
||||||
def ParametersAndQualifiers : External<Tree> {}
|
|
||||||
def MemberPointer : External<Tree> {}
|
|
||||||
def UnqualifiedId : External<Tree> {}
|
|
||||||
|
|
||||||
// Lists
|
|
||||||
def List : External<Tree> {}
|
|
||||||
def DeclaratorList : External<List> {}
|
|
||||||
def ParameterDeclarationList : External<List> {}
|
|
||||||
def CallArguments : External<List> {}
|
|
||||||
def NestedNameSpecifier : External<List> {}
|
|
||||||
|
|
||||||
// Name Specifiers.
|
|
||||||
def NameSpecifier : External<Tree> {}
|
|
||||||
def GlobalNameSpecifier : External<NameSpecifier> {}
|
|
||||||
def DecltypeNameSpecifier : External<NameSpecifier> {}
|
|
||||||
def IdentifierNameSpecifier : External<NameSpecifier> {}
|
|
||||||
def SimpleTemplateNameSpecifier : External<NameSpecifier> {}
|
|
|
@ -1,40 +0,0 @@
|
||||||
//===- Syntax.td - TableGen metamodel for syntax::Node hierarchy ----------===//
|
|
||||||
//
|
|
||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
|
||||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// The tree representation of the is C++ syntax is quite regular.
|
|
||||||
//
|
|
||||||
// There are 4 archetypes of nodes in the syntax tree:
|
|
||||||
// - Leaves, owning exactly one token. (syntax::Leaf)
|
|
||||||
// - Sequences, with a fixed list of children that should appear in order.
|
|
||||||
// The concrete node defines a Role sequence which identifies the children.
|
|
||||||
// The type of child in each role is also constrained.
|
|
||||||
// - Lists, with children in alternating Element/Delimiter roles. (syntax::List)
|
|
||||||
// The concrete node defines the element type, delimiters are always leaves.
|
|
||||||
// - Alternatives, where several different node types are allowed.
|
|
||||||
// These are modeled as abstract types with inheritance (e.g. Declaration).
|
|
||||||
//
|
|
||||||
// This file defines TableGen classes modelling these archetypes.
|
|
||||||
// The concrete nodes are defined in terms of these classes in Nodes.td.
|
|
||||||
//
|
|
||||||
// The C++ classes for the archetypes themselves are written by hand, and the
|
|
||||||
// concrete node classes will be generated. Migration to TableGen is not
|
|
||||||
// complete, so currently there is a mix of generated and hand-authored code.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
|
|
||||||
// Defs derived from NodeType correspond to syntax tree node types.
|
|
||||||
class NodeType {
|
|
||||||
// The NodeType that this node is derived from in the Node class hierarchy.
|
|
||||||
NodeType base = ?;
|
|
||||||
}
|
|
||||||
|
|
||||||
// A node type which is defined in Nodes.h rather than by generated code.
|
|
||||||
// We merely specify the inheritance hierarchy here.
|
|
||||||
class External<NodeType base_> : NodeType { let base = base_; }
|
|
||||||
|
|
||||||
// FIXME: add sequence, list, and alternative archetypes.
|
|
|
@ -630,7 +630,3 @@ syntax::ParametersAndQualifiers::getTrailingReturn() {
|
||||||
return cast_or_null<syntax::TrailingReturnType>(
|
return cast_or_null<syntax::TrailingReturnType>(
|
||||||
findChild(syntax::NodeRole::TrailingReturn));
|
findChild(syntax::NodeRole::TrailingReturn));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NODE(Kind, Parent) \
|
|
||||||
static_assert(sizeof(syntax::Kind) > 0, "Missing Node subclass definition");
|
|
||||||
#include "clang/Tooling/Syntax/Nodes.inc"
|
|
||||||
|
|
|
@ -52,6 +52,10 @@ syntax::Leaf::Leaf(const syntax::Token *Tok) : Node(NodeKind::Leaf), Tok(Tok) {
|
||||||
assert(Tok != nullptr);
|
assert(Tok != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool syntax::Leaf::classof(const Node *N) {
|
||||||
|
return N->getKind() == NodeKind::Leaf;
|
||||||
|
}
|
||||||
|
|
||||||
syntax::Node::Node(NodeKind Kind)
|
syntax::Node::Node(NodeKind Kind)
|
||||||
: Parent(nullptr), NextSibling(nullptr), PreviousSibling(nullptr),
|
: Parent(nullptr), NextSibling(nullptr), PreviousSibling(nullptr),
|
||||||
Kind(static_cast<unsigned>(Kind)), Role(0), Original(false),
|
Kind(static_cast<unsigned>(Kind)), Role(0), Original(false),
|
||||||
|
@ -67,6 +71,10 @@ void syntax::Node::setRole(NodeRole NR) {
|
||||||
this->Role = static_cast<unsigned>(NR);
|
this->Role = static_cast<unsigned>(NR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool syntax::Tree::classof(const Node *N) {
|
||||||
|
return N->getKind() > NodeKind::Leaf;
|
||||||
|
}
|
||||||
|
|
||||||
void syntax::Tree::appendChildLowLevel(Node *Child, NodeRole Role) {
|
void syntax::Tree::appendChildLowLevel(Node *Child, NodeRole Role) {
|
||||||
assert(Child->getRole() == NodeRole::Detached);
|
assert(Child->getRole() == NodeRole::Detached);
|
||||||
assert(Role != NodeRole::Detached);
|
assert(Role != NodeRole::Detached);
|
||||||
|
@ -337,6 +345,18 @@ const syntax::Node *syntax::Tree::findChild(NodeRole R) const {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool syntax::List::classof(const syntax::Node *N) {
|
||||||
|
switch (N->getKind()) {
|
||||||
|
case syntax::NodeKind::NestedNameSpecifier:
|
||||||
|
case syntax::NodeKind::CallArguments:
|
||||||
|
case syntax::NodeKind::ParameterDeclarationList:
|
||||||
|
case syntax::NodeKind::DeclaratorList:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::vector<syntax::List::ElementAndDelimiter<syntax::Node>>
|
std::vector<syntax::List::ElementAndDelimiter<syntax::Node>>
|
||||||
syntax::List::getElementsAsNodesAndDelimiters() {
|
syntax::List::getElementsAsNodesAndDelimiters() {
|
||||||
if (!getFirstChild())
|
if (!getFirstChild())
|
||||||
|
|
|
@ -14,7 +14,6 @@ add_tablegen(clang-tblgen CLANG
|
||||||
ClangOpenCLBuiltinEmitter.cpp
|
ClangOpenCLBuiltinEmitter.cpp
|
||||||
ClangOptionDocEmitter.cpp
|
ClangOptionDocEmitter.cpp
|
||||||
ClangSACheckersEmitter.cpp
|
ClangSACheckersEmitter.cpp
|
||||||
ClangSyntaxEmitter.cpp
|
|
||||||
ClangTypeNodesEmitter.cpp
|
ClangTypeNodesEmitter.cpp
|
||||||
MveEmitter.cpp
|
MveEmitter.cpp
|
||||||
NeonEmitter.cpp
|
NeonEmitter.cpp
|
||||||
|
|
|
@ -1,129 +0,0 @@
|
||||||
//===- ClangSyntaxEmitter.cpp - Generate clang Syntax Tree nodes ----------===//
|
|
||||||
//
|
|
||||||
// The LLVM Compiler Infrastructure
|
|
||||||
//
|
|
||||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
||||||
// See https://llvm.org/LICENSE.txt for license information.
|
|
||||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
//
|
|
||||||
// These backends consume the definitions of Syntax Tree nodes.
|
|
||||||
// See clang/include/clang/Tooling/Syntax/{Syntax,Nodes}.td
|
|
||||||
//
|
|
||||||
// The -gen-clang-syntax-node-list backend produces a .inc with macro calls
|
|
||||||
// NODE(Kind, BaseKind)
|
|
||||||
// ABSTRACT_NODE(Type, Base, FirstKind, LastKind)
|
|
||||||
// similar to those for AST nodes such as AST/DeclNodes.inc.
|
|
||||||
//
|
|
||||||
// In future, the class definitions will be produced by additional backends.
|
|
||||||
//
|
|
||||||
//===----------------------------------------------------------------------===//
|
|
||||||
#include "TableGenBackends.h"
|
|
||||||
|
|
||||||
#include <deque>
|
|
||||||
|
|
||||||
#include "llvm/Support/FormatVariadic.h"
|
|
||||||
#include "llvm/Support/raw_ostream.h"
|
|
||||||
#include "llvm/TableGen/Record.h"
|
|
||||||
#include "llvm/TableGen/TableGenBackend.h"
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
// The class hierarchy of Node types.
|
|
||||||
// We assemble this in order to be able to define the NodeKind enum in a
|
|
||||||
// stable and useful way, where abstract Node subclasses correspond to ranges.
|
|
||||||
class Hierarchy {
|
|
||||||
public:
|
|
||||||
Hierarchy(const llvm::RecordKeeper &Records) {
|
|
||||||
for (llvm::Record *T : Records.getAllDerivedDefinitions("NodeType"))
|
|
||||||
add(T);
|
|
||||||
for (llvm::Record *Derived : Records.getAllDerivedDefinitions("NodeType"))
|
|
||||||
if (llvm::Record *Base = Derived->getValueAsOptionalDef("base"))
|
|
||||||
link(Derived, Base);
|
|
||||||
for (NodeType &N : AllTypes)
|
|
||||||
llvm::sort(N.Derived, [](const NodeType *L, const NodeType *R) {
|
|
||||||
return L->Record->getName() < R->Record->getName();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
struct NodeType {
|
|
||||||
const llvm::Record *Record = nullptr;
|
|
||||||
const NodeType *Base = nullptr;
|
|
||||||
std::vector<const NodeType *> Derived;
|
|
||||||
llvm::StringRef name() const { return Record->getName(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
NodeType &get(llvm::StringRef Name = "Node") {
|
|
||||||
auto NI = ByName.find(Name);
|
|
||||||
assert(NI != ByName.end() && "no such node");
|
|
||||||
return *NI->second;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
void add(const llvm::Record *R) {
|
|
||||||
AllTypes.emplace_back();
|
|
||||||
AllTypes.back().Record = R;
|
|
||||||
assert(ByName.try_emplace(R->getName(), &AllTypes.back()).second &&
|
|
||||||
"Duplicate node name");
|
|
||||||
}
|
|
||||||
|
|
||||||
void link(const llvm::Record *Derived, const llvm::Record *Base) {
|
|
||||||
auto &CN = get(Derived->getName()), &PN = get(Base->getName());
|
|
||||||
assert(CN.Base == nullptr && "setting base twice");
|
|
||||||
PN.Derived.push_back(&CN);
|
|
||||||
CN.Base = &PN;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::deque<NodeType> AllTypes;
|
|
||||||
llvm::DenseMap<llvm::StringRef, NodeType *> ByName;
|
|
||||||
};
|
|
||||||
|
|
||||||
const Hierarchy::NodeType &firstConcrete(const Hierarchy::NodeType &N) {
|
|
||||||
return N.Derived.empty() ? N : firstConcrete(*N.Derived.front());
|
|
||||||
}
|
|
||||||
const Hierarchy::NodeType &lastConcrete(const Hierarchy::NodeType &N) {
|
|
||||||
return N.Derived.empty() ? N : lastConcrete(*N.Derived.back());
|
|
||||||
}
|
|
||||||
|
|
||||||
void emitNodeList(const Hierarchy::NodeType &N, llvm::raw_ostream &OS) {
|
|
||||||
// Don't emit ABSTRACT_NODE for node itself, which has no parent.
|
|
||||||
if (N.Base != nullptr) {
|
|
||||||
if (N.Derived.empty())
|
|
||||||
OS << llvm::formatv("CONCRETE_NODE({0},{1})\n", N.name(), N.Base->name());
|
|
||||||
else
|
|
||||||
OS << llvm::formatv("ABSTRACT_NODE({0},{1},{2},{3})\n", N.name(),
|
|
||||||
N.Base->name(), firstConcrete(N).name(),
|
|
||||||
lastConcrete(N).name());
|
|
||||||
}
|
|
||||||
for (const auto *C : N.Derived)
|
|
||||||
emitNodeList(*C, OS);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace
|
|
||||||
|
|
||||||
void clang::EmitClangSyntaxNodeList(llvm::RecordKeeper &Records,
|
|
||||||
llvm::raw_ostream &OS) {
|
|
||||||
llvm::emitSourceFileHeader("Syntax tree node list", OS);
|
|
||||||
OS << "// Generated from " << Records.getInputFilename() << "\n";
|
|
||||||
OS << R"cpp(
|
|
||||||
#ifndef NODE
|
|
||||||
#define NODE(Kind, Base)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef CONCRETE_NODE
|
|
||||||
#define CONCRETE_NODE(Kind, Base) NODE(Kind, Base)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef ABSTRACT_NODE
|
|
||||||
#define ABSTRACT_NODE(Kind, Base, First, Last) NODE(Kind, Base)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
)cpp";
|
|
||||||
emitNodeList(Hierarchy(Records).get(), OS);
|
|
||||||
OS << R"cpp(
|
|
||||||
#undef NODE
|
|
||||||
#undef CONCRETE_NODE
|
|
||||||
#undef ABSTRACT_NODE
|
|
||||||
)cpp";
|
|
||||||
}
|
|
|
@ -55,7 +55,6 @@ enum ActionType {
|
||||||
GenClangTypeWriter,
|
GenClangTypeWriter,
|
||||||
GenClangOpcodes,
|
GenClangOpcodes,
|
||||||
GenClangSACheckers,
|
GenClangSACheckers,
|
||||||
GenClangSyntaxNodeList,
|
|
||||||
GenClangCommentHTMLTags,
|
GenClangCommentHTMLTags,
|
||||||
GenClangCommentHTMLTagsProperties,
|
GenClangCommentHTMLTagsProperties,
|
||||||
GenClangCommentHTMLNamedCharacterReferences,
|
GenClangCommentHTMLNamedCharacterReferences,
|
||||||
|
@ -167,8 +166,6 @@ cl::opt<ActionType> Action(
|
||||||
"Generate Clang constexpr interpreter opcodes"),
|
"Generate Clang constexpr interpreter opcodes"),
|
||||||
clEnumValN(GenClangSACheckers, "gen-clang-sa-checkers",
|
clEnumValN(GenClangSACheckers, "gen-clang-sa-checkers",
|
||||||
"Generate Clang Static Analyzer checkers"),
|
"Generate Clang Static Analyzer checkers"),
|
||||||
clEnumValN(GenClangSyntaxNodeList, "gen-clang-syntax-node-list",
|
|
||||||
"Generate list of Clang Syntax Tree node types"),
|
|
||||||
clEnumValN(GenClangCommentHTMLTags, "gen-clang-comment-html-tags",
|
clEnumValN(GenClangCommentHTMLTags, "gen-clang-comment-html-tags",
|
||||||
"Generate efficient matchers for HTML tag "
|
"Generate efficient matchers for HTML tag "
|
||||||
"names that are used in documentation comments"),
|
"names that are used in documentation comments"),
|
||||||
|
@ -359,9 +356,6 @@ bool ClangTableGenMain(raw_ostream &OS, RecordKeeper &Records) {
|
||||||
case GenClangOpenCLBuiltins:
|
case GenClangOpenCLBuiltins:
|
||||||
EmitClangOpenCLBuiltins(Records, OS);
|
EmitClangOpenCLBuiltins(Records, OS);
|
||||||
break;
|
break;
|
||||||
case GenClangSyntaxNodeList:
|
|
||||||
EmitClangSyntaxNodeList(Records, OS);
|
|
||||||
break;
|
|
||||||
case GenArmNeon:
|
case GenArmNeon:
|
||||||
EmitNeon(Records, OS);
|
EmitNeon(Records, OS);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -83,9 +83,6 @@ void EmitClangCommentCommandList(llvm::RecordKeeper &Records,
|
||||||
llvm::raw_ostream &OS);
|
llvm::raw_ostream &OS);
|
||||||
void EmitClangOpcodes(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
|
void EmitClangOpcodes(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
|
||||||
|
|
||||||
void EmitClangSyntaxNodeList(llvm::RecordKeeper &Records,
|
|
||||||
llvm::raw_ostream &OS);
|
|
||||||
|
|
||||||
void EmitNeon(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
|
void EmitNeon(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
|
||||||
void EmitFP16(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
|
void EmitFP16(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
|
||||||
void EmitBF16(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
|
void EmitBF16(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
|
||||||
|
|
Loading…
Reference in New Issue