[clang-tools-extra] Fix #75686: add iter_swap and iter_move to the matched name (PR #76117)

Piotr Zegar via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 4 13:53:15 PST 2024


================
@@ -58,14 +58,15 @@ void ExceptionEscapeCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
 
 void ExceptionEscapeCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
-      functionDecl(isDefinition(),
-                   anyOf(isNoThrow(),
-                         allOf(anyOf(cxxDestructorDecl(),
-                                     cxxConstructorDecl(isMoveConstructor()),
-                                     cxxMethodDecl(isMoveAssignmentOperator()),
-                                     isMain(), hasName("swap")),
-                               unless(isExplicitThrow())),
-                         isEnabled(FunctionsThatShouldNotThrow)))
+      functionDecl(
+          isDefinition(),
+          anyOf(isNoThrow(),
+                allOf(anyOf(cxxDestructorDecl(),
+                            cxxConstructorDecl(isMoveConstructor()),
+                            cxxMethodDecl(isMoveAssignmentOperator()), isMain(),
+                            hasAnyName("swap", "iter_swap", "iter_move")),
----------------
PiotrZSL wrote:

NOTE: Here is old legacy bug. For example user can have method swap(), and it will still be counted in even if not needed. Would be good to check if those methods/functions got at least 1 parameter.
Also you can consider updating performance-noexcept-swap by adding there iter_swap.

https://github.com/llvm/llvm-project/pull/76117


More information about the cfe-commits mailing list