forked from OSchip/llvm-project
[clang-diff] Remove NodeCountVisitor, NFC
Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D37000 llvm-svn: 311770
This commit is contained in:
parent
937c74ac12
commit
bc3e993c1f
|
@ -127,6 +127,8 @@ public:
|
||||||
|
|
||||||
SyntaxTree *Parent;
|
SyntaxTree *Parent;
|
||||||
ASTContext *
|
ASTContext *
|
||||||
|
/// Nodes in preorder.
|
||||||
|
std::vector<Node> Nodes;
|
||||||
std::vector<NodeId> Leaves;
|
std::vector<NodeId> Leaves;
|
||||||
// Maps preorder indices to postorder ones.
|
// Maps preorder indices to postorder ones.
|
||||||
std::vector<int> PostorderIds;
|
std::vector<int> PostorderIds;
|
||||||
|
@ -155,9 +157,6 @@ public:
|
||||||
std::string getStmtValue(const Stmt *S) const;
|
std::string getStmtValue(const Stmt *S) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// Nodes in preorder.
|
|
||||||
std::vector<Node> Nodes;
|
|
||||||
|
|
||||||
void initTree();
|
void initTree();
|
||||||
void setLeftMostDescendants();
|
void setLeftMostDescendants();
|
||||||
};
|
};
|
||||||
|
@ -181,32 +180,6 @@ static bool isNodeExcluded(const SourceManager &SrcMgr, T *N) {
|
||||||
return isSpecializedNodeExcluded(N);
|
return isSpecializedNodeExcluded(N);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
|
||||||
/// Counts the number of nodes that will be compared.
|
|
||||||
struct NodeCountVisitor : public RecursiveASTVisitor<NodeCountVisitor> {
|
|
||||||
int Count = 0;
|
|
||||||
const SyntaxTree::Impl &Tree;
|
|
||||||
NodeCountVisitor(const SyntaxTree::Impl &Tree) : Tree(Tree) {}
|
|
||||||
bool TraverseDecl(Decl *D) {
|
|
||||||
if (isNodeExcluded(Tree.AST.getSourceManager(), D))
|
|
||||||
return true;
|
|
||||||
++Count;
|
|
||||||
RecursiveASTVisitor<NodeCountVisitor>::TraverseDecl(D);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool TraverseStmt(Stmt *S) {
|
|
||||||
if (S)
|
|
||||||
S = S->IgnoreImplicit();
|
|
||||||
if (isNodeExcluded(Tree.AST.getSourceManager(), S))
|
|
||||||
return true;
|
|
||||||
++Count;
|
|
||||||
RecursiveASTVisitor<NodeCountVisitor>::TraverseStmt(S);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
bool TraverseType(QualType T) { return true; }
|
|
||||||
};
|
|
||||||
} // end anonymous namespace
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// Sets Height, Parent and Children for each node.
|
// Sets Height, Parent and Children for each node.
|
||||||
struct PreorderVisitor : public RecursiveASTVisitor<PreorderVisitor> {
|
struct PreorderVisitor : public RecursiveASTVisitor<PreorderVisitor> {
|
||||||
|
@ -218,6 +191,7 @@ struct PreorderVisitor : public RecursiveASTVisitor<PreorderVisitor> {
|
||||||
|
|
||||||
template <class T> std::tuple<NodeId, NodeId> PreTraverse(T *ASTNode) {
|
template <class T> std::tuple<NodeId, NodeId> PreTraverse(T *ASTNode) {
|
||||||
NodeId MyId = Id;
|
NodeId MyId = Id;
|
||||||
|
Tree.Nodes.emplace_back();
|
||||||
Node &N = Tree.getMutableNode(MyId);
|
Node &N = Tree.getMutableNode(MyId);
|
||||||
N.Parent = Parent;
|
N.Parent = Parent;
|
||||||
N.Depth = Depth;
|
N.Depth = Depth;
|
||||||
|
@ -274,9 +248,6 @@ struct PreorderVisitor : public RecursiveASTVisitor<PreorderVisitor> {
|
||||||
|
|
||||||
SyntaxTree::Impl::Impl(SyntaxTree *Parent, Decl *N, ASTContext &AST)
|
SyntaxTree::Impl::Impl(SyntaxTree *Parent, Decl *N, ASTContext &AST)
|
||||||
: Parent(Parent), AST(AST) {
|
: Parent(Parent), AST(AST) {
|
||||||
NodeCountVisitor NodeCounter(*this);
|
|
||||||
NodeCounter.TraverseDecl(N);
|
|
||||||
Nodes.resize(NodeCounter.Count);
|
|
||||||
PreorderVisitor PreorderWalker(*this);
|
PreorderVisitor PreorderWalker(*this);
|
||||||
PreorderWalker.TraverseDecl(N);
|
PreorderWalker.TraverseDecl(N);
|
||||||
initTree();
|
initTree();
|
||||||
|
@ -284,9 +255,6 @@ SyntaxTree::Impl::Impl(SyntaxTree *Parent, Decl *N, ASTContext &AST)
|
||||||
|
|
||||||
SyntaxTree::Impl::Impl(SyntaxTree *Parent, Stmt *N, ASTContext &AST)
|
SyntaxTree::Impl::Impl(SyntaxTree *Parent, Stmt *N, ASTContext &AST)
|
||||||
: Parent(Parent), AST(AST) {
|
: Parent(Parent), AST(AST) {
|
||||||
NodeCountVisitor NodeCounter(*this);
|
|
||||||
NodeCounter.TraverseStmt(N);
|
|
||||||
Nodes.resize(NodeCounter.Count);
|
|
||||||
PreorderVisitor PreorderWalker(*this);
|
PreorderVisitor PreorderWalker(*this);
|
||||||
PreorderWalker.TraverseStmt(N);
|
PreorderWalker.TraverseStmt(N);
|
||||||
initTree();
|
initTree();
|
||||||
|
|
Loading…
Reference in New Issue