This revision was automatically updated to reflect the committed changes.
Closed by commit rL302261: [clang-tidy] Fix misc-move-const-arg for move-only 
types. (authored by alexfh).

Changed prior to commit:
  https://reviews.llvm.org/D31160?vs=97971&id=97985#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D31160

Files:
  clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
  clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp


Index: clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
@@ -158,3 +158,16 @@
   // a lambda that is, in turn, an argument to a macro.
   CALL([no_move_semantics] { M3(NoMoveSemantics, no_move_semantics); });
 }
+
+class MoveOnly {
+public:
+  MoveOnly(const MoveOnly &other) = delete;
+  MoveOnly &operator=(const MoveOnly &other) = delete;
+  MoveOnly(MoveOnly &&other) = default;
+  MoveOnly &operator=(MoveOnly &&other) = default;
+};
+template <class T>
+void Q(T);
+void moveOnlyNegatives(MoveOnly val) {
+  Q(std::move(val));
+}
Index: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
@@ -73,6 +73,12 @@
       Arg->getType().isTriviallyCopyableType(*Result.Context);
 
   if (IsConstArg || IsTriviallyCopyable) {
+    if (const CXXRecordDecl *R = Arg->getType()->getAsCXXRecordDecl()) {
+      for (const auto *Ctor : R->ctors()) {
+        if (Ctor->isCopyConstructor() && Ctor->isDeleted())
+          return;
+      }
+    }
     bool IsVariable = isa<DeclRefExpr>(Arg);
     const auto *Var =
         IsVariable ? dyn_cast<DeclRefExpr>(Arg)->getDecl() : nullptr;


Index: clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
===================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
@@ -158,3 +158,16 @@
   // a lambda that is, in turn, an argument to a macro.
   CALL([no_move_semantics] { M3(NoMoveSemantics, no_move_semantics); });
 }
+
+class MoveOnly {
+public:
+  MoveOnly(const MoveOnly &other) = delete;
+  MoveOnly &operator=(const MoveOnly &other) = delete;
+  MoveOnly(MoveOnly &&other) = default;
+  MoveOnly &operator=(MoveOnly &&other) = default;
+};
+template <class T>
+void Q(T);
+void moveOnlyNegatives(MoveOnly val) {
+  Q(std::move(val));
+}
Index: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
===================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
@@ -73,6 +73,12 @@
       Arg->getType().isTriviallyCopyableType(*Result.Context);
 
   if (IsConstArg || IsTriviallyCopyable) {
+    if (const CXXRecordDecl *R = Arg->getType()->getAsCXXRecordDecl()) {
+      for (const auto *Ctor : R->ctors()) {
+        if (Ctor->isCopyConstructor() && Ctor->isDeleted())
+          return;
+      }
+    }
     bool IsVariable = isa<DeclRefExpr>(Arg);
     const auto *Var =
         IsVariable ? dyn_cast<DeclRefExpr>(Arg)->getDecl() : nullptr;
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to