blob: c39e356c96d4b090a1a64a6f779ce7b9a7003cc1 [file] [log] [blame]
Roman Lebedev6cfa38f2018-10-18 20:16:44 +00001//===--- 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
15namespace clang {
16namespace tidy {
17namespace 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
30class NonPrivateMemberVariablesInClassesCheck : public ClangTidyCheck {
31public:
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
37private:
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