[cfe-dev] clang-tidy or static analyzer or ...

Stephen Kelly via cfe-dev cfe-dev at lists.llvm.org
Tue Sep 10 15:54:14 PDT 2019


On 10/09/2019 23:46, Artem Dergachev via cfe-dev wrote:
> Yup, the most principled way of doing this with ASTMatchers is to start 
> with the function decl and then recurse inside it:
> 
>      functionDecl(matchesName(...), forEachDescendant(returnStmt(...)))
> 
> You can always do this in an inside out, but it most likely has 
> performance implications (i never really understood how ASTMatcher 
> performance works as i've never had any real performance problems with 
> them):
> 
>      returnStmt(..., hasAncestor(functionDecl(matchesName(...))))
>
These will give unexpected results in the presence of lambdas for 
example. The `forFunction` expression should be used instead.

Thanks,

Stephen.




More information about the cfe-dev mailing list