[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

Yitzhak Mandelbaum via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 21 12:00:17 PDT 2019


ymandel added a comment.

In D61386#1510690 <https://reviews.llvm.org/D61386#1510690>, @MyDeveloperDay wrote:

> Just a passing comment, Is this:
>
> a) a different type of check that would be used for a different type of check than previous clang-tidy checks
>  b) or is this a replacement on the previous style?


This is a replacement for a certain class of checks. Mostly for simple tests that are primarily pattern + reconstruction, without complex logic (at least for now).  The long-term goal is to provide a concise alternative for the large majority of checks.

> Is there any documentation about the benefits of this method vs the old method? or of why we would potentially use one and not the other?

There's a doc describing the framework here
https://docs.google.com/document/d/1ppw0RhjwsrbBcHYhI85pe6ISDbA6r5d00ot3N8cQWeQ/edit?usp=sharing
and some corresponding discussion on the cfe-dev mailing list (and in the doc comments).

> Is there a change needed to add_new_check.py to have it generate this new style? (its ok if the answer is yes in a future revision)
> 
> Do you foresee people using this mechanism going forward?

Not yet, but once it is more mature, yes. I would hope that it will be the more common approach. At that point, we can adjust the scripts accordingly.

> I do like the brevity of it and I do like the GTEST unit tests, (I struggled more with the lit tests than anything else, mainly for python on cygwin reasons)
> 
> It looks good, even if it looks like I need to go learn how tooling::stencil works... a little bit of documentation might not go a miss on how to get started with it...

Thanks.  Yes, it very much requires that you familiarize yourself with Stencil and RewriteRule (Tooling/Refactoring/Stencil.h and Transformer.h).  I'm not sure what more to add that is specific to clang tidy. The intent is that, if your check can be expressed as a `RewriteRule` then there's really nothing you need to know about clang-tidy beyond what's in the header file -- you just drop the rule into TransformerClangTidyCheck.  If you have questions after you see the Tooling documentation, please let me know and I'm happy to expand the comments here.  Both Stencil and Transformer are quite and still under active development. Once they've stabilized a bit, I also plan to send out a more general announcement about this to the cfe-dev list.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D61386/new/

https://reviews.llvm.org/D61386





More information about the cfe-commits mailing list