This revision was automatically updated to reflect the committed changes. Closed by commit rL322002: [clang-tidy] Fix DanglingHandleCheck for the correct conversion operation… (authored by sbenza, committed by ). Herald added a subscriber: llvm-commits.
Repository: rL LLVM https://reviews.llvm.org/D41779 Files: clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp Index: clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp @@ -25,8 +25,12 @@ ast_matchers::internal::BindableMatcher<Stmt> handleFrom(const ast_matchers::internal::Matcher<RecordDecl> &IsAHandle, const ast_matchers::internal::Matcher<Expr> &Arg) { - return cxxConstructExpr(hasDeclaration(cxxMethodDecl(ofClass(IsAHandle))), - hasArgument(0, Arg)); + return expr( + anyOf(cxxConstructExpr(hasDeclaration(cxxMethodDecl(ofClass(IsAHandle))), + hasArgument(0, Arg)), + cxxMemberCallExpr(hasType(cxxRecordDecl(IsAHandle)), + callee(memberExpr(member(cxxConversionDecl()))), + on(Arg)))); } ast_matchers::internal::Matcher<Stmt> handleFromTemporaryValue( Index: clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp +++ clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp @@ -45,19 +45,23 @@ value_type& operator[](Key&& key); }; +class basic_string_view; + class basic_string { public: basic_string(); basic_string(const char*); + + operator basic_string_view() const noexcept; + ~basic_string(); }; typedef basic_string string; class basic_string_view { public: basic_string_view(const char*); - basic_string_view(const basic_string&); }; typedef basic_string_view string_view;
Index: clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp =================================================================== --- clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/bugprone/DanglingHandleCheck.cpp @@ -25,8 +25,12 @@ ast_matchers::internal::BindableMatcher<Stmt> handleFrom(const ast_matchers::internal::Matcher<RecordDecl> &IsAHandle, const ast_matchers::internal::Matcher<Expr> &Arg) { - return cxxConstructExpr(hasDeclaration(cxxMethodDecl(ofClass(IsAHandle))), - hasArgument(0, Arg)); + return expr( + anyOf(cxxConstructExpr(hasDeclaration(cxxMethodDecl(ofClass(IsAHandle))), + hasArgument(0, Arg)), + cxxMemberCallExpr(hasType(cxxRecordDecl(IsAHandle)), + callee(memberExpr(member(cxxConversionDecl()))), + on(Arg)))); } ast_matchers::internal::Matcher<Stmt> handleFromTemporaryValue( Index: clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp =================================================================== --- clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp +++ clang-tools-extra/trunk/test/clang-tidy/bugprone-dangling-handle.cpp @@ -45,19 +45,23 @@ value_type& operator[](Key&& key); }; +class basic_string_view; + class basic_string { public: basic_string(); basic_string(const char*); + + operator basic_string_view() const noexcept; + ~basic_string(); }; typedef basic_string string; class basic_string_view { public: basic_string_view(const char*); - basic_string_view(const basic_string&); }; typedef basic_string_view string_view;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits