diff options
Diffstat (limited to 'clang-tools-extra/docs')
-rw-r--r-- | clang-tools-extra/docs/ReleaseNotes.rst | 16 | ||||
-rw-r--r-- | clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst | 37 |
2 files changed, 44 insertions, 9 deletions
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index b4c79199b81..bbf893c5cb6 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -276,6 +276,22 @@ The 3.8 release didn't include release notes for :program:`clang-tidy`. In the * `readability-uniqueptr-delete-release <http://llvm.org/releases/3.8.0/tools/clang/tools/extra/docs/clang-tidy/checks/readability-uniqueptr-delete-release.html>`_ +- Updated ``cppcoreguidelines-pro-member-type-member-init`` check + + This check now conforms to C++ Core Guidelines rule Type.6: Always Initialize + a Member Variable. The check examines every record type where construction + might result in an undefined memory state. These record types needing + initialization have at least one default-initialized built-in, pointer, + array or record type matching these criteria or a default-initialized + direct base class of this kind. + + The check has two complementary aspects: + 1. Ensure every constructor for a record type needing initialization + value-initializes all members and direct bases via a combination of + in-class initializers and the member initializer list. + 2. Value-initialize every non-member instance of a record type needing + initialization that lacks a user-provided default constructor, e.g. + a POD. Improvements to modularize -------------------------- diff --git a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst index 6df400623be..1fc8da8d527 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst @@ -3,16 +3,35 @@ cppcoreguidelines-pro-type-member-init ====================================== -The check flags user-defined constructor definitions that do not initialize all -builtin and pointer fields which leaves their memory in an undefined state. +The check flags user-defined constructor definitions that do not +initialize all fields that would be left in an undefined state by +default construction, e.g. builtins, pointers and record types without +user-provided default constructors containing at least one such +type. If these fields aren't initialized, the constructor will leave +some of the memory in an undefined state. -For C++11 it suggests fixes to add in-class field initializers. For older -versions it inserts the field initializers into the constructor initializer -list. +For C++11 it suggests fixes to add in-class field initializers. For +older versions it inserts the field initializers into the constructor +initializer list. It will also initialize any direct base classes that +need to be zeroed in the constructor initializer list. -The check takes assignment of fields in the constructor body into account but -generates false positives for fields initialized in methods invoked in the -constructor body. +The check takes assignment of fields in the constructor body into +account but generates false positives for fields initialized in +methods invoked in the constructor body. -This rule is part of the "Type safety" profile of the C++ Core Guidelines, see +The check also flags variables of record types without a user-provided +constructor that are not initialized. The suggested fix is to zero +initialize the variable via {} for C++11 and beyond or = {} for older +versions. + +IgnoreArrays option +------------------- + +For performance critical code, it may be important to not zero +fixed-size array members. If on, IgnoreArrays will not warn about +array members that are not zero-initialized during construction. +IgnoreArrays is false by default. + +This rule is part of the "Type safety" profile of the C++ Core +Guidelines, corresponding to rule Type.6. See https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-memberinit. |