[clang-tools-extra] 92420f4 - [clang-tidy] Fix false positive in `readability-named-parameter` for defaulted out-of-line special member functions
Piotr Zegar via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 13 11:14:11 PDT 2023
Author: AMS21
Date: 2023-06-13T18:13:52Z
New Revision: 92420f4aefbef49c3eccaf678bc23713a59e5eab
URL: https://github.com/llvm/llvm-project/commit/92420f4aefbef49c3eccaf678bc23713a59e5eab
DIFF: https://github.com/llvm/llvm-project/commit/92420f4aefbef49c3eccaf678bc23713a59e5eab.diff
LOG: [clang-tidy] Fix false positive in `readability-named-parameter` for defaulted out-of-line special member functions
This fixes llvm#63056
Reviewed By: PiotrZSL
Differential Revision: https://reviews.llvm.org/D152825
Added:
Modified:
clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/checkers/readability/named-parameter.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp b/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
index f621cfe706859..ea6597dbdd617 100644
--- a/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp
@@ -28,7 +28,7 @@ void NamedParameterCheck::check(const MatchFinder::MatchResult &Result) {
// overriden method.
const FunctionDecl *Definition = nullptr;
if ((!Function->isDefined(Definition) || Function->isDefaulted() ||
- Function->isDeleted()) &&
+ Definition->isDefaulted() || Function->isDeleted()) &&
(!isa<CXXMethodDecl>(Function) ||
cast<CXXMethodDecl>(Function)->size_overridden_methods() == 0))
return;
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 7cb9664eb6399..cb9b961e92448 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -396,6 +396,10 @@ Changes in existing checks
<clang-tidy/checks/readability/misleading-indentation>` check when warning would
be unnecessarily emitted for template dependent ``if constexpr``.
+- Fixed a false positive in :doc:`readability-named-parameter
+ <clang-tidy/checks/readability/named-parameter>` for defaulted out-of-line
+ special member functions.
+
- Fixed incorrect fixes in :doc:`readability-redundant-declaration
<clang-tidy/checks/readability/redundant-declaration>` check when linkage
(like ``extern "C"``) is explicitly specified.
diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/named-parameter.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/named-parameter.cpp
index af2c1954bc5fe..8c6fb123ac023 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/readability/named-parameter.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/readability/named-parameter.cpp
@@ -131,3 +131,20 @@ void f(std::nullptr_t) {}
typedef void (F)(int);
F f;
void f(int x) {}
+
+namespace issue_63056
+{
+ struct S {
+ S(const S&);
+ S(S&&);
+
+ S& operator=(const S&);
+ S& operator=(S&&);
+ };
+
+ S::S(const S&) = default;
+ S::S(S&&) = default;
+
+ S& S::operator=(const S&) = default;
+ S& S::operator=(S&&) = default;
+} // namespace issue_63056
More information about the cfe-commits
mailing list