[PATCH] D63288: [clang-tidy] Generalize TransformerClangTidyCheck to take a rule generator.
Yitzhak Mandelbaum via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 13 11:03:15 PDT 2019
ymandel marked an inline comment as done.
ymandel added a comment.
Thanks for the review!
================
Comment at: clang-tools-extra/clang-tidy/utils/TransformerClangTidyCheck.cpp:33
+ StringRef Name, ClangTidyContext *Context)
+ : ClangTidyCheck(Name, Context), Rule(MakeRule(getLangOpts(), Options)) {
+ assert(llvm::all_of(Rule.Cases, [](const RewriteRule::Case &C) {
----------------
gribozavr wrote:
> Can we dispatch to the other constructor?
I think not, but please correct me if I'm wrong (and clearly I should add a comment explaining this): in order to get meaningful results from `getLangOpts` and `Options`, we need the `ClangTidyCheck()` constructor to have been called. If we were to dispatch, it would look like:
```
: TransformerClangTidyCheck(MakeRule(getLangOpts(), Options), Name, Context) {}
```
which, if I understand correctly, means that `MakeRule` will access that data _before_ the check object is properly initialized.
That said, I can factor out the assertion into a method to avoid the redundancy. WDYT?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63288/new/
https://reviews.llvm.org/D63288
More information about the cfe-commits
mailing list