blob: b50872c943d3e724ea12e9afa58bb20acc86bff8 [file] [log] [blame]
//===--- NonPrivateMemberVariablesInClassesCheck.h - clang-tidy -*- C++ -*-===//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "../ClangTidyCheck.h"
namespace clang {
namespace tidy {
namespace misc {
/// 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`. They should be made `private`, and manipulated
/// exclusively via the member functions.
/// Optionally, classes with all member variables being `public` could be
/// ignored and optionally all `public` member variables could be ignored.
/// For the user-facing documentation see:
class NonPrivateMemberVariablesInClassesCheck : public ClangTidyCheck {
NonPrivateMemberVariablesInClassesCheck(StringRef Name,
ClangTidyContext *Context);
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
return LangOpts.CPlusPlus;
void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
const bool IgnoreClassesWithAllMemberVariablesBeingPublic;
const bool IgnorePublicMemberVariables;
} // namespace misc
} // namespace tidy
} // namespace clang