From: AMS21 Date: Tue, 13 Jun 2023 17:58:16 +0000 (+0000) Subject: [clang-tidy] Fix false positive in `readability-named-parameter` for defaulted out... X-Git-Tag: upstream/17.0.6~5239 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=92420f4aefbef49c3eccaf678bc23713a59e5eab;p=platform%2Fupstream%2Fllvm.git [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 --- diff --git a/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp b/clang-tools-extra/clang-tidy/readability/NamedParameterCheck.cpp index f621cfe..ea6597d 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(Function) || cast(Function)->size_overridden_methods() == 0)) return; diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index 7cb9664..cb9b961 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -396,6 +396,10 @@ Changes in existing checks ` check when warning would be unnecessarily emitted for template dependent ``if constexpr``. +- Fixed a false positive in :doc:`readability-named-parameter + ` for defaulted out-of-line + special member functions. + - Fixed incorrect fixes in :doc:`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 af2c195..8c6fb12 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