diff options
author | Alexander Kornienko <alexfh@google.com> | 2017-11-28 16:41:03 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2017-11-28 16:41:03 +0000 |
commit | 1bfcba8ceaf3c8dc9b2443e61b8649c3506ca2f0 (patch) | |
tree | ac2883c5617a84a282e431ec048900ff39a7178d | |
parent | 14230e02ffe1a42b509360d8d8b687ebc961a75e (diff) | |
download | bcm5719-llvm-1bfcba8ceaf3c8dc9b2443e61b8649c3506ca2f0.tar.gz bcm5719-llvm-1bfcba8ceaf3c8dc9b2443e61b8649c3506ca2f0.zip |
[clang-tidy] Move more checks from misc- to performance-
Summary:
rename_check.py misc-move-const-arg performance-move-const-arg
rename_check.py misc-noexcept-move-constructor performance-noexcept-move-constructor
Reviewers: hokein, xazax.hun
Reviewed By: xazax.hun
Subscribers: rnkovacs, klimek, mgorny, xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D40507
llvm-svn: 319183
20 files changed, 105 insertions, 85 deletions
diff --git a/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt b/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt index 7752dce1e59..0e37b3e4191 100644 --- a/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/hicpp/CMakeLists.txt @@ -17,6 +17,7 @@ add_clang_library(clangTidyHICPPModule clangTidyGoogleModule clangTidyMiscModule clangTidyModernizeModule + clangTidyPerformanceModule clangTidyReadabilityModule clangTidyUtils ) diff --git a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp index 4a60ebd20a5..3b08acbd6bd 100644 --- a/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/hicpp/HICPPTidyModule.cpp @@ -18,9 +18,7 @@ #include "../cppcoreguidelines/SpecialMemberFunctionsCheck.h" #include "../google/DefaultArgumentsCheck.h" #include "../google/ExplicitConstructorCheck.h" -#include "../misc/MoveConstantArgumentCheck.h" #include "../misc/NewDeleteOverloadsCheck.h" -#include "../misc/NoexceptMoveConstructorCheck.h" #include "../misc/StaticAssertCheck.h" #include "../misc/UndelegatedConstructor.h" #include "../modernize/DeprecatedHeadersCheck.h" @@ -31,6 +29,8 @@ #include "../modernize/UseNoexceptCheck.h" #include "../modernize/UseNullptrCheck.h" #include "../modernize/UseOverrideCheck.h" +#include "../performance/MoveConstArgCheck.h" +#include "../performance/NoexceptMoveConstructorCheck.h" #include "../readability/BracesAroundStatementsCheck.h" #include "../readability/FunctionSizeCheck.h" #include "../readability/IdentifierNamingCheck.h" @@ -63,11 +63,11 @@ public: "hicpp-invalid-access-moved"); CheckFactories.registerCheck<cppcoreguidelines::ProTypeMemberInitCheck>( "hicpp-member-init"); - CheckFactories.registerCheck<misc::MoveConstantArgumentCheck>( + CheckFactories.registerCheck<performance::MoveConstArgCheck>( "hicpp-move-const-arg"); CheckFactories.registerCheck<misc::NewDeleteOverloadsCheck>( "hicpp-new-delete-operators"); - CheckFactories.registerCheck<misc::NoexceptMoveConstructorCheck>( + CheckFactories.registerCheck<performance::NoexceptMoveConstructorCheck>( "hicpp-noexcept-move"); CheckFactories .registerCheck<cppcoreguidelines::ProBoundsArrayToPointerDecayCheck>( diff --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt index 8e7391ea851..44ea9112ca3 100644 --- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt @@ -11,9 +11,7 @@ add_clang_library(clangTidyMiscModule MacroRepeatedSideEffectsCheck.cpp MiscTidyModule.cpp MisplacedWideningCastCheck.cpp - MoveConstantArgumentCheck.cpp NewDeleteOverloadsCheck.cpp - NoexceptMoveConstructorCheck.cpp NonCopyableObjects.cpp RedundantExpressionCheck.cpp SizeofContainerCheck.cpp diff --git a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp index b38feca72cd..cae52b98330 100644 --- a/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp @@ -18,9 +18,7 @@ #include "MacroRepeatedSideEffectsCheck.h" #include "MisplacedConstCheck.h" #include "MisplacedWideningCastCheck.h" -#include "MoveConstantArgumentCheck.h" #include "NewDeleteOverloadsCheck.h" -#include "NoexceptMoveConstructorCheck.h" #include "NonCopyableObjects.h" #include "RedundantExpressionCheck.h" #include "SizeofContainerCheck.h" @@ -67,12 +65,8 @@ public: "misc-macro-repeated-side-effects"); CheckFactories.registerCheck<MisplacedWideningCastCheck>( "misc-misplaced-widening-cast"); - CheckFactories.registerCheck<MoveConstantArgumentCheck>( - "misc-move-const-arg"); CheckFactories.registerCheck<NewDeleteOverloadsCheck>( "misc-new-delete-overloads"); - CheckFactories.registerCheck<NoexceptMoveConstructorCheck>( - "misc-noexcept-move-constructor"); CheckFactories.registerCheck<NonCopyableObjectsCheck>( "misc-non-copyable-objects"); CheckFactories.registerCheck<RedundantExpressionCheck>( diff --git a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp index 0f4d300aa8e..3aab1693fa8 100644 --- a/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/PassByValueCheck.cpp @@ -187,7 +187,7 @@ void PassByValueCheck::check(const MatchFinder::MatchResult &Result) { return; // If the parameter is trivial to copy, don't move it. Moving a trivivally - // copyable type will cause a problem with misc-move-const-arg + // copyable type will cause a problem with performance-move-const-arg if (ParamDecl->getType().getNonReferenceType().isTriviallyCopyableType( *Result.Context)) return; diff --git a/clang-tools-extra/clang-tidy/performance/CMakeLists.txt b/clang-tools-extra/clang-tidy/performance/CMakeLists.txt index 67594332d82..ac417bcc875 100644 --- a/clang-tools-extra/clang-tidy/performance/CMakeLists.txt +++ b/clang-tools-extra/clang-tidy/performance/CMakeLists.txt @@ -7,7 +7,9 @@ add_clang_library(clangTidyPerformanceModule InefficientAlgorithmCheck.cpp InefficientStringConcatenationCheck.cpp InefficientVectorOperationCheck.cpp + MoveConstArgCheck.cpp MoveConstructorInitCheck.cpp + NoexceptMoveConstructorCheck.cpp PerformanceTidyModule.cpp TypePromotionInMathFnCheck.cpp UnnecessaryCopyInitialization.cpp diff --git a/clang-tools-extra/clang-tidy/misc/MoveConstantArgumentCheck.cpp b/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp index 196d982eff1..8d49480298d 100644 --- a/clang-tools-extra/clang-tidy/misc/MoveConstantArgumentCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp @@ -1,4 +1,4 @@ -//===--- MoveConstantArgumentCheck.cpp - clang-tidy -----------------------===// +//===--- MoveConstArgCheck.cpp - clang-tidy -----------------------===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// -#include "MoveConstantArgumentCheck.h" +#include "MoveConstArgCheck.h" #include "clang/Lex/Lexer.h" @@ -15,7 +15,7 @@ using namespace clang::ast_matchers; namespace clang { namespace tidy { -namespace misc { +namespace performance { static void ReplaceCallWithArg(const CallExpr *Call, DiagnosticBuilder &Diag, const SourceManager &SM, @@ -36,12 +36,11 @@ static void ReplaceCallWithArg(const CallExpr *Call, DiagnosticBuilder &Diag, } } -void MoveConstantArgumentCheck::storeOptions( - ClangTidyOptions::OptionMap &Opts) { +void MoveConstArgCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { Options.store(Opts, "CheckTriviallyCopyableMove", CheckTriviallyCopyableMove); } -void MoveConstantArgumentCheck::registerMatchers(MatchFinder *Finder) { +void MoveConstArgCheck::registerMatchers(MatchFinder *Finder) { if (!getLangOpts().CPlusPlus) return; @@ -60,7 +59,7 @@ void MoveConstantArgumentCheck::registerMatchers(MatchFinder *Finder) { this); } -void MoveConstantArgumentCheck::check(const MatchFinder::MatchResult &Result) { +void MoveConstArgCheck::check(const MatchFinder::MatchResult &Result) { const auto *CallMove = Result.Nodes.getNodeAs<CallExpr>("call-move"); const auto *ReceivingExpr = Result.Nodes.getNodeAs<Expr>("receiving-expr"); const Expr *Arg = CallMove->getArg(0); @@ -117,6 +116,6 @@ void MoveConstantArgumentCheck::check(const MatchFinder::MatchResult &Result) { } } -} // namespace misc +} // namespace performance } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/misc/MoveConstantArgumentCheck.h b/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h index 85764720652..13ed9aeee0f 100644 --- a/clang-tools-extra/clang-tidy/misc/MoveConstantArgumentCheck.h +++ b/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h @@ -1,4 +1,4 @@ -//===--- MoveConstantArgumentCheck.h - clang-tidy -------------------------===// +//===--- MoveConstArgCheck.h - clang-tidy -------------------------===// // // The LLVM Compiler Infrastructure // @@ -14,7 +14,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace performance { /// Find casts of calculation results to bigger type. Typically from int to /// @@ -22,9 +22,9 @@ namespace misc { /// /// - `CheckTriviallyCopyableMove`: Whether to check for trivially-copyable // types as their objects are not moved but copied. Enabled by default. -class MoveConstantArgumentCheck : public ClangTidyCheck { +class MoveConstArgCheck : public ClangTidyCheck { public: - MoveConstantArgumentCheck(StringRef Name, ClangTidyContext *Context) + MoveConstArgCheck(StringRef Name, ClangTidyContext *Context) : ClangTidyCheck(Name, Context), CheckTriviallyCopyableMove( Options.get("CheckTriviallyCopyableMove", true)) {} @@ -36,7 +36,7 @@ private: const bool CheckTriviallyCopyableMove; }; -} // namespace misc +} // namespace performance } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp b/clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp index 12a360f4ba7..86ef70ce094 100644 --- a/clang-tools-extra/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp +++ b/clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp @@ -15,7 +15,7 @@ using namespace clang::ast_matchers; namespace clang { namespace tidy { -namespace misc { +namespace performance { void NoexceptMoveConstructorCheck::registerMatchers(MatchFinder *Finder) { // Only register the matchers for C++11; the functionality currently does not @@ -48,30 +48,30 @@ void NoexceptMoveConstructorCheck::check( return; switch (ProtoType->getNoexceptSpec(*Result.Context)) { - case FunctionProtoType::NR_NoNoexcept: - diag(Decl->getLocation(), "move %0s should be marked noexcept") + case FunctionProtoType::NR_NoNoexcept: + diag(Decl->getLocation(), "move %0s should be marked noexcept") + << MethodType; + // FIXME: Add a fixit. + break; + case FunctionProtoType::NR_Throw: + // Don't complain about nothrow(false), but complain on nothrow(expr) + // where expr evaluates to false. + if (const Expr *E = ProtoType->getNoexceptExpr()) { + if (isa<CXXBoolLiteralExpr>(E)) + break; + diag(E->getExprLoc(), + "noexcept specifier on the move %0 evaluates to 'false'") << MethodType; - // FIXME: Add a fixit. - break; - case FunctionProtoType::NR_Throw: - // Don't complain about nothrow(false), but complain on nothrow(expr) - // where expr evaluates to false. - if (const Expr *E = ProtoType->getNoexceptExpr()) { - if (isa<CXXBoolLiteralExpr>(E)) - break; - diag(E->getExprLoc(), - "noexcept specifier on the move %0 evaluates to 'false'") - << MethodType; - } - break; - case FunctionProtoType::NR_Nothrow: - case FunctionProtoType::NR_Dependent: - case FunctionProtoType::NR_BadNoexcept: - break; + } + break; + case FunctionProtoType::NR_Nothrow: + case FunctionProtoType::NR_Dependent: + case FunctionProtoType::NR_BadNoexcept: + break; } } } -} // namespace misc +} // namespace performance } // namespace tidy } // namespace clang diff --git a/clang-tools-extra/clang-tidy/misc/NoexceptMoveConstructorCheck.h b/clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.h index e6a0ef9284f..9687ab1f078 100644 --- a/clang-tools-extra/clang-tidy/misc/NoexceptMoveConstructorCheck.h +++ b/clang-tools-extra/clang-tidy/performance/NoexceptMoveConstructorCheck.h @@ -7,14 +7,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPTMOVECONSTRUCTORCHECK_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPTMOVECONSTRUCTORCHECK_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_NOEXCEPTMOVECONSTRUCTORCHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_NOEXCEPTMOVECONSTRUCTORCHECK_H #include "../ClangTidy.h" namespace clang { namespace tidy { -namespace misc { +namespace performance { /// The check flags user-defined move constructors and assignment operators not /// marked with `noexcept` or marked with `noexcept(expr)` where `expr` @@ -31,8 +31,8 @@ public: void check(const ast_matchers::MatchFinder::MatchResult &Result) override; }; -} // namespace misc +} // namespace performance } // namespace tidy } // namespace clang -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPTMOVECONSTRUCTORCHECK_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_NOEXCEPTMOVECONSTRUCTORCHECK_H diff --git a/clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp b/clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp index 51a8728bf73..646c6595600 100644 --- a/clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp +++ b/clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp @@ -16,7 +16,9 @@ #include "InefficientAlgorithmCheck.h" #include "InefficientStringConcatenationCheck.h" #include "InefficientVectorOperationCheck.h" +#include "MoveConstArgCheck.h" #include "MoveConstructorInitCheck.h" +#include "NoexceptMoveConstructorCheck.h" #include "TypePromotionInMathFnCheck.h" #include "UnnecessaryCopyInitialization.h" #include "UnnecessaryValueParamCheck.h" @@ -40,8 +42,12 @@ public: "performance-inefficient-string-concatenation"); CheckFactories.registerCheck<InefficientVectorOperationCheck>( "performance-inefficient-vector-operation"); + CheckFactories.registerCheck<MoveConstArgCheck>( + "performance-move-const-arg"); CheckFactories.registerCheck<MoveConstructorInitCheck>( "performance-move-constructor-init"); + CheckFactories.registerCheck<NoexceptMoveConstructorCheck>( + "performance-noexcept-move-constructor"); CheckFactories.registerCheck<TypePromotionInMathFnCheck>( "performance-type-promotion-in-math-fn"); CheckFactories.registerCheck<UnnecessaryCopyInitialization>( diff --git a/clang-tools-extra/docs/ReleaseNotes.rst b/clang-tools-extra/docs/ReleaseNotes.rst index b0b9358315f..92e83e76b18 100644 --- a/clang-tools-extra/docs/ReleaseNotes.rst +++ b/clang-tools-extra/docs/ReleaseNotes.rst @@ -62,6 +62,12 @@ Improvements to clang-tidy Add new check to detect the use of OSSpinlock. +- The 'misc-move-const-arg' check was renamed to `performance-move-const-arg + <http://clang.llvm.org/extra/clang-tidy/checks/performance-move-const-arg.html>`_ + +- The 'misc-noexcept-move-constructor' check was renamed to `performance-noexcept-move-constructor + <http://clang.llvm.org/extra/clang-tidy/checks/performance-noexcept-move-constructor.html>`_ + - The 'misc-move-constructor-init' check was renamed to `performance-move-constructor-init <http://clang.llvm.org/extra/clang-tidy/checks/performance-move-constructor-init.html>`_ diff --git a/clang-tools-extra/docs/clang-tidy/checks/hicpp-move-const-arg.rst b/clang-tools-extra/docs/clang-tidy/checks/hicpp-move-const-arg.rst index 790ac78eaca..c8d34d0bee6 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/hicpp-move-const-arg.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/hicpp-move-const-arg.rst @@ -1,10 +1,10 @@ .. title:: clang-tidy - hicpp-move-const-arg .. meta:: - :http-equiv=refresh: 5;URL=misc-move-const-arg.html + :http-equiv=refresh: 5;URL=performance-move-const-arg.html hicpp-move-const-arg ==================== The `hicpp-move-const-arg` check is an alias, please see -`misc-move-const-arg <misc-move-const-arg.html>`_ for more information. +`performance-move-const-arg <performance-move-const-arg.html>`_ for more information. It enforces the `rule 17.3.1 <http://www.codingstandard.com/rule/17-3-1-do-not-use-stdmove-on-objects-declared-with-const-or-const-type/>`_. diff --git a/clang-tools-extra/docs/clang-tidy/checks/list.rst b/clang-tools-extra/docs/clang-tidy/checks/list.rst index c575dfdfbea..6355eb0e91e 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/list.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/list.rst @@ -93,7 +93,7 @@ Clang-Tidy Checks hicpp-function-size (redirects to readability-function-size) <hicpp-function-size> hicpp-invalid-access-moved (redirects to bugprone-use-after-move) <hicpp-invalid-access-moved> hicpp-member-init (redirects to cppcoreguidelines-pro-type-member-init) <hicpp-member-init> - hicpp-move-const-arg (redirects to misc-move-const-arg) <hicpp-move-const-arg> + hicpp-move-const-arg (redirects to performance-move-const-arg) <hicpp-move-const-arg> hicpp-named-parameter (redirects to readability-named-parameter) <hicpp-named-parameter> hicpp-new-delete-operators (redirects to misc-new-delete-overloads) <hicpp-new-delete-operators> hicpp-no-array-decay (redirects to cppcoreguidelines-pro-bounds-array-to-pointer-decay) <hicpp-no-array-decay> @@ -124,9 +124,7 @@ Clang-Tidy Checks misc-macro-repeated-side-effects misc-misplaced-const misc-misplaced-widening-cast - misc-move-const-arg misc-new-delete-overloads - misc-noexcept-move-constructor misc-non-copyable-objects misc-redundant-expression misc-sizeof-container @@ -183,7 +181,9 @@ Clang-Tidy Checks performance-inefficient-algorithm performance-inefficient-string-concatenation performance-inefficient-vector-operation + performance-move-const-arg performance-move-constructor-init + performance-noexcept-move-constructor performance-type-promotion-in-math-fn performance-unnecessary-copy-initialization performance-unnecessary-value-param diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-move-const-arg.rst b/clang-tools-extra/docs/clang-tidy/checks/performance-move-const-arg.rst index f8764a0c1b5..39e1ca4afbd 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc-move-const-arg.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/performance-move-const-arg.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-move-const-arg +.. title:: clang-tidy - performance-move-const-arg -misc-move-const-arg -=================== +performance-move-const-arg +========================== The check warns diff --git a/clang-tools-extra/docs/clang-tidy/checks/misc-noexcept-move-constructor.rst b/clang-tools-extra/docs/clang-tidy/checks/performance-noexcept-move-constructor.rst index 9d3d4f79a6a..05f1d85f1af 100644 --- a/clang-tools-extra/docs/clang-tidy/checks/misc-noexcept-move-constructor.rst +++ b/clang-tools-extra/docs/clang-tidy/checks/performance-noexcept-move-constructor.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-noexcept-move-constructor +.. title:: clang-tidy - performance-noexcept-move-constructor -misc-noexcept-move-constructor -============================== +performance-noexcept-move-constructor +===================================== The check flags user-defined move constructors and assignment operators not diff --git a/clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp b/clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp index eb9a3052998..87e22ba170c 100644 --- a/clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp +++ b/clang-tools-extra/test/clang-tidy/modernize-pass-by-value.cpp @@ -202,7 +202,7 @@ struct S { template <typename T, int N> struct array { T A[N]; }; // Test that types that are trivially copyable will not use std::move. This will -// cause problems with misc-move-const-arg, as it will revert it. +// cause problems with performance-move-const-arg, as it will revert it. struct T { T(array<int, 10> a) : a_(a) {} // CHECK-FIXES: T(array<int, 10> a) : a_(a) {} diff --git a/clang-tools-extra/test/clang-tidy/misc-move-const-arg-trivially-copyable.cpp b/clang-tools-extra/test/clang-tidy/performance-move-const-arg-trivially-copyable.cpp index 57602e17e49..ea0c2fc7130 100644 --- a/clang-tools-extra/test/clang-tidy/misc-move-const-arg-trivially-copyable.cpp +++ b/clang-tools-extra/test/clang-tidy/performance-move-const-arg-trivially-copyable.cpp @@ -1,6 +1,6 @@ -// RUN: %check_clang_tidy %s misc-move-const-arg %t \ +// RUN: %check_clang_tidy %s performance-move-const-arg %t \ // RUN: -config='{CheckOptions: \ -// RUN: [{key: misc-move-const-arg.CheckTriviallyCopyableMove, value: 0}]}' \ +// RUN: [{key: performance-move-const-arg.CheckTriviallyCopyableMove, value: 0}]}' \ // RUN: -- -std=c++14 namespace std { @@ -39,7 +39,7 @@ void moveToConstReferencePositives() { // Basic case. It is here just to have a single "detected and fixed" case. callByConstRef(std::move(obj)); - // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: passing result of std::move() as a const reference argument; no move will actually happen [misc-move-const-arg] + // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg] // CHECK-FIXES: callByConstRef(obj); } diff --git a/clang-tools-extra/test/clang-tidy/misc-move-const-arg.cpp b/clang-tools-extra/test/clang-tidy/performance-move-const-arg.cpp index f4b28066a3a..06ed6e0b56b 100644 --- a/clang-tools-extra/test/clang-tidy/misc-move-const-arg.cpp +++ b/clang-tools-extra/test/clang-tidy/performance-move-const-arg.cpp @@ -1,13 +1,23 @@ -// RUN: %check_clang_tidy %s misc-move-const-arg %t +// RUN: %check_clang_tidy %s performance-move-const-arg %t namespace std { -template <typename> struct remove_reference; +template <typename> +struct remove_reference; -template <typename _Tp> struct remove_reference { typedef _Tp type; }; +template <typename _Tp> +struct remove_reference { + typedef _Tp type; +}; -template <typename _Tp> struct remove_reference<_Tp &> { typedef _Tp type; }; +template <typename _Tp> +struct remove_reference<_Tp &> { + typedef _Tp type; +}; -template <typename _Tp> struct remove_reference<_Tp &&> { typedef _Tp type; }; +template <typename _Tp> +struct remove_reference<_Tp &&> { + typedef _Tp type; +}; template <typename _Tp> constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) { @@ -38,13 +48,13 @@ void f(TriviallyCopyable) {} void g() { TriviallyCopyable obj; f(std::move(obj)); - // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: std::move of the variable 'obj' of the trivially-copyable type 'TriviallyCopyable' has no effect; remove std::move() [misc-move-const-arg] + // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: std::move of the variable 'obj' of the trivially-copyable type 'TriviallyCopyable' has no effect; remove std::move() [performance-move-const-arg] // CHECK-FIXES: f(obj); } int f1() { return std::move(42); - // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the expression of the trivially-copyable type 'int' has no effect; remove std::move() [misc-move-const-arg] + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the expression of the trivially-copyable type 'int' has no effect; remove std::move() [performance-move-const-arg] // CHECK-FIXES: return 42; } @@ -64,11 +74,14 @@ A f4(A x4) { return std::move(x4); } A f5(const A x5) { return std::move(x5); - // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the const variable 'x5' has no effect; remove std::move() or make the variable non-const [misc-move-const-arg] + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the const variable 'x5' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg] // CHECK-FIXES: return x5; } -template <typename T> T f6(const T x6) { return std::move(x6); } +template <typename T> +T f6(const T x6) { + return std::move(x6); +} void f7() { int a = f6(10); } @@ -83,9 +96,10 @@ void f8() { #define M2(x) std::move(x) int f9() { return M2(1); } -template <typename T> T f10(const int x10) { +template <typename T> +T f10(const int x10) { return std::move(x10); - // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the const variable 'x10' of the trivially-copyable type 'const int' has no effect; remove std::move() [misc-move-const-arg] + // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the const variable 'x10' of the trivially-copyable type 'const int' has no effect; remove std::move() [performance-move-const-arg] // CHECK-FIXES: return x10; } void f11() { @@ -94,7 +108,7 @@ void f11() { } class NoMoveSemantics { - public: +public: NoMoveSemantics(); NoMoveSemantics(const NoMoveSemantics &); @@ -134,7 +148,7 @@ void moveToConstReferencePositives() { } class MoveSemantics { - public: +public: MoveSemantics(); MoveSemantics(MoveSemantics &&); diff --git a/clang-tools-extra/test/clang-tidy/misc-noexcept-move-constructor.cpp b/clang-tools-extra/test/clang-tidy/performance-noexcept-move-constructor.cpp index b8154ec3af1..70d70650c1d 100644 --- a/clang-tools-extra/test/clang-tidy/misc-noexcept-move-constructor.cpp +++ b/clang-tools-extra/test/clang-tidy/performance-noexcept-move-constructor.cpp @@ -1,8 +1,8 @@ -// RUN: %check_clang_tidy %s misc-noexcept-move-constructor %t +// RUN: %check_clang_tidy %s performance-noexcept-move-constructor %t class A { A(A &&); - // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be marked noexcept [misc-noexcept-move-constructor] + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be marked noexcept [performance-noexcept-move-constructor] A &operator=(A &&); // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: move assignment operators should }; @@ -10,7 +10,7 @@ class A { struct B { static constexpr bool kFalse = false; B(B &&) noexcept(kFalse); - // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: noexcept specifier on the move constructor evaluates to 'false' [misc-noexcept-move-constructor] + // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: noexcept specifier on the move constructor evaluates to 'false' [performance-noexcept-move-constructor] }; class OK {}; @@ -21,10 +21,10 @@ void f() { } class OK1 { - public: +public: OK1(); OK1(const OK1 &); - OK1(OK1&&) noexcept; + OK1(OK1 &&) noexcept; OK1 &operator=(OK1 &&) noexcept; void f(); void g() noexcept; |