blob: 7bc44250128fcd8b81ca4ba2baa5201b06379392 [file] [log] [blame]
Roman Lebedev6cfa38f2018-10-18 20:16:44 +00001//===--- NonPrivateMemberVariablesInClassesCheck.h - clang-tidy -*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Roman Lebedev6cfa38f2018-10-18 20:16:44 +00006//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONPRIVATEMEMBERVARIABLESINCLASSESCHECK_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONPRIVATEMEMBERVARIABLESINCLASSESCHECK_H
11
Alexander Kornienko478fc5c2019-03-25 12:38:26 +000012#include "../ClangTidyCheck.h"
Roman Lebedev6cfa38f2018-10-18 20:16:44 +000013
14namespace clang {
15namespace tidy {
16namespace misc {
17
18/// This checker finds classes that not only contain the data
19/// (non-static member variables), but also have logic (non-static member
20/// functions), and diagnoses all member variables that have any other scope
21/// other than `private`. They should be made `private`, and manipulated
22/// exclusively via the member functions.
23///
24/// Optionally, classes with all member variables being `public` could be
25/// ignored and optionally all `public` member variables could be ignored.
26///
27/// For the user-facing documentation see:
28/// http://clang.llvm.org/extra/clang-tidy/checks/misc-non-private-member-variables-in-classes.html
29class NonPrivateMemberVariablesInClassesCheck : public ClangTidyCheck {
30public:
31 NonPrivateMemberVariablesInClassesCheck(StringRef Name,
32 ClangTidyContext *Context);
33 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
34 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
35
36private:
37 const bool IgnoreClassesWithAllMemberVariablesBeingPublic;
38 const bool IgnorePublicMemberVariables;
39};
40
41} // namespace misc
42} // namespace tidy
43} // namespace clang
44
45#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NONPRIVATEMEMBERVARIABLESINCLASSESCHECK_H