Quantcast

Trying to write new clang-tidy check, have a problem with RecursiveASTVisitor.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Trying to write new clang-tidy check, have a problem with RecursiveASTVisitor.

Martin J. O'Riordan via cfe-dev
Hi all!

I'm attempting to write a new clang-tidy check, misc-assertion-count.
The current version of the code is available in :
https://github.com/LebedevRI/clang-tools-extra/tree/misc-assertion-count--for-cfe-dev.
What's missing is docs, and handling for a few more special cases, at least
C++ lambdas.

As the subj suggests, i'm having a trouble with RecursiveASTVisitor. During
function AST traversal, i would like to completely avoid c++11's lambdas.

As it was suggested on #llvm, i implemented TraverseLambdaExpr() and
TraverseLambdaBody(), but as you can see from those assert()'s, they are never
called. So the lambdas are still visited... The lit test for the check would
start failing if they are no longer visited.

So here comes the question: am i missing something really obvious?
Am i overriding those functions incorrectly? Or are they not supposed to be
overridden? How to do it?

Roman.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Trying to write new clang-tidy check, have a problem with RecursiveASTVisitor.

Martin J. O'Riordan via cfe-dev
On Thu, May 4, 2017 at 3:00 PM, Roman Lebedev <[hidden email]> wrote:

> Hi all!
>
> I'm attempting to write a new clang-tidy check, misc-assertion-count.
> The current version of the code is available in :
> https://github.com/LebedevRI/clang-tools-extra/tree/misc-assertion-count--for-cfe-dev.
> What's missing is docs, and handling for a few more special cases, at least
> C++ lambdas.
>
> As the subj suggests, i'm having a trouble with RecursiveASTVisitor. During
> function AST traversal, i would like to completely avoid c++11's lambdas.
>
> As it was suggested on #llvm, i implemented TraverseLambdaExpr() and
> TraverseLambdaBody(), but as you can see from those assert()'s, they are never
> called. So the lambdas are still visited... The lit test for the check would
> start failing if they are no longer visited.
>
> So here comes the question: am i missing something really obvious?
> Am i overriding those functions incorrectly? Or are they not supposed to be
> overridden? How to do it?
Solved.

As expected, there is no problem with the TraverseLambdaExpr().
It was not called because in dataTraverseStmtPre(), i have already avoided
traversing declarations, so naturally, LambdaExpr() would never be called...

One less TODO, one step closer to something worth a review :)

Thank you all.

Roman.
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Loading...