Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #75686: add iter_swap and iter_move to the matched name #76117

Merged

Conversation

Da-Viper
Copy link
Contributor

Fixes #75686

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 21, 2023

@llvm/pr-subscribers-clang-tidy

Author: None (Da-Viper)

Changes

Fixes #75686


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

1 Files Affected:

  • (modified) clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp (+9-8)
diff --git a/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
index 90bf523ffb00b6..18cd7150185a20 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
@@ -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")),
+                      unless(isExplicitThrow())),
+                isEnabled(FunctionsThatShouldNotThrow)))
           .bind("thrower"),
       this);
 }

@EugeneZelenko
Copy link
Contributor

Should Release Notes be updated?

Copy link
Member

@PiotrZSL PiotrZSL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing tests, documentation, release notes.

Copy link
Member

@PiotrZSL PiotrZSL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Looks fine even in current stage.

@PiotrZSL PiotrZSL merged commit 356c2c2 into llvm:main Jan 14, 2024
5 checks passed
@Da-Viper Da-Viper deleted the #75686_bugprone-exception-escape_new_functions branch January 14, 2024 20:03
justinfargnoli pushed a commit to justinfargnoli/llvm-project that referenced this pull request Jan 28, 2024
…#76117)

Added support for iter_swap, iter_move in bugprone-exception-escape 
and performance-noexcept-swap checks.

Fixes  llvm#75686
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bugprone-exception-escape.FunctionsThatShouldNotThrow should consider iter_move and iter_swap
4 participants