diff --git a/clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp --- a/clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp @@ -25,7 +25,8 @@ return expr( anyOf(cxxConstructExpr(hasDeclaration(cxxMethodDecl(ofClass(IsAHandle))), hasArgument(0, Arg)), - cxxMemberCallExpr(hasType(cxxRecordDecl(IsAHandle)), + cxxMemberCallExpr(hasType(hasUnqualifiedDesugaredType(recordType( + hasDeclaration(cxxRecordDecl(IsAHandle))))), callee(memberExpr(member(cxxConversionDecl()))), on(Arg)))); } diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -174,6 +174,10 @@ arguments to ``std::print``, ``std::format`` or other functions listed in the ``StringParameterFunction`` check option. +- Improved :doc:`bugprone-dangling-handle + ` check enhancing detection of + handles behind type aliases. + - Deprecated check-local options `HeaderFileExtensions` in :doc:`bugprone-dynamic-static-initializers ` check. diff --git a/clang-tools-extra/test/clang-tidy/checkers/bugprone/dangling-handle.cpp b/clang-tools-extra/test/clang-tidy/checkers/bugprone/dangling-handle.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/bugprone/dangling-handle.cpp +++ b/clang-tools-extra/test/clang-tidy/checkers/bugprone/dangling-handle.cpp @@ -52,7 +52,8 @@ basic_string(); basic_string(const char*); - operator basic_string_view() const noexcept; + typedef basic_string_view str_view; + operator str_view() const noexcept; ~basic_string(); }; @@ -193,3 +194,4 @@ TakesAStringView(std::string()); } +