llvm-project/clang-tools-extra/clang-tidy/misc
Roman Lebedev 6cfa38f1f1 [clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP)
Summary:
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.

Options
-------

* IgnoreClassesWithAllMemberVariablesBeingPublic

  Allows to completely ignore classes if **all** the member variables in that
  class have `public` visibility.

* IgnorePublicMemberVariables

  Allows to ignore (not diagnose) **all** the member variables with `public`
  visibility scope.

References:
* MISRA 11-0-1 Member data in non-POD class types shall be private.
* https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c2-use-class-if-the-class-has-an-invariant-use-struct-if-the-data-members-can-vary-independently
* https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rc-private
* https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rh-protected

Reviewers: JonasToth, aaron.ballman, alexfh, hokein, xazax.hun

Reviewed By: aaron.ballman

Subscribers: Eugene.Zelenko, zinovy.nis, cfe-commits, rnkovacs, nemanjai, mgorny, xazax.hun, kbarton

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D52771

llvm-svn: 344757
2018-10-18 20:16:44 +00:00
..
CMakeLists.txt [clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP) 2018-10-18 20:16:44 +00:00
DefinitionsInHeadersCheck.cpp Port getLocStart -> getBeginLoc 2018-08-09 22:42:26 +00:00
DefinitionsInHeadersCheck.h [clang-tdiy] Add header file extension configuration support. 2016-02-05 11:23:59 +00:00
MiscTidyModule.cpp [clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP) 2018-10-18 20:16:44 +00:00
MisplacedConstCheck.cpp Add the misc-misplaced-const check to clang-tidy, which diagnoses when a const-qualifier is applied to a typedef of pointer type rather than to the pointee type. 2016-06-07 17:22:47 +00:00
MisplacedConstCheck.h Add the misc-misplaced-const check to clang-tidy, which diagnoses when a const-qualifier is applied to a typedef of pointer type rather than to the pointee type. 2016-06-07 17:22:47 +00:00
NewDeleteOverloadsCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
NewDeleteOverloadsCheck.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
NonCopyableObjects.cpp [clang-tidy] Simplify matchers 2016-11-08 05:58:07 +00:00
NonCopyableObjects.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
NonPrivateMemberVariablesInClassesCheck.cpp [clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP) 2018-10-18 20:16:44 +00:00
NonPrivateMemberVariablesInClassesCheck.h [clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP) 2018-10-18 20:16:44 +00:00
RedundantExpressionCheck.cpp Port getLocEnd -> getEndLoc 2018-08-09 22:43:02 +00:00
RedundantExpressionCheck.h [clang-tidy] Misc redundant expressions checker updated for macros 2017-11-07 13:17:58 +00:00
StaticAssertCheck.cpp Port getLocEnd -> getEndLoc 2018-08-09 22:43:02 +00:00
StaticAssertCheck.h [clang-tidy] remove trailing whitespaces and retab 2016-08-01 12:06:18 +00:00
ThrowByValueCatchByReferenceCheck.cpp Port getLocStart -> getBeginLoc 2018-08-09 22:42:26 +00:00
ThrowByValueCatchByReferenceCheck.h [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
UnconventionalAssignOperatorCheck.cpp Port getLocStart -> getBeginLoc 2018-08-09 22:42:26 +00:00
UnconventionalAssignOperatorCheck.h Trying to fix docs. 2016-05-09 10:56:57 +00:00
UniqueptrResetReleaseCheck.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
UniqueptrResetReleaseCheck.h [clang-tidy] Update docs for clang-tidy checks. NFC 2015-08-27 18:01:58 +00:00
UnusedAliasDeclsCheck.cpp Port getLocEnd -> getEndLoc 2018-08-09 22:43:02 +00:00
UnusedAliasDeclsCheck.h [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
UnusedParametersCheck.cpp Port getLocEnd -> getEndLoc 2018-08-09 22:43:02 +00:00
UnusedParametersCheck.h [clang-tidy] misc-unused-parameters - retain old behavior under StrictMode 2018-06-28 15:21:25 +00:00
UnusedUsingDeclsCheck.cpp Port getLocEnd -> getEndLoc 2018-08-09 22:43:02 +00:00
UnusedUsingDeclsCheck.h [clang-tidy] Ignore function context in misc-unused-using-decls. 2016-06-03 08:05:11 +00:00