Motivated by Tune inspections to a specific C++ standard.
Moves the isLanguageVersionSupported virtual function from MakeSmartPtrCheck to the base ClangTidyCheck class.
This will disable registering matchers or pp callbacks on unsupported language versions for a check.
Having it as a standalone function is cleaner than manually disabling the check in the register function and should hopefully
encourage check developers to actually restrict the check based on language version.
As an added bonus this could enable automatic detection of what language version a check runs on for the purpose of documentation generation
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Language and/or its standard is checked in other places too. Should all similar places be refactored?
They should but I feel they should be in follow up patches, the only reason MakeSmartPtrCheck is in here is because by coincidence it used the same name as what I planned and I got a compile warning about it.
I also don't know exactly where all occurrences are.
clang-tools-extra/clang-tidy/ClangTidyCheck.h | ||
---|---|---|
102 | Please update the doc comment on registerMatchers and registerPPCallbacks that there is now a precondition that isLanguageVersionSupported must return true. |
clang-tools-extra/clang-tidy/ClangTidyCheck.h | ||
---|---|---|
125 | Not a critical thing, but I feel like it would be better to put isLanguageVersionSupported before register functions. That logical order makes more sense to a reader that is not familiar with the class. |
Please update the doc comment on registerMatchers and registerPPCallbacks that there is now a precondition that isLanguageVersionSupported must return true.