[clang] 4c14ee6 - [SyntaxTree] Rename functions to start with verb
Eduardo Caldas via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 11 07:54:33 PDT 2020
Author: Eduardo Caldas
Date: 2020-09-11T14:54:18Z
New Revision: 4c14ee61b73746b314d83e7c52e03d6527b78105
URL: https://github.com/llvm/llvm-project/commit/4c14ee61b73746b314d83e7c52e03d6527b78105
DIFF: https://github.com/llvm/llvm-project/commit/4c14ee61b73746b314d83e7c52e03d6527b78105.diff
LOG: [SyntaxTree] Rename functions to start with verb
According to LLVM coding standards:
https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly
Differential Revision: https://reviews.llvm.org/D87498
Added:
Modified:
clang/include/clang/Tooling/Syntax/Nodes.h
clang/include/clang/Tooling/Syntax/Tree.h
clang/lib/Tooling/Syntax/BuildTree.cpp
clang/lib/Tooling/Syntax/ComputeReplacements.cpp
clang/lib/Tooling/Syntax/Mutations.cpp
clang/lib/Tooling/Syntax/Nodes.cpp
clang/lib/Tooling/Syntax/Synthesis.cpp
clang/lib/Tooling/Syntax/Tree.cpp
clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
clang/unittests/Tooling/Syntax/SynthesisTest.cpp
clang/unittests/Tooling/Syntax/TreeTestBase.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Tooling/Syntax/Nodes.h b/clang/include/clang/Tooling/Syntax/Nodes.h
index a6505c8167ee..8b393c5423b4 100644
--- a/clang/include/clang/Tooling/Syntax/Nodes.h
+++ b/clang/include/clang/Tooling/Syntax/Nodes.h
@@ -190,7 +190,7 @@ class TranslationUnit final : public Tree {
public:
TranslationUnit() : Tree(NodeKind::TranslationUnit) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::TranslationUnit;
+ return N->getKind() == NodeKind::TranslationUnit;
}
};
@@ -200,8 +200,8 @@ class Expression : public Tree {
public:
Expression(NodeKind K) : Tree(K) {}
static bool classof(const Node *N) {
- return NodeKind::UnknownExpression <= N->kind() &&
- N->kind() <= NodeKind::UnknownExpression;
+ return NodeKind::UnknownExpression <= N->getKind() &&
+ N->getKind() <= NodeKind::UnknownExpression;
}
};
@@ -211,10 +211,10 @@ class NameSpecifier : public Tree {
public:
NameSpecifier(NodeKind K) : Tree(K) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::GlobalNameSpecifier ||
- N->kind() == NodeKind::DecltypeNameSpecifier ||
- N->kind() == NodeKind::IdentifierNameSpecifier ||
- N->kind() == NodeKind::SimpleTemplateNameSpecifier;
+ return N->getKind() == NodeKind::GlobalNameSpecifier ||
+ N->getKind() == NodeKind::DecltypeNameSpecifier ||
+ N->getKind() == NodeKind::IdentifierNameSpecifier ||
+ N->getKind() == NodeKind::SimpleTemplateNameSpecifier;
}
};
@@ -226,7 +226,7 @@ class GlobalNameSpecifier final : public NameSpecifier {
public:
GlobalNameSpecifier() : NameSpecifier(NodeKind::GlobalNameSpecifier) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::GlobalNameSpecifier;
+ return N->getKind() == NodeKind::GlobalNameSpecifier;
}
};
@@ -236,7 +236,7 @@ class DecltypeNameSpecifier final : public NameSpecifier {
public:
DecltypeNameSpecifier() : NameSpecifier(NodeKind::DecltypeNameSpecifier) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::DecltypeNameSpecifier;
+ return N->getKind() == NodeKind::DecltypeNameSpecifier;
}
};
@@ -247,7 +247,7 @@ class IdentifierNameSpecifier final : public NameSpecifier {
IdentifierNameSpecifier()
: NameSpecifier(NodeKind::IdentifierNameSpecifier) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::IdentifierNameSpecifier;
+ return N->getKind() == NodeKind::IdentifierNameSpecifier;
}
};
@@ -259,7 +259,7 @@ class SimpleTemplateNameSpecifier final : public NameSpecifier {
SimpleTemplateNameSpecifier()
: NameSpecifier(NodeKind::SimpleTemplateNameSpecifier) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::SimpleTemplateNameSpecifier;
+ return N->getKind() == NodeKind::SimpleTemplateNameSpecifier;
}
};
@@ -269,7 +269,7 @@ class NestedNameSpecifier final : public List {
public:
NestedNameSpecifier() : List(NodeKind::NestedNameSpecifier) {}
static bool classof(const Node *N) {
- return N->kind() <= NodeKind::NestedNameSpecifier;
+ return N->getKind() <= NodeKind::NestedNameSpecifier;
}
std::vector<NameSpecifier *> getSpecifiers();
std::vector<List::ElementAndDelimiter<syntax::NameSpecifier>>
@@ -282,7 +282,7 @@ class UnqualifiedId final : public Tree {
public:
UnqualifiedId() : Tree(NodeKind::UnqualifiedId) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::UnqualifiedId;
+ return N->getKind() == NodeKind::UnqualifiedId;
}
};
@@ -297,7 +297,7 @@ class IdExpression final : public Expression {
public:
IdExpression() : Expression(NodeKind::IdExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::IdExpression;
+ return N->getKind() == NodeKind::IdExpression;
}
NestedNameSpecifier *getQualifier();
Leaf *getTemplateKeyword();
@@ -310,7 +310,7 @@ class UnknownExpression final : public Expression {
public:
UnknownExpression() : Expression(NodeKind::UnknownExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::UnknownExpression;
+ return N->getKind() == NodeKind::UnknownExpression;
}
};
@@ -319,7 +319,7 @@ class ThisExpression final : public Expression {
public:
ThisExpression() : Expression(NodeKind::ThisExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::ThisExpression;
+ return N->getKind() == NodeKind::ThisExpression;
}
Leaf *getThisKeyword();
};
@@ -333,7 +333,7 @@ class CallArguments final : public List {
public:
CallArguments() : List(NodeKind::CallArguments) {}
static bool classof(const Node *N) {
- return N->kind() <= NodeKind::CallArguments;
+ return N->getKind() <= NodeKind::CallArguments;
}
std::vector<Expression *> getArguments();
std::vector<List::ElementAndDelimiter<Expression>> getArgumentsAndCommas();
@@ -347,7 +347,7 @@ class CallExpression final : public Expression {
public:
CallExpression() : Expression(NodeKind::CallExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::CallExpression;
+ return N->getKind() == NodeKind::CallExpression;
}
Expression *getCallee();
Leaf *getOpenParen();
@@ -361,7 +361,7 @@ class ParenExpression final : public Expression {
public:
ParenExpression() : Expression(NodeKind::ParenExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::ParenExpression;
+ return N->getKind() == NodeKind::ParenExpression;
}
Leaf *getOpenParen();
Expression *getSubExpression();
@@ -380,7 +380,7 @@ class MemberExpression final : public Expression {
public:
MemberExpression() : Expression(NodeKind::MemberExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::MemberExpression;
+ return N->getKind() == NodeKind::MemberExpression;
}
Expression *getObject();
Leaf *getAccessToken();
@@ -393,16 +393,16 @@ class LiteralExpression : public Expression {
public:
LiteralExpression(NodeKind K) : Expression(K) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::IntegerLiteralExpression ||
- N->kind() == NodeKind::CharacterLiteralExpression ||
- N->kind() == NodeKind::FloatingLiteralExpression ||
- N->kind() == NodeKind::StringLiteralExpression ||
- N->kind() == NodeKind::BoolLiteralExpression ||
- N->kind() == NodeKind::CxxNullPtrExpression ||
- N->kind() == NodeKind::IntegerUserDefinedLiteralExpression ||
- N->kind() == NodeKind::FloatUserDefinedLiteralExpression ||
- N->kind() == NodeKind::CharUserDefinedLiteralExpression ||
- N->kind() == NodeKind::StringUserDefinedLiteralExpression;
+ 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();
};
@@ -413,7 +413,7 @@ class IntegerLiteralExpression final : public LiteralExpression {
IntegerLiteralExpression()
: LiteralExpression(NodeKind::IntegerLiteralExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::IntegerLiteralExpression;
+ return N->getKind() == NodeKind::IntegerLiteralExpression;
}
};
@@ -423,7 +423,7 @@ class CharacterLiteralExpression final : public LiteralExpression {
CharacterLiteralExpression()
: LiteralExpression(NodeKind::CharacterLiteralExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::CharacterLiteralExpression;
+ return N->getKind() == NodeKind::CharacterLiteralExpression;
}
};
@@ -433,7 +433,7 @@ class FloatingLiteralExpression final : public LiteralExpression {
FloatingLiteralExpression()
: LiteralExpression(NodeKind::FloatingLiteralExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::FloatingLiteralExpression;
+ return N->getKind() == NodeKind::FloatingLiteralExpression;
}
};
@@ -443,7 +443,7 @@ class StringLiteralExpression final : public LiteralExpression {
StringLiteralExpression()
: LiteralExpression(NodeKind::StringLiteralExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::StringLiteralExpression;
+ return N->getKind() == NodeKind::StringLiteralExpression;
}
};
@@ -453,7 +453,7 @@ class BoolLiteralExpression final : public LiteralExpression {
BoolLiteralExpression()
: LiteralExpression(NodeKind::BoolLiteralExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::BoolLiteralExpression;
+ return N->getKind() == NodeKind::BoolLiteralExpression;
}
};
@@ -462,7 +462,7 @@ class CxxNullPtrExpression final : public LiteralExpression {
public:
CxxNullPtrExpression() : LiteralExpression(NodeKind::CxxNullPtrExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::CxxNullPtrExpression;
+ return N->getKind() == NodeKind::CxxNullPtrExpression;
}
};
@@ -476,10 +476,10 @@ class UserDefinedLiteralExpression : public LiteralExpression {
public:
UserDefinedLiteralExpression(NodeKind K) : LiteralExpression(K) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::IntegerUserDefinedLiteralExpression ||
- N->kind() == NodeKind::FloatUserDefinedLiteralExpression ||
- N->kind() == NodeKind::CharUserDefinedLiteralExpression ||
- N->kind() == NodeKind::StringUserDefinedLiteralExpression;
+ return N->getKind() == NodeKind::IntegerUserDefinedLiteralExpression ||
+ N->getKind() == NodeKind::FloatUserDefinedLiteralExpression ||
+ N->getKind() == NodeKind::CharUserDefinedLiteralExpression ||
+ N->getKind() == NodeKind::StringUserDefinedLiteralExpression;
}
};
@@ -491,7 +491,7 @@ class IntegerUserDefinedLiteralExpression final
: UserDefinedLiteralExpression(
NodeKind::IntegerUserDefinedLiteralExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::IntegerUserDefinedLiteralExpression;
+ return N->getKind() == NodeKind::IntegerUserDefinedLiteralExpression;
}
};
@@ -503,7 +503,7 @@ class FloatUserDefinedLiteralExpression final
: UserDefinedLiteralExpression(
NodeKind::FloatUserDefinedLiteralExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::FloatUserDefinedLiteralExpression;
+ return N->getKind() == NodeKind::FloatUserDefinedLiteralExpression;
}
};
@@ -515,7 +515,7 @@ class CharUserDefinedLiteralExpression final
: UserDefinedLiteralExpression(
NodeKind::CharUserDefinedLiteralExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::CharUserDefinedLiteralExpression;
+ return N->getKind() == NodeKind::CharUserDefinedLiteralExpression;
}
};
@@ -527,7 +527,7 @@ class StringUserDefinedLiteralExpression final
: UserDefinedLiteralExpression(
NodeKind::StringUserDefinedLiteralExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::StringUserDefinedLiteralExpression;
+ return N->getKind() == NodeKind::StringUserDefinedLiteralExpression;
}
};
@@ -536,8 +536,8 @@ class UnaryOperatorExpression : public Expression {
public:
UnaryOperatorExpression(NodeKind K) : Expression(K) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::PrefixUnaryOperatorExpression ||
- N->kind() == NodeKind::PostfixUnaryOperatorExpression;
+ return N->getKind() == NodeKind::PrefixUnaryOperatorExpression ||
+ N->getKind() == NodeKind::PostfixUnaryOperatorExpression;
}
Leaf *getOperatorToken();
Expression *getOperand();
@@ -557,7 +557,7 @@ class PrefixUnaryOperatorExpression final : public UnaryOperatorExpression {
PrefixUnaryOperatorExpression()
: UnaryOperatorExpression(NodeKind::PrefixUnaryOperatorExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::PrefixUnaryOperatorExpression;
+ return N->getKind() == NodeKind::PrefixUnaryOperatorExpression;
}
};
@@ -571,7 +571,7 @@ class PostfixUnaryOperatorExpression final : public UnaryOperatorExpression {
PostfixUnaryOperatorExpression()
: UnaryOperatorExpression(NodeKind::PostfixUnaryOperatorExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::PostfixUnaryOperatorExpression;
+ return N->getKind() == NodeKind::PostfixUnaryOperatorExpression;
}
};
@@ -586,7 +586,7 @@ class BinaryOperatorExpression final : public Expression {
public:
BinaryOperatorExpression() : Expression(NodeKind::BinaryOperatorExpression) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::BinaryOperatorExpression;
+ return N->getKind() == NodeKind::BinaryOperatorExpression;
}
Expression *getLhs();
Leaf *getOperatorToken();
@@ -599,8 +599,8 @@ class Statement : public Tree {
public:
Statement(NodeKind K) : Tree(K) {}
static bool classof(const Node *N) {
- return NodeKind::UnknownStatement <= N->kind() &&
- N->kind() <= NodeKind::CompoundStatement;
+ return NodeKind::UnknownStatement <= N->getKind() &&
+ N->getKind() <= NodeKind::CompoundStatement;
}
};
@@ -610,7 +610,7 @@ class UnknownStatement final : public Statement {
public:
UnknownStatement() : Statement(NodeKind::UnknownStatement) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::UnknownStatement;
+ return N->getKind() == NodeKind::UnknownStatement;
}
};
@@ -619,7 +619,7 @@ class DeclarationStatement final : public Statement {
public:
DeclarationStatement() : Statement(NodeKind::DeclarationStatement) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::DeclarationStatement;
+ return N->getKind() == NodeKind::DeclarationStatement;
}
};
@@ -628,7 +628,7 @@ class EmptyStatement final : public Statement {
public:
EmptyStatement() : Statement(NodeKind::EmptyStatement) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::EmptyStatement;
+ return N->getKind() == NodeKind::EmptyStatement;
}
};
@@ -637,7 +637,7 @@ class SwitchStatement final : public Statement {
public:
SwitchStatement() : Statement(NodeKind::SwitchStatement) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::SwitchStatement;
+ return N->getKind() == NodeKind::SwitchStatement;
}
Leaf *getSwitchKeyword();
Statement *getBody();
@@ -648,7 +648,7 @@ class CaseStatement final : public Statement {
public:
CaseStatement() : Statement(NodeKind::CaseStatement) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::CaseStatement;
+ return N->getKind() == NodeKind::CaseStatement;
}
Leaf *getCaseKeyword();
Expression *getCaseValue();
@@ -660,7 +660,7 @@ class DefaultStatement final : public Statement {
public:
DefaultStatement() : Statement(NodeKind::DefaultStatement) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::DefaultStatement;
+ return N->getKind() == NodeKind::DefaultStatement;
}
Leaf *getDefaultKeyword();
Statement *getBody();
@@ -672,7 +672,7 @@ class IfStatement final : public Statement {
public:
IfStatement() : Statement(NodeKind::IfStatement) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::IfStatement;
+ return N->getKind() == NodeKind::IfStatement;
}
Leaf *getIfKeyword();
Statement *getThenStatement();
@@ -685,7 +685,7 @@ class ForStatement final : public Statement {
public:
ForStatement() : Statement(NodeKind::ForStatement) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::ForStatement;
+ return N->getKind() == NodeKind::ForStatement;
}
Leaf *getForKeyword();
Statement *getBody();
@@ -696,7 +696,7 @@ class WhileStatement final : public Statement {
public:
WhileStatement() : Statement(NodeKind::WhileStatement) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::WhileStatement;
+ return N->getKind() == NodeKind::WhileStatement;
}
Leaf *getWhileKeyword();
Statement *getBody();
@@ -707,7 +707,7 @@ class ContinueStatement final : public Statement {
public:
ContinueStatement() : Statement(NodeKind::ContinueStatement) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::ContinueStatement;
+ return N->getKind() == NodeKind::ContinueStatement;
}
Leaf *getContinueKeyword();
};
@@ -717,7 +717,7 @@ class BreakStatement final : public Statement {
public:
BreakStatement() : Statement(NodeKind::BreakStatement) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::BreakStatement;
+ return N->getKind() == NodeKind::BreakStatement;
}
Leaf *getBreakKeyword();
};
@@ -728,7 +728,7 @@ class ReturnStatement final : public Statement {
public:
ReturnStatement() : Statement(NodeKind::ReturnStatement) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::ReturnStatement;
+ return N->getKind() == NodeKind::ReturnStatement;
}
Leaf *getReturnKeyword();
Expression *getReturnValue();
@@ -739,7 +739,7 @@ class RangeBasedForStatement final : public Statement {
public:
RangeBasedForStatement() : Statement(NodeKind::RangeBasedForStatement) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::RangeBasedForStatement;
+ return N->getKind() == NodeKind::RangeBasedForStatement;
}
Leaf *getForKeyword();
Statement *getBody();
@@ -751,7 +751,7 @@ class ExpressionStatement final : public Statement {
public:
ExpressionStatement() : Statement(NodeKind::ExpressionStatement) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::ExpressionStatement;
+ return N->getKind() == NodeKind::ExpressionStatement;
}
Expression *getExpression();
};
@@ -761,7 +761,7 @@ class CompoundStatement final : public Statement {
public:
CompoundStatement() : Statement(NodeKind::CompoundStatement) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::CompoundStatement;
+ return N->getKind() == NodeKind::CompoundStatement;
}
Leaf *getLbrace();
/// FIXME: use custom iterator instead of 'vector'.
@@ -777,8 +777,8 @@ class Declaration : public Tree {
public:
Declaration(NodeKind K) : Tree(K) {}
static bool classof(const Node *N) {
- return NodeKind::UnknownDeclaration <= N->kind() &&
- N->kind() <= NodeKind::TypeAliasDeclaration;
+ return NodeKind::UnknownDeclaration <= N->getKind() &&
+ N->getKind() <= NodeKind::TypeAliasDeclaration;
}
};
@@ -787,7 +787,7 @@ class UnknownDeclaration final : public Declaration {
public:
UnknownDeclaration() : Declaration(NodeKind::UnknownDeclaration) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::UnknownDeclaration;
+ return N->getKind() == NodeKind::UnknownDeclaration;
}
};
@@ -796,7 +796,7 @@ class EmptyDeclaration final : public Declaration {
public:
EmptyDeclaration() : Declaration(NodeKind::EmptyDeclaration) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::EmptyDeclaration;
+ return N->getKind() == NodeKind::EmptyDeclaration;
}
};
@@ -806,7 +806,7 @@ class StaticAssertDeclaration final : public Declaration {
public:
StaticAssertDeclaration() : Declaration(NodeKind::StaticAssertDeclaration) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::StaticAssertDeclaration;
+ return N->getKind() == NodeKind::StaticAssertDeclaration;
}
Expression *getCondition();
Expression *getMessage();
@@ -819,7 +819,7 @@ class LinkageSpecificationDeclaration final : public Declaration {
LinkageSpecificationDeclaration()
: Declaration(NodeKind::LinkageSpecificationDeclaration) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::LinkageSpecificationDeclaration;
+ return N->getKind() == NodeKind::LinkageSpecificationDeclaration;
}
};
@@ -830,7 +830,7 @@ class SimpleDeclaration final : public Declaration {
public:
SimpleDeclaration() : Declaration(NodeKind::SimpleDeclaration) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::SimpleDeclaration;
+ return N->getKind() == NodeKind::SimpleDeclaration;
}
/// FIXME: use custom iterator instead of 'vector'.
std::vector<SimpleDeclarator *> getDeclarators();
@@ -841,7 +841,7 @@ class TemplateDeclaration final : public Declaration {
public:
TemplateDeclaration() : Declaration(NodeKind::TemplateDeclaration) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::TemplateDeclaration;
+ return N->getKind() == NodeKind::TemplateDeclaration;
}
Leaf *getTemplateKeyword();
Declaration *getDeclaration();
@@ -857,7 +857,7 @@ class ExplicitTemplateInstantiation final : public Declaration {
ExplicitTemplateInstantiation()
: Declaration(NodeKind::ExplicitTemplateInstantiation) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::ExplicitTemplateInstantiation;
+ return N->getKind() == NodeKind::ExplicitTemplateInstantiation;
}
Leaf *getTemplateKeyword();
Leaf *getExternKeyword();
@@ -869,7 +869,7 @@ class NamespaceDefinition final : public Declaration {
public:
NamespaceDefinition() : Declaration(NodeKind::NamespaceDefinition) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::NamespaceDefinition;
+ return N->getKind() == NodeKind::NamespaceDefinition;
}
};
@@ -879,7 +879,7 @@ class NamespaceAliasDefinition final : public Declaration {
NamespaceAliasDefinition()
: Declaration(NodeKind::NamespaceAliasDefinition) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::NamespaceAliasDefinition;
+ return N->getKind() == NodeKind::NamespaceAliasDefinition;
}
};
@@ -888,7 +888,7 @@ class UsingNamespaceDirective final : public Declaration {
public:
UsingNamespaceDirective() : Declaration(NodeKind::UsingNamespaceDirective) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::UsingNamespaceDirective;
+ return N->getKind() == NodeKind::UsingNamespaceDirective;
}
};
@@ -898,7 +898,7 @@ class UsingDeclaration final : public Declaration {
public:
UsingDeclaration() : Declaration(NodeKind::UsingDeclaration) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::UsingDeclaration;
+ return N->getKind() == NodeKind::UsingDeclaration;
}
};
@@ -907,7 +907,7 @@ class TypeAliasDeclaration final : public Declaration {
public:
TypeAliasDeclaration() : Declaration(NodeKind::TypeAliasDeclaration) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::TypeAliasDeclaration;
+ return N->getKind() == NodeKind::TypeAliasDeclaration;
}
};
@@ -927,8 +927,8 @@ class Declarator : public Tree {
public:
Declarator(NodeKind K) : Tree(K) {}
static bool classof(const Node *N) {
- return NodeKind::SimpleDeclarator <= N->kind() &&
- N->kind() <= NodeKind::ParenDeclarator;
+ return NodeKind::SimpleDeclarator <= N->getKind() &&
+ N->getKind() <= NodeKind::ParenDeclarator;
}
};
@@ -938,7 +938,7 @@ class SimpleDeclarator final : public Declarator {
public:
SimpleDeclarator() : Declarator(NodeKind::SimpleDeclarator) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::SimpleDeclarator;
+ return N->getKind() == NodeKind::SimpleDeclarator;
}
};
@@ -949,7 +949,7 @@ class ParenDeclarator final : public Declarator {
public:
ParenDeclarator() : Declarator(NodeKind::ParenDeclarator) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::ParenDeclarator;
+ return N->getKind() == NodeKind::ParenDeclarator;
}
Leaf *getLparen();
Leaf *getRparen();
@@ -963,7 +963,7 @@ class ArraySubscript final : public Tree {
public:
ArraySubscript() : Tree(NodeKind::ArraySubscript) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::ArraySubscript;
+ return N->getKind() == NodeKind::ArraySubscript;
}
// TODO: add an accessor for the "static" keyword.
Leaf *getLbracket();
@@ -977,7 +977,7 @@ class TrailingReturnType final : public Tree {
public:
TrailingReturnType() : Tree(NodeKind::TrailingReturnType) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::TrailingReturnType;
+ return N->getKind() == NodeKind::TrailingReturnType;
}
// TODO: add accessors for specifiers.
Leaf *getArrowToken();
@@ -992,7 +992,7 @@ class ParameterDeclarationList final : public List {
public:
ParameterDeclarationList() : List(NodeKind::ParameterDeclarationList) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::ParameterDeclarationList;
+ return N->getKind() == NodeKind::ParameterDeclarationList;
}
std::vector<SimpleDeclaration *> getParameterDeclarations();
std::vector<List::ElementAndDelimiter<syntax::SimpleDeclaration>>
@@ -1014,7 +1014,7 @@ class ParametersAndQualifiers final : public Tree {
public:
ParametersAndQualifiers() : Tree(NodeKind::ParametersAndQualifiers) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::ParametersAndQualifiers;
+ return N->getKind() == NodeKind::ParametersAndQualifiers;
}
Leaf *getLparen();
ParameterDeclarationList *getParameters();
@@ -1028,7 +1028,7 @@ class MemberPointer final : public Tree {
public:
MemberPointer() : Tree(NodeKind::MemberPointer) {}
static bool classof(const Node *N) {
- return N->kind() == NodeKind::MemberPointer;
+ return N->getKind() == NodeKind::MemberPointer;
}
};
diff --git a/clang/include/clang/Tooling/Syntax/Tree.h b/clang/include/clang/Tooling/Syntax/Tree.h
index f7f9e6bdc5a0..aab904ab65d3 100644
--- a/clang/include/clang/Tooling/Syntax/Tree.h
+++ b/clang/include/clang/Tooling/Syntax/Tree.h
@@ -41,11 +41,11 @@ class Arena {
Arena(SourceManager &SourceMgr, const LangOptions &LangOpts,
const TokenBuffer &Tokens);
- const SourceManager &sourceManager() const { return SourceMgr; }
- const LangOptions &langOptions() const { return LangOpts; }
+ const SourceManager &getSourceManager() const { return SourceMgr; }
+ const LangOptions &getLangOptions() const { return LangOpts; }
- const TokenBuffer &tokenBuffer() const;
- llvm::BumpPtrAllocator &allocator() { return Allocator; }
+ const TokenBuffer &getTokenBuffer() const;
+ llvm::BumpPtrAllocator &getAllocator() { return Allocator; }
/// Add \p Buffer to the underlying source manager, tokenize it and store the
/// resulting tokens. Useful when there is a need to materialize tokens that
@@ -79,8 +79,8 @@ class Node {
/// set when the node is added as a child to another one.
Node(NodeKind Kind);
- NodeKind kind() const { return static_cast<NodeKind>(Kind); }
- NodeRole role() const { return static_cast<NodeRole>(Role); }
+ NodeKind getKind() const { return static_cast<NodeKind>(Kind); }
+ NodeRole getRole() const { return static_cast<NodeRole>(Role); }
/// Whether the node is detached from a tree, i.e. does not have a parent.
bool isDetached() const;
@@ -99,11 +99,11 @@ class Node {
/// modifiable.
bool canModify() const { return CanModify; }
- const Tree *parent() const { return Parent; }
- Tree *parent() { return Parent; }
+ const Tree *getParent() const { return Parent; }
+ Tree *getParent() { return Parent; }
- const Node *nextSibling() const { return NextSibling; }
- Node *nextSibling() { return NextSibling; }
+ const Node *getNextSibling() const { return NextSibling; }
+ Node *getNextSibling() { return NextSibling; }
/// Dumps the structure of a subtree. For debugging and testing purposes.
std::string dump(const SourceManager &SM) const;
@@ -142,7 +142,7 @@ class Leaf final : public Node {
Leaf(const Token *T);
static bool classof(const Node *N);
- const Token *token() const { return Tok; }
+ const Token *getToken() const { return Tok; }
private:
const Token *Tok;
@@ -154,16 +154,18 @@ class Tree : public Node {
using Node::Node;
static bool classof(const Node *N);
- Node *firstChild() { return FirstChild; }
- const Node *firstChild() const { return FirstChild; }
+ Node *getFirstChild() { return FirstChild; }
+ const Node *getFirstChild() const { return FirstChild; }
- Leaf *firstLeaf();
- const Leaf *firstLeaf() const {
- return const_cast<Tree *>(this)->firstLeaf();
+ Leaf *findFirstLeaf();
+ const Leaf *findFirstLeaf() const {
+ return const_cast<Tree *>(this)->findFirstLeaf();
}
- Leaf *lastLeaf();
- const Leaf *lastLeaf() const { return const_cast<Tree *>(this)->lastLeaf(); }
+ Leaf *findLastLeaf();
+ const Leaf *findLastLeaf() const {
+ return const_cast<Tree *>(this)->findLastLeaf();
+ }
protected:
/// Find the first node with a corresponding role.
diff --git a/clang/lib/Tooling/Syntax/BuildTree.cpp b/clang/lib/Tooling/Syntax/BuildTree.cpp
index 1942290b5abc..8de50dd02162 100644
--- a/clang/lib/Tooling/Syntax/BuildTree.cpp
+++ b/clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -366,12 +366,14 @@ class ASTToSyntaxMapping {
class syntax::TreeBuilder {
public:
TreeBuilder(syntax::Arena &Arena) : Arena(Arena), Pending(Arena) {
- for (const auto &T : Arena.tokenBuffer().expandedTokens())
+ for (const auto &T : Arena.getTokenBuffer().expandedTokens())
LocationToToken.insert({T.location().getRawEncoding(), &T});
}
- llvm::BumpPtrAllocator &allocator() { return Arena.allocator(); }
- const SourceManager &sourceManager() const { return Arena.sourceManager(); }
+ llvm::BumpPtrAllocator &allocator() { return Arena.getAllocator(); }
+ const SourceManager &sourceManager() const {
+ return Arena.getSourceManager();
+ }
/// Populate children for \p New node, assuming it covers tokens from \p
/// Range.
@@ -421,13 +423,13 @@ class syntax::TreeBuilder {
/// Finish building the tree and consume the root node.
syntax::TranslationUnit *finalize() && {
- auto Tokens = Arena.tokenBuffer().expandedTokens();
+ auto Tokens = Arena.getTokenBuffer().expandedTokens();
assert(!Tokens.empty());
assert(Tokens.back().kind() == tok::eof);
// Build the root of the tree, consuming all the children.
Pending.foldChildren(Arena, Tokens.drop_back(),
- new (Arena.allocator()) syntax::TranslationUnit);
+ new (Arena.getAllocator()) syntax::TranslationUnit);
auto *TU = cast<syntax::TranslationUnit>(std::move(Pending).finalize());
TU->assertInvariantsRecursive();
@@ -451,7 +453,7 @@ class syntax::TreeBuilder {
assert(First.isValid());
assert(Last.isValid());
assert(First == Last ||
- Arena.sourceManager().isBeforeInTranslationUnit(First, Last));
+ Arena.getSourceManager().isBeforeInTranslationUnit(First, Last));
return llvm::makeArrayRef(findToken(First), std::next(findToken(Last)));
}
@@ -540,7 +542,7 @@ class syntax::TreeBuilder {
}
void setRole(syntax::Node *N, NodeRole R) {
- assert(N->role() == NodeRole::Detached);
+ assert(N->getRole() == NodeRole::Detached);
N->setRole(R);
}
@@ -552,14 +554,14 @@ class syntax::TreeBuilder {
/// Ensures that added nodes properly nest and cover the whole token stream.
struct Forest {
Forest(syntax::Arena &A) {
- assert(!A.tokenBuffer().expandedTokens().empty());
- assert(A.tokenBuffer().expandedTokens().back().kind() == tok::eof);
+ assert(!A.getTokenBuffer().expandedTokens().empty());
+ assert(A.getTokenBuffer().expandedTokens().back().kind() == tok::eof);
// Create all leaf nodes.
// Note that we do not have 'eof' in the tree.
- for (auto &T : A.tokenBuffer().expandedTokens().drop_back()) {
- auto *L = new (A.allocator()) syntax::Leaf(&T);
+ for (auto &T : A.getTokenBuffer().expandedTokens().drop_back()) {
+ auto *L = new (A.getAllocator()) syntax::Leaf(&T);
L->Original = true;
- L->CanModify = A.tokenBuffer().spelledForExpanded(T).hasValue();
+ L->CanModify = A.getTokenBuffer().spelledForExpanded(T).hasValue();
Trees.insert(Trees.end(), {&T, L});
}
}
@@ -572,7 +574,7 @@ class syntax::TreeBuilder {
assert((std::next(It) == Trees.end() ||
std::next(It)->first == Range.end()) &&
"no child with the specified range");
- assert(It->second->role() == NodeRole::Detached &&
+ assert(It->second->getRole() == NodeRole::Detached &&
"re-assigning role for a child");
It->second->setRole(Role);
}
@@ -581,7 +583,7 @@ class syntax::TreeBuilder {
void foldChildren(const syntax::Arena &A, ArrayRef<syntax::Token> Tokens,
syntax::Tree *Node) {
// Attach children to `Node`.
- assert(Node->firstChild() == nullptr && "node already has children");
+ assert(Node->getFirstChild() == nullptr && "node already has children");
auto *FirstToken = Tokens.begin();
auto BeginChildren = Trees.lower_bound(FirstToken);
@@ -597,14 +599,15 @@ class syntax::TreeBuilder {
// We need to go in reverse order, because we can only prepend.
for (auto It = EndChildren; It != BeginChildren; --It) {
auto *C = std::prev(It)->second;
- if (C->role() == NodeRole::Detached)
+ if (C->getRole() == NodeRole::Detached)
C->setRole(NodeRole::Unknown);
Node->prependChildLowLevel(C);
}
// Mark that this node came from the AST and is backed by the source code.
Node->Original = true;
- Node->CanModify = A.tokenBuffer().spelledForExpanded(Tokens).hasValue();
+ Node->CanModify =
+ A.getTokenBuffer().spelledForExpanded(Tokens).hasValue();
Trees.erase(BeginChildren, EndChildren);
Trees.insert({FirstToken, Node});
@@ -624,12 +627,12 @@ class syntax::TreeBuilder {
unsigned CoveredTokens =
It != Trees.end()
? (std::next(It)->first - It->first)
- : A.tokenBuffer().expandedTokens().end() - It->first;
+ : A.getTokenBuffer().expandedTokens().end() - It->first;
R += std::string(
- formatv("- '{0}' covers '{1}'+{2} tokens\n", It->second->kind(),
- It->first->text(A.sourceManager()), CoveredTokens));
- R += It->second->dump(A.sourceManager());
+ formatv("- '{0}' covers '{1}'+{2} tokens\n", It->second->getKind(),
+ It->first->text(A.getSourceManager()), CoveredTokens));
+ R += It->second->dump(A.getSourceManager());
}
return R;
}
diff --git a/clang/lib/Tooling/Syntax/ComputeReplacements.cpp b/clang/lib/Tooling/Syntax/ComputeReplacements.cpp
index 30b3ee17d092..93b1c4416bf4 100644
--- a/clang/lib/Tooling/Syntax/ComputeReplacements.cpp
+++ b/clang/lib/Tooling/Syntax/ComputeReplacements.cpp
@@ -32,13 +32,14 @@ void enumerateTokenSpans(const syntax::Tree *Root, ProcessTokensFn Callback) {
private:
void process(const syntax::Node *N) {
if (auto *T = dyn_cast<syntax::Tree>(N)) {
- for (auto *C = T->firstChild(); C != nullptr; C = C->nextSibling())
+ for (auto *C = T->getFirstChild(); C != nullptr;
+ C = C->getNextSibling())
process(C);
return;
}
auto *L = cast<syntax::Leaf>(N);
- if (SpanEnd == L->token() && SpanIsOriginal == L->isOriginal()) {
+ if (SpanEnd == L->getToken() && SpanIsOriginal == L->isOriginal()) {
// Extend the current span.
++SpanEnd;
return;
@@ -47,7 +48,7 @@ void enumerateTokenSpans(const syntax::Tree *Root, ProcessTokensFn Callback) {
if (SpanBegin)
Callback(llvm::makeArrayRef(SpanBegin, SpanEnd), SpanIsOriginal);
// Start recording a new span.
- SpanBegin = L->token();
+ SpanBegin = L->getToken();
SpanEnd = SpanBegin + 1;
SpanIsOriginal = L->isOriginal();
}
@@ -63,8 +64,8 @@ void enumerateTokenSpans(const syntax::Tree *Root, ProcessTokensFn Callback) {
syntax::FileRange rangeOfExpanded(const syntax::Arena &A,
llvm::ArrayRef<syntax::Token> Expanded) {
- auto &Buffer = A.tokenBuffer();
- auto &SM = A.sourceManager();
+ auto &Buffer = A.getTokenBuffer();
+ auto &SM = A.getSourceManager();
// Check that \p Expanded actually points into expanded tokens.
assert(Buffer.expandedTokens().begin() <= Expanded.begin());
@@ -84,8 +85,8 @@ syntax::FileRange rangeOfExpanded(const syntax::Arena &A,
tooling::Replacements
syntax::computeReplacements(const syntax::Arena &A,
const syntax::TranslationUnit &TU) {
- auto &Buffer = A.tokenBuffer();
- auto &SM = A.sourceManager();
+ auto &Buffer = A.getTokenBuffer();
+ auto &SM = A.getSourceManager();
tooling::Replacements Replacements;
// Text inserted by the replacement we are building now.
diff --git a/clang/lib/Tooling/Syntax/Mutations.cpp b/clang/lib/Tooling/Syntax/Mutations.cpp
index 24048b297a11..bf1bcda26455 100644
--- a/clang/lib/Tooling/Syntax/Mutations.cpp
+++ b/clang/lib/Tooling/Syntax/Mutations.cpp
@@ -36,7 +36,7 @@ class syntax::MutationsImpl {
assert(Role != NodeRole::Detached);
New->setRole(Role);
- auto *P = Anchor->parent();
+ auto *P = Anchor->getParent();
P->replaceChildRangeLowLevel(Anchor, Anchor, New);
P->assertInvariants();
@@ -52,16 +52,16 @@ class syntax::MutationsImpl {
assert(New->isDetached());
New->Role = Old->Role;
- auto *P = Old->parent();
- P->replaceChildRangeLowLevel(findPrevious(Old), Old->nextSibling(), New);
+ auto *P = Old->getParent();
+ P->replaceChildRangeLowLevel(findPrevious(Old), Old->getNextSibling(), New);
P->assertInvariants();
}
/// Completely remove the node from its parent.
static void remove(syntax::Node *N) {
- auto *P = N->parent();
- P->replaceChildRangeLowLevel(findPrevious(N), N->nextSibling(),
+ auto *P = N->getParent();
+ P->replaceChildRangeLowLevel(findPrevious(N), N->getNextSibling(),
/*New=*/nullptr);
P->assertInvariants();
@@ -70,11 +70,11 @@ class syntax::MutationsImpl {
private:
static syntax::Node *findPrevious(syntax::Node *N) {
- if (N->parent()->firstChild() == N)
+ if (N->getParent()->getFirstChild() == N)
return nullptr;
- for (syntax::Node *C = N->parent()->firstChild(); C != nullptr;
- C = C->nextSibling()) {
- if (C->nextSibling() == N)
+ for (syntax::Node *C = N->getParent()->getFirstChild(); C != nullptr;
+ C = C->getNextSibling()) {
+ if (C->getNextSibling() == N)
return C;
}
llvm_unreachable("could not find a child node");
@@ -85,7 +85,7 @@ void syntax::removeStatement(syntax::Arena &A, syntax::Statement *S) {
assert(S);
assert(S->canModify());
- if (isa<CompoundStatement>(S->parent())) {
+ if (isa<CompoundStatement>(S->getParent())) {
// A child of CompoundStatement can just be safely removed.
MutationsImpl::remove(S);
return;
diff --git a/clang/lib/Tooling/Syntax/Nodes.cpp b/clang/lib/Tooling/Syntax/Nodes.cpp
index 6102c45a08e4..bb63585cbd7c 100644
--- a/clang/lib/Tooling/Syntax/Nodes.cpp
+++ b/clang/lib/Tooling/Syntax/Nodes.cpp
@@ -501,8 +501,8 @@ syntax::Leaf *syntax::CompoundStatement::getLbrace() {
std::vector<syntax::Statement *> syntax::CompoundStatement::getStatements() {
std::vector<syntax::Statement *> Children;
- for (auto *C = firstChild(); C; C = C->nextSibling()) {
- assert(C->role() == syntax::NodeRole::Statement);
+ for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
+ assert(C->getRole() == syntax::NodeRole::Statement);
Children.push_back(cast<syntax::Statement>(C));
}
return Children;
@@ -524,8 +524,8 @@ syntax::Expression *syntax::StaticAssertDeclaration::getMessage() {
std::vector<syntax::SimpleDeclarator *>
syntax::SimpleDeclaration::getDeclarators() {
std::vector<syntax::SimpleDeclarator *> Children;
- for (auto *C = firstChild(); C; C = C->nextSibling()) {
- if (C->role() == syntax::NodeRole::Declarator)
+ for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
+ if (C->getRole() == syntax::NodeRole::Declarator)
Children.push_back(cast<syntax::SimpleDeclarator>(C));
}
return Children;
diff --git a/clang/lib/Tooling/Syntax/Synthesis.cpp b/clang/lib/Tooling/Syntax/Synthesis.cpp
index aa01a34c761f..701a1e60a4f3 100644
--- a/clang/lib/Tooling/Syntax/Synthesis.cpp
+++ b/clang/lib/Tooling/Syntax/Synthesis.cpp
@@ -28,7 +28,7 @@ clang::syntax::Leaf *syntax::createPunctuation(clang::syntax::Arena &A,
.second;
assert(Tokens.size() == 1);
assert(Tokens.front().kind() == K);
- auto *L = new (A.allocator()) clang::syntax::Leaf(Tokens.begin());
+ auto *L = new (A.getAllocator()) clang::syntax::Leaf(Tokens.begin());
FactoryImpl::setCanModify(L);
L->assertInvariants();
return L;
@@ -36,7 +36,7 @@ clang::syntax::Leaf *syntax::createPunctuation(clang::syntax::Arena &A,
clang::syntax::EmptyStatement *
syntax::createEmptyStatement(clang::syntax::Arena &A) {
- auto *S = new (A.allocator()) clang::syntax::EmptyStatement;
+ auto *S = new (A.getAllocator()) clang::syntax::EmptyStatement;
FactoryImpl::setCanModify(S);
FactoryImpl::prependChildLowLevel(S, createPunctuation(A, clang::tok::semi),
NodeRole::Unknown);
diff --git a/clang/lib/Tooling/Syntax/Tree.cpp b/clang/lib/Tooling/Syntax/Tree.cpp
index 2cef806937bf..f9d1fa6110ff 100644
--- a/clang/lib/Tooling/Syntax/Tree.cpp
+++ b/clang/lib/Tooling/Syntax/Tree.cpp
@@ -19,7 +19,7 @@ namespace {
static void traverse(const syntax::Node *N,
llvm::function_ref<void(const syntax::Node *)> Visit) {
if (auto *T = dyn_cast<syntax::Tree>(N)) {
- for (auto *C = T->firstChild(); C; C = C->nextSibling())
+ for (auto *C = T->getFirstChild(); C; C = C->getNextSibling())
traverse(C, Visit);
}
Visit(N);
@@ -36,7 +36,9 @@ syntax::Arena::Arena(SourceManager &SourceMgr, const LangOptions &LangOpts,
const TokenBuffer &Tokens)
: SourceMgr(SourceMgr), LangOpts(LangOpts), Tokens(Tokens) {}
-const syntax::TokenBuffer &syntax::Arena::tokenBuffer() const { return Tokens; }
+const syntax::TokenBuffer &syntax::Arena::getTokenBuffer() const {
+ return Tokens;
+}
std::pair<FileID, ArrayRef<syntax::Token>>
syntax::Arena::lexBuffer(std::unique_ptr<llvm::MemoryBuffer> Input) {
@@ -51,7 +53,7 @@ syntax::Leaf::Leaf(const syntax::Token *Tok) : Node(NodeKind::Leaf), Tok(Tok) {
}
bool syntax::Leaf::classof(const Node *N) {
- return N->kind() == NodeKind::Leaf;
+ return N->getKind() == NodeKind::Leaf;
}
syntax::Node::Node(NodeKind Kind)
@@ -60,16 +62,20 @@ syntax::Node::Node(NodeKind Kind)
this->setRole(NodeRole::Detached);
}
-bool syntax::Node::isDetached() const { return role() == NodeRole::Detached; }
+bool syntax::Node::isDetached() const {
+ return getRole() == NodeRole::Detached;
+}
void syntax::Node::setRole(NodeRole NR) {
this->Role = static_cast<unsigned>(NR);
}
-bool syntax::Tree::classof(const Node *N) { return N->kind() > NodeKind::Leaf; }
+bool syntax::Tree::classof(const Node *N) {
+ return N->getKind() > NodeKind::Leaf;
+}
void syntax::Tree::prependChildLowLevel(Node *Child, NodeRole Role) {
- assert(Child->role() == NodeRole::Detached);
+ assert(Child->getRole() == NodeRole::Detached);
assert(Role != NodeRole::Detached);
Child->setRole(Role);
@@ -79,7 +85,7 @@ void syntax::Tree::prependChildLowLevel(Node *Child, NodeRole Role) {
void syntax::Tree::prependChildLowLevel(Node *Child) {
assert(Child->Parent == nullptr);
assert(Child->NextSibling == nullptr);
- assert(Child->role() != NodeRole::Detached);
+ assert(Child->getRole() != NodeRole::Detached);
Child->Parent = this;
Child->NextSibling = this->FirstChild;
@@ -91,15 +97,15 @@ void syntax::Tree::replaceChildRangeLowLevel(Node *BeforeBegin, Node *End,
assert(!BeforeBegin || BeforeBegin->Parent == this);
#ifndef NDEBUG
- for (auto *N = New; N; N = N->nextSibling()) {
+ for (auto *N = New; N; N = N->getNextSibling()) {
assert(N->Parent == nullptr);
- assert(N->role() != NodeRole::Detached && "Roles must be set");
+ assert(N->getRole() != NodeRole::Detached && "Roles must be set");
// FIXME: sanity-check the role.
}
#endif
// Detach old nodes.
- for (auto *N = !BeforeBegin ? FirstChild : BeforeBegin->nextSibling();
+ for (auto *N = !BeforeBegin ? FirstChild : BeforeBegin->getNextSibling();
N != End;) {
auto *Next = N->NextSibling;
@@ -120,7 +126,7 @@ void syntax::Tree::replaceChildRangeLowLevel(Node *BeforeBegin, Node *End,
if (New) {
auto *Last = New;
- for (auto *N = New; N != nullptr; N = N->nextSibling()) {
+ for (auto *N = New; N != nullptr; N = N->getNextSibling()) {
Last = N;
N->Parent = this;
}
@@ -136,7 +142,7 @@ namespace {
static void dumpLeaf(raw_ostream &OS, const syntax::Leaf *L,
const SourceManager &SM) {
assert(L);
- const auto *Token = L->token();
+ const auto *Token = L->getToken();
assert(Token);
// Handle 'eof' separately, calling text() on it produces an empty string.
if (Token->kind() == tok::eof)
@@ -148,8 +154,8 @@ static void dumpLeaf(raw_ostream &OS, const syntax::Leaf *L,
static void dumpNode(raw_ostream &OS, const syntax::Node *N,
const SourceManager &SM, std::vector<bool> IndentMask) {
auto dumpExtraInfo = [&OS](const syntax::Node *N) {
- if (N->role() != syntax::NodeRole::Unknown)
- OS << " " << N->role();
+ if (N->getRole() != syntax::NodeRole::Unknown)
+ OS << " " << N->getRole();
if (!N->isOriginal())
OS << " synthesized";
if (!N->canModify())
@@ -167,18 +173,18 @@ static void dumpNode(raw_ostream &OS, const syntax::Node *N,
}
const auto *T = cast<syntax::Tree>(N);
- OS << T->kind();
+ OS << T->getKind();
dumpExtraInfo(N);
OS << "\n";
- for (const auto *It = T->firstChild(); It; It = It->nextSibling()) {
+ for (const auto *It = T->getFirstChild(); It; It = It->getNextSibling()) {
for (bool Filled : IndentMask) {
if (Filled)
OS << "| ";
else
OS << " ";
}
- if (!It->nextSibling()) {
+ if (!It->getNextSibling()) {
OS << "`-";
IndentMask.push_back(false);
} else {
@@ -213,18 +219,18 @@ std::string syntax::Node::dumpTokens(const SourceManager &SM) const {
void syntax::Node::assertInvariants() const {
#ifndef NDEBUG
if (isDetached())
- assert(parent() == nullptr);
+ assert(getParent() == nullptr);
else
- assert(parent() != nullptr);
+ assert(getParent() != nullptr);
auto *T = dyn_cast<Tree>(this);
if (!T)
return;
- for (auto *C = T->firstChild(); C; C = C->nextSibling()) {
+ for (auto *C = T->getFirstChild(); C; C = C->getNextSibling()) {
if (T->isOriginal())
assert(C->isOriginal());
assert(!C->isDetached());
- assert(C->parent() == T);
+ assert(C->getParent() == T);
}
#endif
}
@@ -235,9 +241,9 @@ void syntax::Node::assertInvariantsRecursive() const {
#endif
}
-syntax::Leaf *syntax::Tree::firstLeaf() {
+syntax::Leaf *syntax::Tree::findFirstLeaf() {
auto *T = this;
- while (auto *C = T->firstChild()) {
+ while (auto *C = T->getFirstChild()) {
if (auto *L = dyn_cast<syntax::Leaf>(C))
return L;
T = cast<syntax::Tree>(C);
@@ -245,11 +251,11 @@ syntax::Leaf *syntax::Tree::firstLeaf() {
return nullptr;
}
-syntax::Leaf *syntax::Tree::lastLeaf() {
+syntax::Leaf *syntax::Tree::findLastLeaf() {
auto *T = this;
- while (auto *C = T->firstChild()) {
+ while (auto *C = T->getFirstChild()) {
// Find the last child.
- while (auto *Next = C->nextSibling())
+ while (auto *Next = C->getNextSibling())
C = Next;
if (auto *L = dyn_cast<syntax::Leaf>(C))
@@ -260,8 +266,8 @@ syntax::Leaf *syntax::Tree::lastLeaf() {
}
syntax::Node *syntax::Tree::findChild(NodeRole R) {
- for (auto *C = FirstChild; C; C = C->nextSibling()) {
- if (C->role() == R)
+ for (auto *C = FirstChild; C; C = C->getNextSibling()) {
+ if (C->getRole() == R)
return C;
}
return nullptr;
@@ -269,13 +275,13 @@ syntax::Node *syntax::Tree::findChild(NodeRole R) {
std::vector<syntax::List::ElementAndDelimiter<syntax::Node>>
syntax::List::getElementsAsNodesAndDelimiters() {
- if (!firstChild())
+ if (!getFirstChild())
return {};
auto children = std::vector<syntax::List::ElementAndDelimiter<Node>>();
syntax::Node *elementWithoutDelimiter = nullptr;
- for (auto *C = firstChild(); C; C = C->nextSibling()) {
- switch (C->role()) {
+ for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
+ switch (C->getRole()) {
case syntax::NodeRole::ListElement: {
if (elementWithoutDelimiter) {
children.push_back({elementWithoutDelimiter, nullptr});
@@ -314,13 +320,13 @@ syntax::List::getElementsAsNodesAndDelimiters() {
// Almost the same implementation of `getElementsAsNodesAndDelimiters` but
// ignoring delimiters
std::vector<syntax::Node *> syntax::List::getElementsAsNodes() {
- if (!firstChild())
+ if (!getFirstChild())
return {};
auto children = std::vector<syntax::Node *>();
syntax::Node *elementWithoutDelimiter = nullptr;
- for (auto *C = firstChild(); C; C = C->nextSibling()) {
- switch (C->role()) {
+ for (auto *C = getFirstChild(); C; C = C->getNextSibling()) {
+ switch (C->getRole()) {
case syntax::NodeRole::ListElement: {
if (elementWithoutDelimiter) {
children.push_back(elementWithoutDelimiter);
@@ -356,7 +362,7 @@ std::vector<syntax::Node *> syntax::List::getElementsAsNodes() {
}
clang::tok::TokenKind syntax::List::getDelimiterTokenKind() {
- switch (this->kind()) {
+ switch (this->getKind()) {
case NodeKind::NestedNameSpecifier:
return clang::tok::coloncolon;
case NodeKind::CallArguments:
@@ -369,7 +375,7 @@ clang::tok::TokenKind syntax::List::getDelimiterTokenKind() {
}
syntax::List::TerminationKind syntax::List::getTerminationKind() {
- switch (this->kind()) {
+ switch (this->getKind()) {
case NodeKind::NestedNameSpecifier:
return TerminationKind::Terminated;
case NodeKind::CallArguments:
@@ -382,7 +388,7 @@ syntax::List::TerminationKind syntax::List::getTerminationKind() {
}
bool syntax::List::canBeEmpty() {
- switch (this->kind()) {
+ switch (this->getKind()) {
case NodeKind::NestedNameSpecifier:
return false;
case NodeKind::CallArguments:
diff --git a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
index 6fcc74ba55d0..95ebeb2c5940 100644
--- a/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ b/clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -28,7 +28,7 @@ class BuildSyntaxTreeTest : public SyntaxTreeTest {
<< "Source file has syntax errors, they were printed to the test "
"log";
}
- auto Actual = StringRef(Root->dump(Arena->sourceManager())).trim().str();
+ auto Actual = StringRef(Root->dump(Arena->getSourceManager())).trim().str();
// EXPECT_EQ shows the
diff between the two strings if they are
diff erent.
EXPECT_EQ(Tree.trim().str(), Actual);
if (Actual != Tree.trim().str()) {
@@ -63,7 +63,9 @@ class BuildSyntaxTreeTest : public SyntaxTreeTest {
auto *AnnotatedNode = nodeByRange(AnnotatedRanges[i], Root);
assert(AnnotatedNode);
auto AnnotatedNodeDump =
- StringRef(AnnotatedNode->dump(Arena->sourceManager())).trim().str();
+ StringRef(AnnotatedNode->dump(Arena->getSourceManager()))
+ .trim()
+ .str();
// EXPECT_EQ shows the
diff between the two strings if they are
diff erent.
EXPECT_EQ(TreeDumps[i].trim().str(), AnnotatedNodeDump)
<< "Dumps diverged for the code:\n"
diff --git a/clang/unittests/Tooling/Syntax/SynthesisTest.cpp b/clang/unittests/Tooling/Syntax/SynthesisTest.cpp
index db4ee6b585fb..884f3797edef 100644
--- a/clang/unittests/Tooling/Syntax/SynthesisTest.cpp
+++ b/clang/unittests/Tooling/Syntax/SynthesisTest.cpp
@@ -26,7 +26,7 @@ TEST_P(SyntaxTreeTest, Leaf_Punctuation) {
auto *C = syntax::createPunctuation(*Arena, tok::comma);
ASSERT_NE(C, nullptr);
- EXPECT_EQ(C->token()->kind(), tok::comma);
+ EXPECT_EQ(C->getToken()->kind(), tok::comma);
EXPECT_TRUE(C->canModify());
EXPECT_FALSE(C->isOriginal());
EXPECT_TRUE(C->isDetached());
diff --git a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
index 3618949c36ae..2305b78006b1 100644
--- a/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
+++ b/clang/unittests/Tooling/Syntax/TreeTestBase.cpp
@@ -38,10 +38,10 @@ namespace {
ArrayRef<syntax::Token> tokens(syntax::Node *N) {
assert(N->isOriginal() && "tokens of modified nodes are not well-defined");
if (auto *L = dyn_cast<syntax::Leaf>(N))
- return llvm::makeArrayRef(L->token(), 1);
+ return llvm::makeArrayRef(L->getToken(), 1);
auto *T = cast<syntax::Tree>(N);
- return llvm::makeArrayRef(T->firstLeaf()->token(),
- T->lastLeaf()->token() + 1);
+ return llvm::makeArrayRef(T->findFirstLeaf()->getToken(),
+ T->findLastLeaf()->getToken() + 1);
}
} // namespace
@@ -170,7 +170,7 @@ syntax::Node *SyntaxTreeTest::nodeByRange(llvm::Annotations::Range R,
auto *T = dyn_cast<syntax::Tree>(Root);
if (!T)
return nullptr;
- for (auto *C = T->firstChild(); C != nullptr; C = C->nextSibling()) {
+ for (auto *C = T->getFirstChild(); C != nullptr; C = C->getNextSibling()) {
if (auto *Result = nodeByRange(R, C))
return Result;
}
More information about the cfe-commits
mailing list