Skip to content

Commit bc3e993

Browse files
committed
[clang-diff] Remove NodeCountVisitor, NFC
Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D37000 llvm-svn: 311770
1 parent 937c74a commit bc3e993

File tree

1 file changed

+3
-35
lines changed

1 file changed

+3
-35
lines changed

clang/lib/Tooling/ASTDiff/ASTDiff.cpp

Lines changed: 3 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ class SyntaxTree::Impl {
127127

128128
SyntaxTree *Parent;
129129
ASTContext *
130+
/// Nodes in preorder.
131+
std::vector<Node> Nodes;
130132
std::vector<NodeId> Leaves;
131133
// Maps preorder indices to postorder ones.
132134
std::vector<int> PostorderIds;
@@ -155,9 +157,6 @@ class SyntaxTree::Impl {
155157
std::string getStmtValue(const Stmt *S) const;
156158

157159
private:
158-
/// Nodes in preorder.
159-
std::vector<Node> Nodes;
160-
161160
void initTree();
162161
void setLeftMostDescendants();
163162
};
@@ -181,32 +180,6 @@ static bool isNodeExcluded(const SourceManager &SrcMgr, T *N) {
181180
return isSpecializedNodeExcluded(N);
182181
}
183182

184-
namespace {
185-
/// Counts the number of nodes that will be compared.
186-
struct NodeCountVisitor : public RecursiveASTVisitor<NodeCountVisitor> {
187-
int Count = 0;
188-
const SyntaxTree::Impl &Tree;
189-
NodeCountVisitor(const SyntaxTree::Impl &Tree) : Tree(Tree) {}
190-
bool TraverseDecl(Decl *D) {
191-
if (isNodeExcluded(Tree.AST.getSourceManager(), D))
192-
return true;
193-
++Count;
194-
RecursiveASTVisitor<NodeCountVisitor>::TraverseDecl(D);
195-
return true;
196-
}
197-
bool TraverseStmt(Stmt *S) {
198-
if (S)
199-
S = S->IgnoreImplicit();
200-
if (isNodeExcluded(Tree.AST.getSourceManager(), S))
201-
return true;
202-
++Count;
203-
RecursiveASTVisitor<NodeCountVisitor>::TraverseStmt(S);
204-
return true;
205-
}
206-
bool TraverseType(QualType T) { return true; }
207-
};
208-
} // end anonymous namespace
209-
210183
namespace {
211184
// Sets Height, Parent and Children for each node.
212185
struct PreorderVisitor : public RecursiveASTVisitor<PreorderVisitor> {
@@ -218,6 +191,7 @@ struct PreorderVisitor : public RecursiveASTVisitor<PreorderVisitor> {
218191

219192
template <class T> std::tuple<NodeId, NodeId> PreTraverse(T *ASTNode) {
220193
NodeId MyId = Id;
194+
Tree.Nodes.emplace_back();
221195
Node &N = Tree.getMutableNode(MyId);
222196
N.Parent = Parent;
223197
N.Depth = Depth;
@@ -274,19 +248,13 @@ struct PreorderVisitor : public RecursiveASTVisitor<PreorderVisitor> {
274248

275249
SyntaxTree::Impl::Impl(SyntaxTree *Parent, Decl *N, ASTContext &AST)
276250
: Parent(Parent), AST(AST) {
277-
NodeCountVisitor NodeCounter(*this);
278-
NodeCounter.TraverseDecl(N);
279-
Nodes.resize(NodeCounter.Count);
280251
PreorderVisitor PreorderWalker(*this);
281252
PreorderWalker.TraverseDecl(N);
282253
initTree();
283254
}
284255

285256
SyntaxTree::Impl::Impl(SyntaxTree *Parent, Stmt *N, ASTContext &AST)
286257
: Parent(Parent), AST(AST) {
287-
NodeCountVisitor NodeCounter(*this);
288-
NodeCounter.TraverseStmt(N);
289-
Nodes.resize(NodeCounter.Count);
290258
PreorderVisitor PreorderWalker(*this);
291259
PreorderWalker.TraverseStmt(N);
292260
initTree();

0 commit comments

Comments
 (0)