[PATCH] D147929: [clang-tidy] Fix handling of UseAssignment option in cppcoreguidelines-prefer-member-initializer
Piotr Zegar via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 16 03:35:05 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb34ca0851a52: [clang-tidy] Fix handling of UseAssignment option in cppcoreguidelines-prefer… (authored by PiotrZSL).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D147929/new/
https://reviews.llvm.org/D147929
Files:
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/prefer-member-initializer.rst
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer-modernize-use-default-member-init-assignment.cpp
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer-modernize-use-default-member-init.cpp
Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer-modernize-use-default-member-init.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer-modernize-use-default-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer-modernize-use-default-member-init.cpp
@@ -1,4 +1,7 @@
// RUN: %check_clang_tidy %s cppcoreguidelines-prefer-member-initializer,modernize-use-default-member-init %t
+// RUN: %check_clang_tidy %s cppcoreguidelines-prefer-member-initializer,modernize-use-default-member-init %t -- \
+// RUN: -config="{CheckOptions: [{key: modernize-use-default-member-init.UseAssignment, value: true}, \
+// RUN: {key: cppcoreguidelines-prefer-member-initializer.UseAssignment, value: false}]}"
class Simple1 {
int n;
Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer-modernize-use-default-member-init-assignment.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer-modernize-use-default-member-init-assignment.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-member-initializer-modernize-use-default-member-init-assignment.cpp
@@ -1,5 +1,8 @@
// RUN: %check_clang_tidy %s cppcoreguidelines-prefer-member-initializer,modernize-use-default-member-init %t -- \
// RUN: -config="{CheckOptions: [{key: modernize-use-default-member-init.UseAssignment, value: true}]}"
+// RUN: %check_clang_tidy %s cppcoreguidelines-prefer-member-initializer,modernize-use-default-member-init %t -- \
+// RUN: -config="{CheckOptions: [{key: modernize-use-default-member-init.UseAssignment, value: false}, \
+// RUN: {key: cppcoreguidelines-prefer-member-initializer.UseAssignment, value: true}]}"
class Simple1 {
int n;
Index: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/prefer-member-initializer.rst
===================================================================
--- clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/prefer-member-initializer.rst
+++ clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/prefer-member-initializer.rst
@@ -85,9 +85,11 @@
.. option:: UseAssignment
- If this option is set to `true` (default is `false`), the check will initialize
- members with an assignment. In this case the fix of the first example looks
- like this:
+ If this option is set to `true` (by default `UseAssignment` from
+ `modernize-use-default-member-init
+ <../modernize/use-default-member-init.html>`_ will be used),
+ the check will initialize members with an assignment.
+ In this case the fix of the first example looks like this:
.. code-block:: c++
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
@@ -129,9 +129,11 @@
: ClangTidyCheck(Name, Context),
IsUseDefaultMemberInitEnabled(
Context->isCheckEnabled("modernize-use-default-member-init")),
- UseAssignment(OptionsView("modernize-use-default-member-init",
- Context->getOptions().CheckOptions, Context)
- .get("UseAssignment", false)) {}
+ UseAssignment(
+ Options.get("UseAssignment",
+ OptionsView("modernize-use-default-member-init",
+ Context->getOptions().CheckOptions, Context)
+ .get("UseAssignment", false))) {}
void PreferMemberInitializerCheck::storeOptions(
ClangTidyOptions::OptionMap &Opts) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147929.513984.patch
Type: text/x-patch
Size: 4012 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230416/3934007c/attachment.bin>
More information about the cfe-commits
mailing list