Skip to content

Commit

Permalink
[clang-tidy] Ignore declarations in bugprone-exception-escape
Browse files Browse the repository at this point in the history
Warnings will now only be printed for function definitions, not declarations

Reviewed By: isuckatcs

Differential Revision: https://reviews.llvm.org/D148462
  • Loading branch information
PiotrZSL committed Apr 30, 2023
1 parent 9fce1fc commit fc5f14c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit fc5f14c

Please sign in to comment.