[PATCH] D75441: [clang-tidy] Add helper base check classes that only run on specific language versions
Nathan James via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 2 02:07:17 PST 2020
njames93 created this revision.
njames93 added reviewers: aaron.ballman, gribozavr2, alexfh, lebedev.ri, Eugene.Zelenko.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75441
Files:
clang-tools-extra/clang-tidy/ClangTidyCheck.h
Index: clang-tools-extra/clang-tidy/ClangTidyCheck.h
===================================================================
--- clang-tools-extra/clang-tidy/ClangTidyCheck.h
+++ clang-tools-extra/clang-tidy/ClangTidyCheck.h
@@ -204,6 +204,39 @@
const LangOptions &getLangOpts() const { return Context->getLangOpts(); }
};
+/// Helper class for clang-tidy checks that only register when in `Cc mode.
+class CClangTidyCheck : public ClangTidyCheck {
+ using ClangTidyCheck::ClangTidyCheck;
+ bool isLanguageVersionSupported(const LangOptions &LangOpts) const final {
+ return LangOpts.C99;
+ }
+};
+
+/// Helper class for clang-tidy checks that only register when in `c++` mode.
+class CppClangTidyCheck : public ClangTidyCheck {
+ using ClangTidyCheck::ClangTidyCheck;
+ bool isLanguageVersionSupported(const LangOptions &LangOpts) const final {
+ return LangOpts.CPlusPlus;
+ }
+};
+
+/// Helper class for clang-tidy checks that only register when in `c++11` mode.
+class Cpp11ClangTidyCheck : public ClangTidyCheck {
+ using ClangTidyCheck::ClangTidyCheck;
+ bool isLanguageVersionSupported(const LangOptions &LangOpts) const final {
+ return LangOpts.CPlusPlus11;
+ }
+};
+
+/// Helper class for clang-tidy checks that only register when in `Objective-c`
+/// mode.
+class ObjCClangTidyCheck : public ClangTidyCheck {
+ using ClangTidyCheck::ClangTidyCheck;
+ bool isLanguageVersionSupported(const LangOptions &LangOpts) const final {
+ return LangOpts.ObjC;
+ }
+};
+
} // namespace tidy
} // namespace clang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75441.247574.patch
Type: text/x-patch
Size: 1543 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200302/447fa5f2/attachment.bin>
More information about the cfe-commits
mailing list