[PATCH] D41779: [clang-tidy] Fix DanglingHandleCheck for the correct conversion operation between basic_string and basic_string_view.

Samuel Benzaquen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 8 08:00:26 PST 2018


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;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41779.128931.patch
Type: text/x-patch
Size: 1760 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180108/26f2dbf5/attachment.bin>


More information about the cfe-commits mailing list