clang-tools  11.0.0git
NonPrivateMemberVariablesInClassesCheck.h
Go to the documentation of this file.
1 //===--- NonPrivateMemberVariablesInClassesCheck.h - clang-tidy -*- C++ -*-===//
2 //
3 // 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
6 //
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 
12 #include "../ClangTidyCheck.h"
13 
14 namespace clang {
15 namespace tidy {
16 namespace 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
30 public:
32  ClangTidyContext *Context);
33  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
34  return LangOpts.CPlusPlus;
35  }
36  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
37  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
38  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
39 
40 private:
41  const bool IgnoreClassesWithAllMemberVariablesBeingPublic;
42  const bool IgnorePublicMemberVariables;
43 };
44 
45 } // namespace misc
46 } // namespace tidy
47 } // namespace clang
48 
49 #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.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
Override this to disable registering matchers and PP callbacks if an invalid language version is bein...
static constexpr llvm::StringLiteral Name
===– 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.
std::map< std::string, ClangTidyValue > OptionMap