зеркало из https://github.com/microsoft/clang-1.git
Revert "Fix RecursiveASTVisitor's data recursion to call the Traverse* functions if they"
FAIL: Clang :: Index/index-many-call-ops.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155962 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
ff310c763e
Коммит
b51c7f3fe6
|
@ -405,14 +405,18 @@ private:
|
|||
bool TraverseFunctionHelper(FunctionDecl *D);
|
||||
bool TraverseVarHelper(VarDecl *D);
|
||||
|
||||
bool Walk(Stmt *S);
|
||||
|
||||
struct EnqueueJob {
|
||||
Stmt *S;
|
||||
Stmt::child_iterator StmtIt;
|
||||
|
||||
EnqueueJob(Stmt *S) : S(S), StmtIt() {}
|
||||
EnqueueJob(Stmt *S) : S(S), StmtIt() {
|
||||
if (Expr *E = dyn_cast_or_null<Expr>(S))
|
||||
S = E->IgnoreParens();
|
||||
}
|
||||
};
|
||||
bool dataTraverse(Stmt *S);
|
||||
bool dataTraverseNode(Stmt *S, bool &EnqueueChildren);
|
||||
};
|
||||
|
||||
template<typename Derived>
|
||||
|
@ -431,12 +435,7 @@ bool RecursiveASTVisitor<Derived>::dataTraverse(Stmt *S) {
|
|||
|
||||
if (getDerived().shouldUseDataRecursionFor(CurrS)) {
|
||||
if (job.StmtIt == Stmt::child_iterator()) {
|
||||
bool EnqueueChildren = true;
|
||||
if (!dataTraverseNode(CurrS, EnqueueChildren)) return false;
|
||||
if (!EnqueueChildren) {
|
||||
Queue.pop_back();
|
||||
continue;
|
||||
}
|
||||
if (!Walk(CurrS)) return false;
|
||||
job.StmtIt = CurrS->child_begin();
|
||||
} else {
|
||||
++job.StmtIt;
|
||||
|
@ -457,16 +456,10 @@ bool RecursiveASTVisitor<Derived>::dataTraverse(Stmt *S) {
|
|||
}
|
||||
|
||||
template<typename Derived>
|
||||
bool RecursiveASTVisitor<Derived>::dataTraverseNode(Stmt *S,
|
||||
bool &EnqueueChildren) {
|
||||
bool RecursiveASTVisitor<Derived>::Walk(Stmt *S) {
|
||||
|
||||
// Dispatch to the corresponding WalkUpFrom* function only if the derived
|
||||
// class didn't override Traverse* (and thus the traversal is trivial).
|
||||
#define DISPATCH_WALK(NAME, CLASS, VAR) \
|
||||
if (&RecursiveASTVisitor::Traverse##NAME == &Derived::Traverse##NAME) \
|
||||
return getDerived().WalkUpFrom##NAME(static_cast<CLASS*>(VAR)); \
|
||||
EnqueueChildren = false; \
|
||||
return getDerived().Traverse##NAME(static_cast<CLASS*>(VAR));
|
||||
return getDerived().WalkUpFrom##NAME(static_cast<CLASS*>(VAR));
|
||||
|
||||
if (BinaryOperator *BinOp = dyn_cast<BinaryOperator>(S)) {
|
||||
switch (BinOp->getOpcode()) {
|
||||
|
|
|
@ -165,25 +165,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
class CXXOperatorCallExprTraverser
|
||||
: public ExpectedLocationVisitor<CXXOperatorCallExprTraverser> {
|
||||
public:
|
||||
// Use Traverse, not Visit, to check that data recursion optimization isn't
|
||||
// bypassing the call of this function.
|
||||
bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr *CE) {
|
||||
Match(getOperatorSpelling(CE->getOperator()), CE->getExprLoc());
|
||||
return ExpectedLocationVisitor::TraverseCXXOperatorCallExpr(CE);
|
||||
}
|
||||
};
|
||||
|
||||
class ParenExprVisitor : public ExpectedLocationVisitor<ParenExprVisitor> {
|
||||
public:
|
||||
bool VisitParenExpr(ParenExpr *Parens) {
|
||||
Match("", Parens->getExprLoc());
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
TEST(RecursiveASTVisitor, VisitsBaseClassDeclarations) {
|
||||
TypeLocVisitor Visitor;
|
||||
Visitor.ExpectMatch("class X", 1, 30);
|
||||
|
@ -364,20 +345,4 @@ TEST(RecursiveASTVisitor, NoRecursionInSelfFriend) {
|
|||
"vector_iterator<int> it_int;\n"));
|
||||
}
|
||||
|
||||
TEST(RecursiveASTVisitor, TraversesOverloadedOperator) {
|
||||
CXXOperatorCallExprTraverser Visitor;
|
||||
Visitor.ExpectMatch("()", 4, 9);
|
||||
EXPECT_TRUE(Visitor.runOver(
|
||||
"struct A {\n"
|
||||
" int operator()();\n"
|
||||
"} a;\n"
|
||||
"int k = a();\n"));
|
||||
}
|
||||
|
||||
TEST(RecursiveASTVisitor, VisitsParensDuringDataRecursion) {
|
||||
ParenExprVisitor Visitor;
|
||||
Visitor.ExpectMatch("", 1, 9);
|
||||
EXPECT_TRUE(Visitor.runOver("int k = (4) + 9;\n"));
|
||||
}
|
||||
|
||||
} // end namespace clang
|
||||
|
|
Загрузка…
Ссылка в новой задаче