[cfe-commits] r155849 - in /cfe/trunk: include/clang/AST/RecursiveASTVisitor.h test/Index/index-many-call-ops.cpp

Richard Smith richard at metafoo.co.uk
Mon Apr 30 17:21:37 PDT 2012


Hi,

With this change, TraverseCXXOperatorCallExpr is no longer called --
dataTraverse just calls the WalkFoo() functions for a Foo node, and misses
the TraverseFoo function. This breaks include-what-you-use. Looking through
the code, I'm also concerned that dataTraverse skips over ParenExprs,
violating the requirement that RecursiveASTVisitor visit each node exactly
once.

I suppose this could be fixed by checking
&RecursiveASTVisitor::TraverseCXXOperatorCallExpr ==
&Derived::TraverseCXXOperatorCallExpr before choosing data recursion, but
perhaps there's a better way.

On Mon, Apr 30, 2012 at 3:12 PM, Argyrios Kyrtzidis <akyrtzi at gmail.com>wrote:

> Author: akirtzidis
> Date: Mon Apr 30 17:12:26 2012
> New Revision: 155849
>
> URL: http://llvm.org/viewvc/llvm-project?rev=155849&view=rev
> Log:
> For RecursiveASTVisitor, do data recursion for CXXOperatorCallExpr.
>
> rdar://11289247
>
> Added:
>    cfe/trunk/test/Index/index-many-call-ops.cpp
> Modified:
>    cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>
> Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=155849&r1=155848&r2=155849&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
> +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Mon Apr 30 17:12:26
> 2012
> @@ -151,7 +151,8 @@
>   /// \brief Return whether \param S should be traversed using data
> recursion
>   /// to avoid a stack overflow with extreme cases.
>   bool shouldUseDataRecursionFor(Stmt *S) const {
> -    return isa<BinaryOperator>(S) || isa<UnaryOperator>(S) ||
> isa<CaseStmt>(S);
> +    return isa<BinaryOperator>(S) || isa<UnaryOperator>(S) ||
> +           isa<CaseStmt>(S) || isa<CXXOperatorCallExpr>(S);
>   }
>
>   /// \brief Recursively visit a statement or expression, by
>
> Added: cfe/trunk/test/Index/index-many-call-ops.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-many-call-ops.cpp?rev=155849&view=auto
>
> ==============================================================================
> --- cfe/trunk/test/Index/index-many-call-ops.cpp (added)
> +++ cfe/trunk/test/Index/index-many-call-ops.cpp Mon Apr 30 17:12:26 2012
> @@ -0,0 +1,47 @@
> +// RUN: c-index-test -index-file %s | FileCheck %s
> +
> +// rdar://11289247
> +// Check that we don't get stack overflow trying to index a huge number of
> +// call operators.
> +
> +struct S {
> +  S &operator()();
> +};
> +
> +// CHECK: [indexDeclaration]: kind: function | name: foo
> +void foo() {
> +  S s;
> +
>  s()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +
> ()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()()
> +    ;
> +}
> +
> +// CHECK: [indexDeclaration]: kind: function | name: bar
> +void bar();
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120430/fc54d231/attachment.html>


More information about the cfe-commits mailing list