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) {
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) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits