Index: clang-tidy/cert/CERTTidyModule.cpp =================================================================== --- clang-tidy/cert/CERTTidyModule.cpp +++ clang-tidy/cert/CERTTidyModule.cpp @@ -11,11 +11,11 @@ #include "../ClangTidyModule.h" #include "../ClangTidyModuleRegistry.h" #include "../google/UnnamedNamespaceInHeaderCheck.h" -#include "../misc/MoveConstructorInitCheck.h" #include "../misc/NewDeleteOverloadsCheck.h" #include "../misc/NonCopyableObjects.h" #include "../misc/StaticAssertCheck.h" #include "../misc/ThrowByValueCatchByReferenceCheck.h" +#include "../performance/MoveConstructorInitCheck.h" #include "CommandProcessorCheck.h" #include "DontModifyStdNamespaceCheck.h" #include "FloatLoopCounter.h" @@ -46,7 +46,7 @@ CheckFactories.registerCheck<google::build::UnnamedNamespaceInHeaderCheck>( "cert-dcl59-cpp"); // OOP - CheckFactories.registerCheck<misc::MoveConstructorInitCheck>( + CheckFactories.registerCheck<performance::MoveConstructorInitCheck>( "cert-oop11-cpp"); // ERR CheckFactories.registerCheck<misc::ThrowByValueCatchByReferenceCheck>( Index: clang-tidy/misc/CMakeLists.txt =================================================================== --- clang-tidy/misc/CMakeLists.txt +++ clang-tidy/misc/CMakeLists.txt @@ -7,13 +7,11 @@ UnconventionalAssignOperatorCheck.cpp DefinitionsInHeadersCheck.cpp IncorrectRoundings.cpp - InefficientAlgorithmCheck.cpp MacroParenthesesCheck.cpp MacroRepeatedSideEffectsCheck.cpp MiscTidyModule.cpp MisplacedWideningCastCheck.cpp MoveConstantArgumentCheck.cpp - MoveConstructorInitCheck.cpp NewDeleteOverloadsCheck.cpp NoexceptMoveConstructorCheck.cpp NonCopyableObjects.cpp Index: clang-tidy/misc/MiscTidyModule.cpp =================================================================== --- clang-tidy/misc/MiscTidyModule.cpp +++ clang-tidy/misc/MiscTidyModule.cpp @@ -13,14 +13,12 @@ #include "DefinitionsInHeadersCheck.h" #include "ForwardingReferenceOverloadCheck.h" #include "IncorrectRoundings.h" -#include "InefficientAlgorithmCheck.h" #include "LambdaFunctionNameCheck.h" #include "MacroParenthesesCheck.h" #include "MacroRepeatedSideEffectsCheck.h" #include "MisplacedConstCheck.h" #include "MisplacedWideningCastCheck.h" #include "MoveConstantArgumentCheck.h" -#include "MoveConstructorInitCheck.h" #include "NewDeleteOverloadsCheck.h" #include "NoexceptMoveConstructorCheck.h" #include "NonCopyableObjects.h" @@ -63,8 +61,6 @@ "misc-definitions-in-headers"); CheckFactories.registerCheck<IncorrectRoundings>( "misc-incorrect-roundings"); - CheckFactories.registerCheck<InefficientAlgorithmCheck>( - "misc-inefficient-algorithm"); CheckFactories.registerCheck<MacroParenthesesCheck>( "misc-macro-parentheses"); CheckFactories.registerCheck<MacroRepeatedSideEffectsCheck>( @@ -73,8 +69,6 @@ "misc-misplaced-widening-cast"); CheckFactories.registerCheck<MoveConstantArgumentCheck>( "misc-move-const-arg"); - CheckFactories.registerCheck<MoveConstructorInitCheck>( - "misc-move-constructor-init"); CheckFactories.registerCheck<NewDeleteOverloadsCheck>( "misc-new-delete-overloads"); CheckFactories.registerCheck<NoexceptMoveConstructorCheck>( Index: clang-tidy/performance/CMakeLists.txt =================================================================== --- clang-tidy/performance/CMakeLists.txt +++ clang-tidy/performance/CMakeLists.txt @@ -4,8 +4,10 @@ FasterStringFindCheck.cpp ForRangeCopyCheck.cpp ImplicitConversionInLoopCheck.cpp + InefficientAlgorithmCheck.cpp InefficientStringConcatenationCheck.cpp InefficientVectorOperationCheck.cpp + MoveConstructorInitCheck.cpp PerformanceTidyModule.cpp TypePromotionInMathFnCheck.cpp UnnecessaryCopyInitialization.cpp Index: clang-tidy/performance/InefficientAlgorithmCheck.h =================================================================== --- clang-tidy/performance/InefficientAlgorithmCheck.h +++ clang-tidy/performance/InefficientAlgorithmCheck.h @@ -7,14 +7,14 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_INEFFICIENTALGORITHMCHECK_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_INEFFICIENTALGORITHMCHECK_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_INEFFICIENTALGORITHMCHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_INEFFICIENTALGORITHMCHECK_H #include "../ClangTidy.h" namespace clang { namespace tidy { -namespace misc { +namespace performance { /// Warns on inefficient use of STL algorithms on associative containers. /// @@ -29,8 +29,8 @@ 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_INEFFICIENTALGORITHMCHECK_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_INEFFICIENTALGORITHMCHECK_H Index: clang-tidy/performance/InefficientAlgorithmCheck.cpp =================================================================== --- clang-tidy/performance/InefficientAlgorithmCheck.cpp +++ clang-tidy/performance/InefficientAlgorithmCheck.cpp @@ -16,7 +16,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace performance { static bool areTypesCompatible(QualType Left, QualType Right) { if (const auto *LeftRefType = Left->getAs<ReferenceType>()) @@ -158,6 +158,6 @@ << Hint; } -} // namespace misc +} // namespace performance } // namespace tidy } // namespace clang Index: clang-tidy/performance/MoveConstructorInitCheck.h =================================================================== --- clang-tidy/performance/MoveConstructorInitCheck.h +++ clang-tidy/performance/MoveConstructorInitCheck.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTRUCTORINITCHECK_H -#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTRUCTORINITCHECK_H +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_MOVECONSTRUCTORINITCHECK_H +#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_MOVECONSTRUCTORINITCHECK_H #include "../ClangTidy.h" #include "../utils/IncludeInserter.h" @@ -17,13 +17,13 @@ namespace clang { namespace tidy { -namespace misc { +namespace performance { /// The check flags user-defined move constructors that have a ctor-initializer /// initializing a member or base class through a copy constructor instead of a /// move constructor. /// For the user-facing documentation see: -/// http://clang.llvm.org/extra/clang-tidy/checks/misc-move-constructor-init.html +/// http://clang.llvm.org/extra/clang-tidy/checks/performance-move-constructor-init.html class MoveConstructorInitCheck : public ClangTidyCheck { public: MoveConstructorInitCheck(StringRef Name, ClangTidyContext *Context); @@ -37,8 +37,8 @@ const utils::IncludeSorter::IncludeStyle IncludeStyle; }; -} // namespace misc +} // namespace performance } // namespace tidy } // namespace clang -#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTRUCTORINITCHECK_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_MOVECONSTRUCTORINITCHECK_H Index: clang-tidy/performance/MoveConstructorInitCheck.cpp =================================================================== --- clang-tidy/performance/MoveConstructorInitCheck.cpp +++ clang-tidy/performance/MoveConstructorInitCheck.cpp @@ -19,7 +19,7 @@ namespace clang { namespace tidy { -namespace misc { +namespace performance { MoveConstructorInitCheck::MoveConstructorInitCheck(StringRef Name, ClangTidyContext *Context) @@ -105,6 +105,6 @@ utils::IncludeSorter::toString(IncludeStyle)); } -} // namespace misc +} // namespace performance } // namespace tidy } // namespace clang Index: clang-tidy/performance/PerformanceTidyModule.cpp =================================================================== --- clang-tidy/performance/PerformanceTidyModule.cpp +++ clang-tidy/performance/PerformanceTidyModule.cpp @@ -13,8 +13,10 @@ #include "FasterStringFindCheck.h" #include "ForRangeCopyCheck.h" #include "ImplicitConversionInLoopCheck.h" +#include "InefficientAlgorithmCheck.h" #include "InefficientStringConcatenationCheck.h" #include "InefficientVectorOperationCheck.h" +#include "MoveConstructorInitCheck.h" #include "TypePromotionInMathFnCheck.h" #include "UnnecessaryCopyInitialization.h" #include "UnnecessaryValueParamCheck.h" @@ -32,10 +34,14 @@ "performance-for-range-copy"); CheckFactories.registerCheck<ImplicitConversionInLoopCheck>( "performance-implicit-conversion-in-loop"); + CheckFactories.registerCheck<InefficientAlgorithmCheck>( + "performance-inefficient-algorithm"); CheckFactories.registerCheck<InefficientStringConcatenationCheck>( "performance-inefficient-string-concatenation"); CheckFactories.registerCheck<InefficientVectorOperationCheck>( "performance-inefficient-vector-operation"); + CheckFactories.registerCheck<MoveConstructorInitCheck>( + "performance-move-constructor-init"); CheckFactories.registerCheck<TypePromotionInMathFnCheck>( "performance-type-promotion-in-math-fn"); CheckFactories.registerCheck<UnnecessaryCopyInitialization>( Index: docs/ReleaseNotes.rst =================================================================== --- docs/ReleaseNotes.rst +++ docs/ReleaseNotes.rst @@ -57,6 +57,12 @@ Improvements to clang-tidy -------------------------- +- 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>`_ + +- The 'misc-inefficient-algorithm' check was renamed to `performance-inefficient-algorithm + <http://clang.llvm.org/extra/clang-tidy/checks/performance-inefficient-algorithm.html>`_ + - The 'misc-virtual-near-miss' check was renamed to `bugprone-virtual-near-miss <http://clang.llvm.org/extra/clang-tidy/checks/bugprone-virtual-near-miss.html>`_ Index: docs/clang-tidy/checks/cert-oop11-cpp.rst =================================================================== --- docs/clang-tidy/checks/cert-oop11-cpp.rst +++ docs/clang-tidy/checks/cert-oop11-cpp.rst @@ -1,10 +1,10 @@ .. title:: clang-tidy - cert-oop11-cpp .. meta:: - :http-equiv=refresh: 5;URL=misc-move-constructor-init.html + :http-equiv=refresh: 5;URL=performance-move-constructor-init.html cert-oop11-cpp ============== The cert-oop11-cpp check is an alias, please see -`misc-move-constructor-init <misc-move-constructor-init.html>`_ for more +`performance-move-constructor-init <performance-move-constructor-init.html>`_ for more information. Index: docs/clang-tidy/checks/list.rst =================================================================== --- docs/clang-tidy/checks/list.rst +++ docs/clang-tidy/checks/list.rst @@ -51,7 +51,7 @@ cert-flp30-c cert-msc30-c (redirects to cert-msc50-cpp) <cert-msc30-c> cert-msc50-cpp - cert-oop11-cpp (redirects to misc-move-constructor-init) <cert-oop11-cpp> + cert-oop11-cpp (redirects to performance-move-constructor-init) <cert-oop11-cpp> cppcoreguidelines-c-copy-assignment-signature (redirects to misc-unconventional-assign-operator) <cppcoreguidelines-c-copy-assignment-signature> cppcoreguidelines-interfaces-global-init cppcoreguidelines-no-malloc @@ -119,14 +119,12 @@ misc-definitions-in-headers misc-forwarding-reference-overload misc-incorrect-roundings - misc-inefficient-algorithm misc-lambda-function-name misc-macro-parentheses misc-macro-repeated-side-effects misc-misplaced-const misc-misplaced-widening-cast misc-move-const-arg - misc-move-constructor-init misc-new-delete-overloads misc-noexcept-move-constructor misc-non-copyable-objects @@ -181,8 +179,10 @@ performance-faster-string-find performance-for-range-copy performance-implicit-conversion-in-loop + performance-inefficient-algorithm performance-inefficient-string-concatenation performance-inefficient-vector-operation + performance-move-constructor-init performance-type-promotion-in-math-fn performance-unnecessary-copy-initialization performance-unnecessary-value-param Index: docs/clang-tidy/checks/performance-inefficient-algorithm.rst =================================================================== --- docs/clang-tidy/checks/performance-inefficient-algorithm.rst +++ docs/clang-tidy/checks/performance-inefficient-algorithm.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-inefficient-algorithm +.. title:: clang-tidy - performance-inefficient-algorithm -misc-inefficient-algorithm -========================== +performance-inefficient-algorithm +================================= Warns on inefficient use of STL algorithms on associative containers. Index: docs/clang-tidy/checks/performance-move-constructor-init.rst =================================================================== --- docs/clang-tidy/checks/performance-move-constructor-init.rst +++ docs/clang-tidy/checks/performance-move-constructor-init.rst @@ -1,7 +1,7 @@ -.. title:: clang-tidy - misc-move-constructor-init +.. title:: clang-tidy - performance-move-constructor-init -misc-move-constructor-init -========================== +performance-move-constructor-init +================================= "cert-oop11-cpp" redirects here as an alias for this check. Index: test/clang-tidy/cert-oop11-cpp.cpp =================================================================== --- test/clang-tidy/cert-oop11-cpp.cpp +++ test/clang-tidy/cert-oop11-cpp.cpp @@ -16,6 +16,6 @@ // This should not produce a diagnostic because it is not covered under // the CERT guideline for OOP11-CPP. However, this will produce a diagnostic - // under misc-move-constructor-init. + // under performance-move-constructor-init. D(B b) : b(b) {} }; Index: test/clang-tidy/performance-inefficient-algorithm.cpp =================================================================== --- test/clang-tidy/performance-inefficient-algorithm.cpp +++ test/clang-tidy/performance-inefficient-algorithm.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-inefficient-algorithm %t +// RUN: %check_clang_tidy %s performance-inefficient-algorithm %t namespace std { template <typename T> struct less { @@ -78,7 +78,7 @@ int main() { std::set<int> s; auto it = std::find(s.begin(), s.end(), 43); - // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: this STL algorithm call should be replaced with a container method [misc-inefficient-algorithm] + // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: this STL algorithm call should be replaced with a container method [performance-inefficient-algorithm] // CHECK-FIXES: {{^ }}auto it = s.find(43);{{$}} auto c = count(s.begin(), s.end(), 43); // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: this STL algorithm call should be @@ -107,7 +107,7 @@ // CHECK-FIXES: {{^ }}msptr->find(46);{{$}} it = std::find(s.begin(), s.end(), 43, std::greater<int>()); - // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: different comparers used in the algorithm and the container [misc-inefficient-algorithm] + // CHECK-MESSAGES: :[[@LINE-1]]:42: warning: different comparers used in the algorithm and the container [performance-inefficient-algorithm] FIND_IN_SET(s); // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: this STL algorithm call should be Index: test/clang-tidy/performance-move-constructor-init.cpp =================================================================== --- test/clang-tidy/performance-move-constructor-init.cpp +++ test/clang-tidy/performance-move-constructor-init.cpp @@ -1,4 +1,4 @@ -// RUN: %check_clang_tidy %s misc-move-constructor-init,modernize-pass-by-value %t -- \ +// RUN: %check_clang_tidy %s performance-move-constructor-init,modernize-pass-by-value %t -- \ // RUN: -config='{CheckOptions: \ // RUN: [{key: modernize-pass-by-value.ValuesOnly, value: 1}]}' \ // RUN: -- -std=c++11 -isystem %S/Inputs/Headers @@ -30,7 +30,7 @@ struct D : B { D() : B() {} D(const D &RHS) : B(RHS) {} - // CHECK-MESSAGES: :[[@LINE+3]]:16: warning: move constructor initializes base class by calling a copy constructor [misc-move-constructor-init] + // CHECK-MESSAGES: :[[@LINE+3]]:16: warning: move constructor initializes base class by calling a copy constructor [performance-move-constructor-init] // CHECK-MESSAGES: 26:3: note: copy constructor being called // CHECK-MESSAGES: 27:3: note: candidate move constructor here D(D &&RHS) : B(RHS) {} @@ -75,7 +75,7 @@ struct M { B Mem; - // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: move constructor initializes class member by calling a copy constructor [misc-move-constructor-init] + // CHECK-MESSAGES: :[[@LINE+1]]:16: warning: move constructor initializes class member by calling a copy constructor [performance-move-constructor-init] M(M &&RHS) : Mem(RHS.Mem) {} };