[clang-tidy] misc-move-const-arg shouldn't complain on std::move(lambda)
authorAlexander Kornienko <alexfh@google.com>
Mon, 22 May 2017 14:30:14 +0000 (14:30 +0000)
committerAlexander Kornienko <alexfh@google.com>
Mon, 22 May 2017 14:30:14 +0000 (14:30 +0000)
llvm-svn: 303554

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

index c8ef942..cc2d353 100644 (file)
@@ -74,6 +74,12 @@ void MoveConstantArgumentCheck::check(const MatchFinder::MatchResult &Result) {
 
   if (IsConstArg || IsTriviallyCopyable) {
     if (const CXXRecordDecl *R = Arg->getType()->getAsCXXRecordDecl()) {
+      // According to [expr.prim.lambda]p3, "whether the closure type is
+      // trivially copyable" property can be changed by the implementation of
+      // the language, so we shouldn't rely on it when issuing diagnostics.
+      if (R->isLambda())
+        return;
+      // Don't warn when the type is not copyable.
       for (const auto *Ctor : R->ctors()) {
         if (Ctor->isCopyConstructor() && Ctor->isDeleted())
           return;
index 096f2f9..29b2b92 100644 (file)
@@ -157,6 +157,9 @@ void moveToConstReferenceNegatives() {
   // No warning inside of macro expansion, even if the macro expansion is inside
   // a lambda that is, in turn, an argument to a macro.
   CALL([no_move_semantics] { M3(NoMoveSemantics, no_move_semantics); });
+
+  auto lambda = [] {};
+  auto lambda2 = std::move(lambda);
 }
 
 class MoveOnly {