forked from OSchip/llvm-project
				
			[clang-tidy] misc-move-const-arg shouldn't complain on std::move(lambda)
llvm-svn: 303554
This commit is contained in:
		
							parent
							
								
									6bb7e21f10
								
							
						
					
					
						commit
						f2dc6492ed
					
				| 
						 | 
					@ -74,6 +74,12 @@ void MoveConstantArgumentCheck::check(const MatchFinder::MatchResult &Result) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (IsConstArg || IsTriviallyCopyable) {
 | 
					  if (IsConstArg || IsTriviallyCopyable) {
 | 
				
			||||||
    if (const CXXRecordDecl *R = Arg->getType()->getAsCXXRecordDecl()) {
 | 
					    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()) {
 | 
					      for (const auto *Ctor : R->ctors()) {
 | 
				
			||||||
        if (Ctor->isCopyConstructor() && Ctor->isDeleted())
 | 
					        if (Ctor->isCopyConstructor() && Ctor->isDeleted())
 | 
				
			||||||
          return;
 | 
					          return;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -157,6 +157,9 @@ void moveToConstReferenceNegatives() {
 | 
				
			||||||
  // No warning inside of macro expansion, even if the macro expansion is inside
 | 
					  // No warning inside of macro expansion, even if the macro expansion is inside
 | 
				
			||||||
  // a lambda that is, in turn, an argument to a macro.
 | 
					  // a lambda that is, in turn, an argument to a macro.
 | 
				
			||||||
  CALL([no_move_semantics] { M3(NoMoveSemantics, no_move_semantics); });
 | 
					  CALL([no_move_semantics] { M3(NoMoveSemantics, no_move_semantics); });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  auto lambda = [] {};
 | 
				
			||||||
 | 
					  auto lambda2 = std::move(lambda);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class MoveOnly {
 | 
					class MoveOnly {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue