[cfe-dev] Trying to write new clang-tidy check, have a problem with RecursiveASTVisitor.

Roman Lebedev via cfe-dev cfe-dev at lists.llvm.org
Tue May 9 05:01:58 PDT 2017


On Thu, May 4, 2017 at 3:00 PM, Roman Lebedev <lebedev.ri at gmail.com> 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.



More information about the cfe-dev mailing list