https://github.com/cpp-engine updated https://github.com/llvm/llvm-project/pull/226488
>From b513dc568af3516f0f5eb70245073bfcd055b608 Mon Sep 17 00:00:00 2001 From: Agaev G <[email protected]> Date: Fri, 25 Sep 2026 13:04:11 +0000 Subject: [PATCH 1/7] [clang-tidy] Fix performance-noexcept-move-constructor for implicit noexcept(false) --- .../performance/NoexceptFunctionBaseCheck.cpp | 17 ++++++++------- .../performance/noexcept-move-constructor.cpp | 21 +++++++++++++++++++ 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/clang-tools-extra/clang-tidy/performance/NoexceptFunctionBaseCheck.cpp b/clang-tools-extra/clang-tidy/performance/NoexceptFunctionBaseCheck.cpp index 33d80615fb19f..32d85e18dff95 100644 --- a/clang-tools-extra/clang-tidy/performance/NoexceptFunctionBaseCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/NoexceptFunctionBaseCheck.cpp @@ -26,13 +26,16 @@ void NoexceptFunctionBaseCheck::check(const MatchFinder::MatchResult &Result) { // Don't complain about nothrow(false), but complain on nothrow(expr) // where expr evaluates to false. - const auto *ProtoType = FuncDecl->getType()->castAs<FunctionProtoType>(); - const Expr *NoexceptExpr = ProtoType->getNoexceptExpr(); - if (NoexceptExpr) { - NoexceptExpr = NoexceptExpr->IgnoreImplicit(); - if (!isa<CXXBoolLiteralExpr>(NoexceptExpr)) - reportNoexceptEvaluatedToFalse(FuncDecl, NoexceptExpr); - return; + const auto ExceptionSpecSourceRange = FuncDecl->getExceptionSpecSourceRange(); + if (ExceptionSpecSourceRange.isValid()) { + const auto *ProtoType = FuncDecl->getType()->castAs<FunctionProtoType>(); + const Expr *NoexceptExpr = ProtoType->getNoexceptExpr(); + if (NoexceptExpr) { + NoexceptExpr = NoexceptExpr->IgnoreImplicit(); + if (!isa<CXXBoolLiteralExpr>(NoexceptExpr)) + reportNoexceptEvaluatedToFalse(FuncDecl, NoexceptExpr); + return; + } } const auto Diag = reportMissingNoexcept(FuncDecl); diff --git a/clang-tools-extra/test/clang-tidy/checkers/performance/noexcept-move-constructor.cpp b/clang-tools-extra/test/clang-tidy/checkers/performance/noexcept-move-constructor.cpp index 76e1d9e493421..42a1287163d92 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/performance/noexcept-move-constructor.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/performance/noexcept-move-constructor.cpp @@ -2,6 +2,8 @@ // RUN: %check_clang_tidy -std=c++17-or-later -check-suffixes=,ERR %s performance-noexcept-move-constructor %t \ // RUN: -- --fix-errors -- -fexceptions -DENABLE_ERROR +#include <utility> + namespace std { template <typename T> @@ -181,6 +183,25 @@ struct O : virtual IntWrapper, ThrowOnAnything { // CHECK-FIXES: O &operator=(O &&) noexcept = default; }; +struct P { + P() = default; + + P(P &&) = default; + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be marked noexcept [performance-noexcept-move-constructor] + // CHECK-FIXES: P(P &&) noexcept = default; + P &operator=(P &&) = default; + // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: move assignment operators should be marked noexcept [performance-noexcept-move-constructor] + // CHECK-FIXES: P &operator=(P &&) noexcept = default; + + InheritFromThrowOnAnything IFF; +}; + +void p() { + P P1{}; + P P2{std::move(P1)}; + P P3 = std::move(P2); +} + class OK {}; void f() { >From 0a62218f1ea96122dd7e611898ed515d6df0dcfc Mon Sep 17 00:00:00 2001 From: "Agaev G." <[email protected]> Date: Sun, 27 Sep 2026 17:14:55 +0400 Subject: [PATCH 2/7] [clang-tidy] Fix test and add a release note --- clang-tools-extra/docs/ReleaseNotes.md | 4 ++++ .../checkers/performance/noexcept-move-constructor.cpp | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/clang-tools-extra/docs/ReleaseNotes.md b/clang-tools-extra/docs/ReleaseNotes.md index 0441aef375c54..535baf66b2453 100644 --- a/clang-tools-extra/docs/ReleaseNotes.md +++ b/clang-tools-extra/docs/ReleaseNotes.md @@ -322,6 +322,10 @@ infrastructure are described first, followed by tool-specific sections. <clang-tidy/checks/readability/use-std-min-max>` check by fixing spurious trailing semicolons and lost comments when the `if` body has no braces. +- Improved {doc}`noexcept-move-constructors + <clang-tidy/checks/performance/noexcept-move-constructor>` check by fixing + false positives for implicitly declared noexcept(false). + #### Removed checks - Removed the deprecated `zircon-temporary-objects` check. Users should migrate to diff --git a/clang-tools-extra/test/clang-tidy/checkers/performance/noexcept-move-constructor.cpp b/clang-tools-extra/test/clang-tidy/checkers/performance/noexcept-move-constructor.cpp index 42a1287163d92..1b705aada6c2b 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/performance/noexcept-move-constructor.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/performance/noexcept-move-constructor.cpp @@ -199,7 +199,7 @@ struct P { void p() { P P1{}; P P2{std::move(P1)}; - P P3 = std::move(P2); + P1 = std::move(P2); } class OK {}; >From 21020c0d3c2b992b44c71972bb76e64bbcae7f5e Mon Sep 17 00:00:00 2001 From: "Agaev G." <[email protected]> Date: Sun, 27 Sep 2026 19:18:25 +0400 Subject: [PATCH 3/7] [clang-tidy] Fix order of release notes --- clang-tools-extra/docs/ReleaseNotes.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/docs/ReleaseNotes.md b/clang-tools-extra/docs/ReleaseNotes.md index f69b45d5b38de..ed0e5b8f64e8b 100644 --- a/clang-tools-extra/docs/ReleaseNotes.md +++ b/clang-tools-extra/docs/ReleaseNotes.md @@ -249,6 +249,10 @@ infrastructure are described first, followed by tool-specific sections. <clang-tidy/checks/modernize/use-nullptr>` to turn `decltype(nullptr)` into `std::nullptr_t` from `<cstdef>`. +- Improved {doc}`noexcept-move-constructors + <clang-tidy/checks/performance/noexcept-move-constructor>` check by fixing + false positives for implicitly declared `noexcept(false)`. + - Improved {doc}`performance-inefficient-algorithm <clang-tidy/checks/performance/inefficient-algorithm>` check to no longer produce a fix with the container or the searched-for value missing, such as @@ -333,10 +337,6 @@ infrastructure are described first, followed by tool-specific sections. <clang-tidy/checks/readability/use-std-min-max>` check by fixing spurious trailing semicolons and lost comments when the `if` body has no braces. -- Improved {doc}`noexcept-move-constructors - <clang-tidy/checks/performance/noexcept-move-constructor>` check by fixing - false positives for implicitly declared `noexcept(false)`. - #### Removed checks - Removed the deprecated `zircon-temporary-objects` check. Users should migrate to >From 7dce1eaf6b73c7fa43547d03767ea506c57c6ef3 Mon Sep 17 00:00:00 2001 From: "Agaev G." <[email protected]> Date: Mon, 28 Sep 2026 17:40:30 +0400 Subject: [PATCH 4/7] [clang-tidy] Fix performance-noexcept-move-constructor for implicit noexcept(false) --- .../utils/ExceptionSpecAnalyzer.cpp | 27 ++++++++++++------- .../performance/noexcept-move-constructor.cpp | 10 +++++++ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/clang-tools-extra/clang-tidy/utils/ExceptionSpecAnalyzer.cpp b/clang-tools-extra/clang-tidy/utils/ExceptionSpecAnalyzer.cpp index 2da09669dd7f8..b02a79f37a66a 100644 --- a/clang-tools-extra/clang-tidy/utils/ExceptionSpecAnalyzer.cpp +++ b/clang-tools-extra/clang-tidy/utils/ExceptionSpecAnalyzer.cpp @@ -86,26 +86,33 @@ ExceptionSpecAnalyzer::analyzeRecord(const CXXRecordDecl *RecordDecl, if (getDefaultableMemberKind(MethodDecl) == Kind) return analyze(MethodDecl); + State Result = State::NotThrowing; for (const auto &BaseSpec : RecordDecl->bases()) { - const State Result = analyzeBase(BaseSpec, Kind); - if (Result == State::Throwing || Result == State::Unknown) - return Result; + const State CurrentState = analyzeBase(BaseSpec, Kind); + if (CurrentState == State::Throwing) + return CurrentState; + if (CurrentState == State::Unknown) + Result = CurrentState; } for (const auto &BaseSpec : RecordDecl->vbases()) { - const State Result = analyzeBase(BaseSpec, Kind); - if (Result == State::Throwing || Result == State::Unknown) - return Result; + const State CurrentState = analyzeBase(BaseSpec, Kind); + if (CurrentState == State::Throwing) + return CurrentState; + if (CurrentState == State::Unknown) + Result = CurrentState; } for (const auto *FDecl : RecordDecl->fields()) if (!FDecl->isInvalidDecl() && !FDecl->isUnnamedBitField()) { - const State Result = analyzeFieldDecl(FDecl, Kind); - if (Result == State::Throwing || Result == State::Unknown) - return Result; + const State CurrentState = analyzeFieldDecl(FDecl, Kind); + if (CurrentState == State::Throwing) + return CurrentState; + if (CurrentState == State::Unknown) + Result = CurrentState; } - return State::NotThrowing; + return Result; } ExceptionSpecAnalyzer::State diff --git a/clang-tools-extra/test/clang-tidy/checkers/performance/noexcept-move-constructor.cpp b/clang-tools-extra/test/clang-tidy/checkers/performance/noexcept-move-constructor.cpp index 1b705aada6c2b..4e91c0a517cc6 100644 --- a/clang-tools-extra/test/clang-tidy/checkers/performance/noexcept-move-constructor.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/performance/noexcept-move-constructor.cpp @@ -2,6 +2,7 @@ // RUN: %check_clang_tidy -std=c++17-or-later -check-suffixes=,ERR %s performance-noexcept-move-constructor %t \ // RUN: -- --fix-errors -- -fexceptions -DENABLE_ERROR +#include <string> #include <utility> namespace std @@ -202,6 +203,15 @@ void p() { P1 = std::move(P2); } +struct Q { + Q &operator=(Q &&) = default; + // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: move assignment operators should be marked noexcept [performance-noexcept-move-constructor] + // CHECK-FIXES: Q &operator=(Q &&) noexcept = default; + + std::string additional_field; + ThrowOnAnything field; +}; + class OK {}; void f() { >From 36f58a26ee025f7203e6fb1572c27de897da2277 Mon Sep 17 00:00:00 2001 From: cpp-engine <[email protected]> Date: Mon, 28 Sep 2026 20:22:33 +0400 Subject: [PATCH 5/7] [clang-tidy] Fix release note Co-authored-by: EugeneZelenko <[email protected]> --- clang-tools-extra/docs/ReleaseNotes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/docs/ReleaseNotes.md b/clang-tools-extra/docs/ReleaseNotes.md index ed0e5b8f64e8b..74966a10d7e3c 100644 --- a/clang-tools-extra/docs/ReleaseNotes.md +++ b/clang-tools-extra/docs/ReleaseNotes.md @@ -249,7 +249,7 @@ infrastructure are described first, followed by tool-specific sections. <clang-tidy/checks/modernize/use-nullptr>` to turn `decltype(nullptr)` into `std::nullptr_t` from `<cstdef>`. -- Improved {doc}`noexcept-move-constructors +- Improved {doc}`performance-noexcept-move-constructor <clang-tidy/checks/performance/noexcept-move-constructor>` check by fixing false positives for implicitly declared `noexcept(false)`. >From e8c78b1f6ec813424e2efe58d72bc08e99304323 Mon Sep 17 00:00:00 2001 From: "Agaev G." <[email protected]> Date: Mon, 28 Sep 2026 20:36:19 +0400 Subject: [PATCH 6/7] [clang-tidy] Fix order of release notes --- clang-tools-extra/docs/ReleaseNotes.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/clang-tools-extra/docs/ReleaseNotes.md b/clang-tools-extra/docs/ReleaseNotes.md index 74966a10d7e3c..0deab68d01aaa 100644 --- a/clang-tools-extra/docs/ReleaseNotes.md +++ b/clang-tools-extra/docs/ReleaseNotes.md @@ -249,10 +249,6 @@ infrastructure are described first, followed by tool-specific sections. <clang-tidy/checks/modernize/use-nullptr>` to turn `decltype(nullptr)` into `std::nullptr_t` from `<cstdef>`. -- Improved {doc}`performance-noexcept-move-constructor - <clang-tidy/checks/performance/noexcept-move-constructor>` check by fixing - false positives for implicitly declared `noexcept(false)`. - - Improved {doc}`performance-inefficient-algorithm <clang-tidy/checks/performance/inefficient-algorithm>` check to no longer produce a fix with the container or the searched-for value missing, such as @@ -261,6 +257,10 @@ infrastructure are described first, followed by tool-specific sections. offered when an argument covers only part of a macro expansion, as it then has no source text of its own. +- Improved {doc}`performance-noexcept-move-constructor + <clang-tidy/checks/performance/noexcept-move-constructor>` check by fixing + false positives for implicitly declared `noexcept(false)`. + - Improved {doc}`readability-convert-member-functions-to-static <clang-tidy/checks/readability/convert-member-functions-to-static>` check by fixing a crash when checking a const-qualified method declared with the >From 07e9df671246f4f692ab7f041f4be138a02b09d4 Mon Sep 17 00:00:00 2001 From: "Agaev G." <[email protected]> Date: Thu, 1 Oct 2026 16:53:24 +0400 Subject: [PATCH 7/7] [clang-tidy] Fix release note --- clang-tools-extra/docs/ReleaseNotes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang-tools-extra/docs/ReleaseNotes.md b/clang-tools-extra/docs/ReleaseNotes.md index 0deab68d01aaa..3e150c070f994 100644 --- a/clang-tools-extra/docs/ReleaseNotes.md +++ b/clang-tools-extra/docs/ReleaseNotes.md @@ -259,7 +259,7 @@ infrastructure are described first, followed by tool-specific sections. - Improved {doc}`performance-noexcept-move-constructor <clang-tidy/checks/performance/noexcept-move-constructor>` check by fixing - false positives for implicitly declared `noexcept(false)`. + false negatives for implicitly `noexcept(false)` move operations. - Improved {doc}`readability-convert-member-functions-to-static <clang-tidy/checks/readability/convert-member-functions-to-static>` check by _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
