[clang-tools-extra] fc5f14c - [clang-tidy] Ignore declarations in bugprone-exception-escape
Piotr Zegar via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 30 11:24:20 PDT 2023
Author: Piotr Zegar
Date: 2023-04-30T18:22:44Z
New Revision: fc5f14c5fe78997fb01f9e921b0225f643171fe2
URL: https://github.com/llvm/llvm-project/commit/fc5f14c5fe78997fb01f9e921b0225f643171fe2
DIFF: https://github.com/llvm/llvm-project/commit/fc5f14c5fe78997fb01f9e921b0225f643171fe2.diff
LOG: [clang-tidy] Ignore declarations in bugprone-exception-escape
Warnings will now only be printed for function definitions, not declarations
Reviewed By: isuckatcs
Differential Revision: https://reviews.llvm.org/D148462
Added:
Modified:
clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
index 276c46ca9fe90..635cc2ca05d12 100644
--- a/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
@@ -52,7 +52,8 @@ void ExceptionEscapeCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
void ExceptionEscapeCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
- functionDecl(anyOf(isNoThrow(), cxxDestructorDecl(),
+ functionDecl(isDefinition(),
+ anyOf(isNoThrow(), cxxDestructorDecl(),
cxxConstructorDecl(isMoveConstructor()),
cxxMethodDecl(isMoveAssignmentOperator()),
hasName("main"), hasName("swap"),
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst
index 49f880c971a34..5695d59e89153 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -201,6 +201,10 @@ Changes in existing checks
<clang-tidy/checks/bugprone/dynamic-static-initializers>` check.
Global options of the same name should be used instead.
+- Improved :doc:`bugprone-exception-escape
+ <clang-tidy/checks/bugprone/exception-escape>` to not emit warnings for
+ forward declarations of functions.
+
- Improved :doc:`bugprone-fold-init-type
<clang-tidy/checks/bugprone/fold-init-type>` to handle iterators that do not
define `value_type` type aliases.
diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
index 142c8b114b7c8..78d434854b095 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
@@ -655,7 +655,6 @@ int directly_recursive(int n) noexcept {
}
int indirectly_recursive(int n) noexcept;
- // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in function 'indirectly_recursive' which should not throw exceptions
int recursion_helper(int n) {
indirectly_recursive(n);
More information about the cfe-commits
mailing list