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
31 public:
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
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
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.
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
static constexpr llvm::StringLiteral Name
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.