Summary: Fix misc-move-const-arg false positives on move-only types.
Reviewers: sbenza
Reviewed By: sbenza
Subscribers: xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D31160
llvm-svn: 302261
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;
// 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));
+}