Roman Lebedev | 6cfa38f | 2018-10-18 20:16:44 +0000 | [diff] [blame^] | 1 | //===--- NonPrivateMemberVariablesInClassesCheck.h - clang-tidy -*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONPRIVATEMEMBERVARIABLESINCLASSESCHECK_H |
| 11 | #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONPRIVATEMEMBERVARIABLESINCLASSESCHECK_H |
| 12 | |
| 13 | #include "../ClangTidy.h" |
| 14 | |
| 15 | namespace clang { |
| 16 | namespace tidy { |
| 17 | namespace misc { |
| 18 | |
| 19 | /// This checker finds classes that not only contain the data |
| 20 | /// (non-static member variables), but also have logic (non-static member |
| 21 | /// functions), and diagnoses all member variables that have any other scope |
| 22 | /// other than `private`. They should be made `private`, and manipulated |
| 23 | /// exclusively via the member functions. |
| 24 | /// |
| 25 | /// Optionally, classes with all member variables being `public` could be |
| 26 | /// ignored and optionally all `public` member variables could be ignored. |
| 27 | /// |
| 28 | /// For the user-facing documentation see: |
| 29 | /// http://clang.llvm.org/extra/clang-tidy/checks/misc-non-private-member-variables-in-classes.html |
| 30 | class NonPrivateMemberVariablesInClassesCheck : public ClangTidyCheck { |
| 31 | public: |
| 32 | NonPrivateMemberVariablesInClassesCheck(StringRef Name, |
| 33 | ClangTidyContext *Context); |
| 34 | void registerMatchers(ast_matchers::MatchFinder *Finder) override; |
| 35 | void check(const ast_matchers::MatchFinder::MatchResult &Result) override; |
| 36 | |
| 37 | private: |
| 38 | const bool IgnoreClassesWithAllMemberVariablesBeingPublic; |
| 39 | const bool IgnorePublicMemberVariables; |
| 40 | }; |
| 41 | |
| 42 | } // namespace misc |
| 43 | } // namespace tidy |
| 44 | } // namespace clang |
| 45 | |
| 46 | #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONPRIVATEMEMBERVARIABLESINCLASSESCHECK_H |