llvm-project/clang-tools-extra/clang-tidy/misc
Martin Bohme b1ce6c6d57 [clang-tidy] Add check 'misc-move-forwarding-reference'
Summary:
The check emits a warning if std::move() is applied to a forwarding reference, i.e. an rvalue reference of a function template argument type.

If a developer is unaware of the special rules for template argument deduction on forwarding references, it will seem reasonable to apply std::move() to the forwarding reference, in the same way that this would be done for a "normal" rvalue reference.

This has a consequence that is usually unwanted and possibly surprising: If the function that takes the forwarding reference as its parameter is called with an lvalue, that lvalue will be moved from (and hence placed into an indeterminate state) even though no std::move() was applied to the lvalue at the callsite.

As a fix, the check will suggest replacing the std::move() with a std::forward().

This patch requires D23004 to be submitted before it.

Reviewers: sbenza, aaron.ballman

Subscribers: klimek, etienneb, alexfh, aaron.ballman, Prazek, Eugene.Zelenko, mgehre, cfe-commits

Projects: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D22220

llvm-svn: 280077
2016-08-30 12:11:12 +00:00
..
ArgumentCommentCheck.cpp [clang-tidy] misc-argument-comment non-strict mode 2016-08-04 14:54:54 +00:00
ArgumentCommentCheck.h [clang-tidy] misc-argument-comment non-strict mode 2016-08-04 14:54:54 +00:00
AssertSideEffectCheck.cpp [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
AssertSideEffectCheck.h [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
BoolPointerImplicitConversionCheck.cpp [ASTMatchers] Added ignoringParenImpCasts to has matchers 2016-05-31 15:26:56 +00:00
BoolPointerImplicitConversionCheck.h [clang-tidy] Update docs for clang-tidy checks. NFC 2015-08-27 18:01:58 +00:00
CMakeLists.txt [clang-tidy] Add check 'misc-move-forwarding-reference' 2016-08-30 12:11:12 +00:00
DanglingHandleCheck.cpp Fix clang-tidy patterns to adapt to newly added ExprWithCleanups nodes. 2016-06-21 20:11:20 +00:00
DanglingHandleCheck.h [clang-tidy] Add check to detect dangling references in value handlers. 2016-03-29 18:02:26 +00:00
DefinitionsInHeadersCheck.cpp [clang-tidy] Fix misc-definitions-in-headers misplaced fixing to fully templated function. 2016-07-13 13:55:29 +00:00
DefinitionsInHeadersCheck.h [clang-tdiy] Add header file extension configuration support. 2016-02-05 11:23:59 +00:00
FoldInitTypeCheck.cpp A clang-tidy check for std:accumulate. 2016-04-26 10:05:45 +00:00
FoldInitTypeCheck.h A clang-tidy check for std:accumulate. 2016-04-26 10:05:45 +00:00
ForwardDeclarationNamespaceCheck.cpp [clang-tidy] Remove unnecessary getName() on Decls and Types feeding into a DiagnosticBuilder 2016-04-07 14:55:25 +00:00
ForwardDeclarationNamespaceCheck.h [clang-tidy] Added a check for forward declaration in the potentially wrong namespace 2016-02-24 13:35:32 +00:00
InaccurateEraseCheck.cpp [ASTMatchers] Added ignoringParenImpCasts to has matchers 2016-05-31 15:26:56 +00:00
InaccurateEraseCheck.h [clang-tidy] Update docs for clang-tidy checks. NFC 2015-08-27 18:01:58 +00:00
IncorrectRoundings.cpp [ASTMatchers] Added ignoringParenImpCasts to has matchers 2016-05-31 15:26:56 +00:00
IncorrectRoundings.h [clang-tidy] Correct IncorrectRoundings namespace. 2016-02-08 15:54:30 +00:00
InefficientAlgorithmCheck.cpp [ASTMatchers] Added ignoringParenImpCasts to has matchers 2016-05-31 15:26:56 +00:00
InefficientAlgorithmCheck.h [clang-tidy] Update docs for clang-tidy checks. NFC 2015-08-27 18:01:58 +00:00
MacroParenthesesCheck.cpp [clang-tidy] remove trailing whitespaces and retab 2016-08-01 12:06:18 +00:00
MacroParenthesesCheck.h [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
MacroRepeatedSideEffectsCheck.cpp [clang-tidy] Fix misc-macro-repeated-side-effects false positive with stringified arguments 2016-04-23 00:00:08 +00:00
MacroRepeatedSideEffectsCheck.h [clang-tidy] Update docs for clang-tidy checks. NFC 2015-08-27 18:01:58 +00:00
MiscTidyModule.cpp [clang-tidy] Add check 'misc-move-forwarding-reference' 2016-08-30 12:11:12 +00:00
MisplacedConstCheck.cpp Add the misc-misplaced-const check to clang-tidy, which diagnoses when a const-qualifier is applied to a typedef of pointer type rather than to the pointee type. 2016-06-07 17:22:47 +00:00
MisplacedConstCheck.h Add the misc-misplaced-const check to clang-tidy, which diagnoses when a const-qualifier is applied to a typedef of pointer type rather than to the pointee type. 2016-06-07 17:22:47 +00:00
MisplacedWideningCastCheck.cpp [ASTMatchers] Added ignoringParenImpCasts to has matchers 2016-05-31 15:26:56 +00:00
MisplacedWideningCastCheck.h [clang-tidy] Extension of checker misc-misplaced-widening-cast 2016-04-06 12:04:51 +00:00
MoveConstantArgumentCheck.cpp [clang-tidy misc-move-const-arg] more specific messages + suggest alternative solution 2016-08-24 21:23:24 +00:00
MoveConstantArgumentCheck.h [clang-tidy] misc-move-const-arg: Fix typos 2016-06-16 14:32:54 +00:00
MoveConstructorInitCheck.cpp [clang-tidy] remove trailing whitespaces and retab 2016-08-01 12:06:18 +00:00
MoveConstructorInitCheck.h [clang-tidy] Cleanup namespace in utils folder. 2016-05-03 02:54:05 +00:00
MoveForwardingReferenceCheck.cpp [clang-tidy] Add check 'misc-move-forwarding-reference' 2016-08-30 12:11:12 +00:00
MoveForwardingReferenceCheck.h [clang-tidy] Add check 'misc-move-forwarding-reference' 2016-08-30 12:11:12 +00:00
MultipleStatementMacroCheck.cpp [clang-tidy] Add check misc-multiple-statement-macro 2016-04-14 21:15:57 +00:00
MultipleStatementMacroCheck.h [clang-tidy] Add check misc-multiple-statement-macro 2016-04-14 21:15:57 +00:00
NewDeleteOverloadsCheck.cpp [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
NewDeleteOverloadsCheck.h Adding a checker (misc-new-delete-overloads) that detects mismatched overloads of operator new and operator delete. Corresponds to the CERT C++ secure coding rule: https://www.securecoding.cert.org/confluence/display/cplusplus/DCL54-CPP.+Overload+allocation+and+deallocation+functions+as+a+pair+in+the+same+scope 2015-09-29 13:12:21 +00:00
NoexceptMoveConstructorCheck.cpp [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
NoexceptMoveConstructorCheck.h [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
NonCopyableObjects.cpp [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
NonCopyableObjects.h [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
PointerAndIntegralOperationCheck.cpp [clang-tidy] Cleanup some ast-matchers and lift some to utils. 2016-04-21 16:57:56 +00:00
PointerAndIntegralOperationCheck.h [clang-tidy] Add checker for operations between integrals and pointers 2016-04-15 16:31:15 +00:00
RedundantExpressionCheck.cpp [clang-tidy] Enhance redundant-expression check 2016-07-07 04:03:05 +00:00
RedundantExpressionCheck.h [clang-tidy] Enhance redundant-expression check 2016-07-07 04:03:05 +00:00
SizeofContainerCheck.cpp [clang-tidy] remove trailing whitespaces and retab 2016-08-01 12:06:18 +00:00
SizeofContainerCheck.h [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
SizeofExpressionCheck.cpp [ASTMatchers] Added ignoringParenImpCasts to has matchers 2016-05-31 15:26:56 +00:00
SizeofExpressionCheck.h Add missing override keyword to silence -Winconsistent-missing-override. NFC 2016-04-16 02:42:03 +00:00
StaticAssertCheck.cpp [clang-tidy] remove trailing whitespaces and retab 2016-08-01 12:06:18 +00:00
StaticAssertCheck.h [clang-tidy] remove trailing whitespaces and retab 2016-08-01 12:06:18 +00:00
StringConstructorCheck.cpp [clang-tidy] Add FixIt for swapping arguments in string-constructor-checker. 2016-05-11 17:32:12 +00:00
StringConstructorCheck.h [Clang-tidy] Fix Clang warning in misc/StringConstructorCheck.h. 2016-04-22 21:33:33 +00:00
StringIntegerAssignmentCheck.cpp [clang-tidy] remove trailing whitespaces and retab 2016-08-01 12:06:18 +00:00
StringIntegerAssignmentCheck.h [clang-tidy] remove trailing whitespaces and retab 2016-08-01 12:06:18 +00:00
StringLiteralWithEmbeddedNulCheck.cpp [clang-tidy] add new checker for string literal with NUL character. 2016-04-07 16:16:36 +00:00
StringLiteralWithEmbeddedNulCheck.h [clang-tidy] add new checker for string literal with NUL character. 2016-04-07 16:16:36 +00:00
SuspiciousMissingCommaCheck.cpp [clang-tidy] remove trailing whitespaces and retab 2016-08-01 12:06:18 +00:00
SuspiciousMissingCommaCheck.h [clang-tidy] remove trailing whitespaces and retab 2016-08-01 12:06:18 +00:00
SuspiciousSemicolonCheck.cpp [clang-tidy] Cleanup namespace in utils folder. 2016-05-03 02:54:05 +00:00
SuspiciousSemicolonCheck.h [clang-tidy] Add a check to find unintended semicolons that changes the semantics. 2016-02-11 09:23:33 +00:00
SuspiciousStringCompareCheck.cpp [ASTMatchers] Added ignoringParenImpCasts to has matchers 2016-05-31 15:26:56 +00:00
SuspiciousStringCompareCheck.h [clang-tidy] Add new checker for comparison with runtime string functions. 2016-04-21 17:19:36 +00:00
SwappedArgumentsCheck.cpp [clang-tidy] remove trailing whitespaces and retab 2016-08-01 12:06:18 +00:00
SwappedArgumentsCheck.h [clang-tidy] Update docs for clang-tidy checks. NFC 2015-08-27 18:01:58 +00:00
ThrowByValueCatchByReferenceCheck.cpp [clang-tidy] remove trailing whitespaces and retab 2016-08-01 12:06:18 +00:00
ThrowByValueCatchByReferenceCheck.h [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
UnconventionalAssignOperatorCheck.cpp [ASTMatchers] Added ignoringParenImpCasts to has matchers 2016-05-31 15:26:56 +00:00
UnconventionalAssignOperatorCheck.h Trying to fix docs. 2016-05-09 10:56:57 +00:00
UndelegatedConstructor.cpp [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
UndelegatedConstructor.h [clang-tidy] Update docs for clang-tidy checks. NFC 2015-08-27 18:01:58 +00:00
UniqueptrResetReleaseCheck.cpp [ASTMatchers] Added ignoringParenImpCasts to has matchers 2016-05-31 15:26:56 +00:00
UniqueptrResetReleaseCheck.h [clang-tidy] Update docs for clang-tidy checks. NFC 2015-08-27 18:01:58 +00:00
UnusedAliasDeclsCheck.cpp [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
UnusedAliasDeclsCheck.h [clang-tidy] remove trailing whitespaces and retab 2016-08-01 12:06:18 +00:00
UnusedParametersCheck.cpp [clang-tidy] Cleaning namespaces to be more consistant across checkers. 2016-05-02 18:00:29 +00:00
UnusedParametersCheck.h [clang-tidy] remove trailing whitespaces and retab 2016-08-01 12:06:18 +00:00
UnusedRAIICheck.cpp [ASTMatchers] Added ignoringParenImpCasts to has matchers 2016-05-31 15:26:56 +00:00
UnusedRAIICheck.h [clang-tidy] Updated misc-unused-raii documentation. 2015-09-25 17:50:11 +00:00
UnusedUsingDeclsCheck.cpp [clang-tidy] Fix an unused-using-decl false positive about template arguments in 2016-08-02 11:26:35 +00:00
UnusedUsingDeclsCheck.h [clang-tidy] Ignore function context in misc-unused-using-decls. 2016-06-03 08:05:11 +00:00
VirtualNearMissCheck.cpp Merge branch 'arcpatch-D16922' 2016-02-11 16:03:27 +00:00
VirtualNearMissCheck.h Merge branch 'arcpatch-D16922' 2016-02-11 16:03:27 +00:00