[cfe-dev] ignoring*() and hasParent() matchers

Michael Jabbour via cfe-dev cfe-dev at lists.llvm.org
Wed Jul 11 08:06:38 PDT 2018


I am certainly planning to invest some time writing blog posts/scripts
to make clang-tidy checks easier to use. Giving a talk seems a bit
impossible in the near future, as there isn't much interest in clang in
my local community (hope that this changes).

Also, I have written some
<https://github.com/micjabbour/pronto-clang_format> scripts
<https://github.com/micjabbour/pronto-clang_tidy> (that are meant to be
used in continuous integration) to get clang-tidy/clang-format output as
comments in popular web-based git repo managers (e.g. github, gitlab,
bitbucket, ...). This can help enforce some coding conventions when
reviewing code changes. Here is a screenshot on gitlab (I'll be
deploying this into production soon):



Sorry for the long email, Just wanted to share my enthusiasm :D

Thanks again,
Mike

On 07/07/2018 6:04 PM, Manuel Klimek wrote:
> Thanks! You can pay that back by giving a talk about clang tooling
> from a user's point of view at some point, as you seem to have
> mastered the subject :)
>
> On Sat, 7 Jul 2018, 17:23 Michael Jabbour, <micjabbour at gmail.com
> <mailto:micjabbour at gmail.com>> wrote:
>
>     Thanks for the confirmation. I have learned a lot from your great
>     talks/presentations :-)
>
>     Thanks,
>
>     Mike
>
>
>     On 06/07/2018 11:03 AM, Manuel Klimek wrote:
>>     That's what I'd do, too.
>>
>>     On Fri, 6 Jul 2018, 00:50 Michael Jabbour via cfe-dev,
>>     <cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>> wrote:
>>
>>         I ended up writing my matcher like this:
>>
>>         integerLiteral(
>>           expr().bind("literal"),       //inline bind call using a
>>         redundant node matcher
>>           hasAncestor(                  //climb up the AST to the
>>         nearest varDeclancestor
>>            
>>         varDecl(hasInitializer(ignoringParenCasts(equalsBoundNode("literal"))))   
>>         //check that this varDecl satisfies the original condition
>>           )
>>         )
>>
>>         Any feedback is appreciated, as I am completely new to
>>         LibTooling...
>>
>>         P.S.: The actual matcher I am working on is far more
>>         complicated. Inverting it (i.e. using my very first example)
>>         would result in much more difficult problems. Although this
>>         seems like a roundabout hack, it might be effective when
>>         nested inside matchers that have already been tested
>>
>>         Thanks,
>>
>>         Mike
>>
>>
>>         On 05/07/2018 7:31 PM, Michael Jabbour wrote:
>>>
>>>         Hello all,
>>>
>>>         When using has*() it is sometimes desirable to use
>>>         ignoringParenCasts(), for example (from the docs):
>>>
>>>         varDecl(hasInitializer(ignoringParenCasts(integerLiteral())))
>>>
>>>         Is there any way to get the same effect when hasParent(), e.g.:
>>>
>>>         integerLiteral(hasParent(ignoringParenCasts(varDecl())))
>>>
>>>         Obviously this does not work, but what is the best way to
>>>         achieve a similar effect?
>>>
>>>         cheers,
>>>
>>>         Mike
>>>
>>
>>         _______________________________________________
>>         cfe-dev mailing list
>>         cfe-dev at lists.llvm.org <mailto:cfe-dev at lists.llvm.org>
>>         http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180711/88aae8a4/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: screenshot.PNG
Type: image/png
Size: 37965 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180711/88aae8a4/attachment.png>


More information about the cfe-dev mailing list