[PATCH] D63288: [clang-tidy] Generalize TransformerClangTidyCheck to take a rule generator.
Dmitri Gribenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jun 13 13:38:05 PDT 2019
gribozavr added inline comments.
================
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) {
----------------
ymandel wrote:
> 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?
You're right. I don't think it is necessary to factor out the assertion -- up to you.
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