clang-tools 8.0.0

NonPrivateMemberVariablesInClassesCheck.h
Go to the documentation of this file.
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
clang::tidy::misc::NonPrivateMemberVariablesInClassesCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: NonPrivateMemberVariablesInClassesCheck.cpp:81
clang::tidy::misc::NonPrivateMemberVariablesInClassesCheck
This checker finds classes that not only contain the data (non-static member variables), but also have logic (non-static member functions), and diagnoses all member variables that have any other scope other than private.
Definition: NonPrivateMemberVariablesInClassesCheck.h:30
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
clang::tidy::misc::NonPrivateMemberVariablesInClassesCheck::NonPrivateMemberVariablesInClassesCheck
NonPrivateMemberVariablesInClassesCheck(StringRef Name, ClangTidyContext *Context)
Definition: NonPrivateMemberVariablesInClassesCheck.cpp:44
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:28
Result
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
Definition: ClangdServer.cpp:60
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ChangeNamespace.cpp:18
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:100
clang::tidy::misc::NonPrivateMemberVariablesInClassesCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: NonPrivateMemberVariablesInClassesCheck.cpp:52