[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.
Jonas Toth via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu May 2 05:32:43 PDT 2019
JonasToth added a comment.
I like the new framework!
================
Comment at: clang-tools-extra/clang-tidy/utils/TransformerTidy.cpp:43
+ if (Rule.Explanation) {
+ if (Expected<std::string> Explanation = Rule.Explanation(Result)) {
+ Message = *Explanation;
----------------
these if-else are single statement, so the braces can be ellided.
================
Comment at: clang-tools-extra/unittests/clang-tidy/TransformerTidyTest.cpp:38
+ IfInverterTidy(StringRef Name, ClangTidyContext *Context)
+ : TransformerTidy(invertIf(), Name, Context) {}
+};
----------------
If we allow to pass in a callable, that returns a `RewriteRule`we would have a more flexible framework in clang-tidy.
Going with this for now is ok in my opinion as the only good usecase that comes to my mind would be statistics.
But If some transformation needs to remember what has been done before only a `RewriteRule` as state is not sufficient and stateful actions would require global state (MEH!).
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