diff options
17 files changed, 57 insertions, 51 deletions
diff --git a/clang-tidy/cert/CERTTidyModule.cpp b/clang-tidy/cert/CERTTidyModule.cpp index 32f6d6c1..1007522d 100644 --- a/clang-tidy/cert/CERTTidyModule.cpp +++ b/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 @@ public: 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>( diff --git a/clang-tidy/misc/CMakeLists.txt b/clang-tidy/misc/CMakeLists.txt index 8a4dcbd5..8e7391ea 100644 --- a/clang-tidy/misc/CMakeLists.txt +++ b/clang-tidy/misc/CMakeLists.txt @@ -7,13 +7,11 @@ add_clang_library(clangTidyMiscModule 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 diff --git a/clang-tidy/misc/MiscTidyModule.cpp b/clang-tidy/misc/MiscTidyModule.cpp index 1dddd4e2..b38feca7 100644 --- a/clang-tidy/misc/MiscTidyModule.cpp +++ b/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 @@ public: "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 @@ public: "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>( diff --git a/clang-tidy/performance/CMakeLists.txt b/clang-tidy/performance/CMakeLists.txt index 4b5541fd..67594332 100644 --- a/clang-tidy/performance/CMakeLists.txt +++ b/clang-tidy/performance/CMakeLists.txt @@ -4,8 +4,10 @@ add_clang_library(clangTidyPerformanceModule FasterStringFindCheck.cpp ForRangeCopyCheck.cpp ImplicitConversionInLoopCheck.cpp + InefficientAlgorithmCheck.cpp InefficientStringConcatenationCheck.cpp InefficientVectorOperationCheck.cpp + MoveConstructorInitCheck.cpp PerformanceTidyModule.cpp TypePromotionInMathFnCheck.cpp UnnecessaryCopyInitialization.cpp diff --git a/clang-tidy/misc/InefficientAlgorithmCheck.cpp b/clang-tidy/performance/InefficientAlgorithmCheck.cpp index a5a5b2b4..4471d077 100644 --- a/clang-tidy/misc/InefficientAlgorithmCheck.cpp +++ b/clang-tidy/performance/InefficientAlgorithmCheck.cpp @@ -16,7 +16,7 @@ using namespace clang::ast_matchers; 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 @@ void InefficientAlgorithmCheck::check(const MatchFinder::MatchResult &Result) { << Hint; } -} // namespace misc +} // namespace performance } // namespace tidy } // namespace clang diff --git a/clang-tidy/misc/InefficientAlgorithmCheck.h b/clang-tidy/performance/InefficientAlgorithmCheck.h index 6935b455..72506cf7 100644 --- a/clang-tidy/misc/InefficientAlgorithmCheck.h +++ b/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 @@ 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_INEFFICIENTALGORITHMCHECK_H +#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_INEFFICIENTALGORITHMCHECK_H diff --git a/clang-tidy/misc/MoveConstructorInitCheck.cpp b/clang-tidy/performance/MoveConstructorInitCheck.cpp index 2c6af5f8..055e4f0a 100644 --- a/clang-tidy/misc/MoveConstructorInitCheck.cpp +++ b/clang-tidy/performance/MoveConstructorInitCheck.cpp @@ -19,7 +19,7 @@ using namespace clang::ast_matchers; namespace clang { namespace tidy { -namespace misc { +namespace performance { MoveConstructorInitCheck::MoveConstructorInitCheck(StringRef Name, ClangTidyContext *Context) @@ -105,6 +105,6 @@ void MoveConstructorInitCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) { utils::IncludeSorter::toString(IncludeStyle)); } -} // namespace misc +} // namespace performance } // namespace tidy } // namespace clang diff --git a/clang-tidy/misc/MoveConstructorInitCheck.h b/clang-tidy/performance/MoveConstructorInitCheck.h index adfba029..3b7dda06 100644 --- a/clang-tidy/misc/MoveConstructorInitCheck.h +++ b/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 @@ private: 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 diff --git a/clang-tidy/performance/PerformanceTidyModule.cpp b/clang-tidy/performance/PerformanceTidyModule.cpp index b4652509..51a8728b 100644 --- a/clang-tidy/performance/PerformanceTidyModule.cpp +++ b/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 @@ public: "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>( diff --git a/docs/ReleaseNotes.rst b/docs/ReleaseNotes.rst index 4e456fda..431bb3ff 100644 --- a/docs/ReleaseNotes.rst +++ b/docs/ReleaseNotes.rst @@ -57,6 +57,12 @@ The improvements are... 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>`_ diff --git a/docs/clang-tidy/checks/cert-oop11-cpp.rst b/docs/clang-tidy/checks/cert-oop11-cpp.rst index c824528c..dcd0fee8 100644 --- a/docs/clang-tidy/checks/cert-oop11-cpp.rst +++ b/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
-
-cert-oop11-cpp
-==============
-
-The cert-oop11-cpp check is an alias, please see
-`misc-move-constructor-init <misc-move-constructor-init.html>`_ for more
-information.
+.. title:: clang-tidy - cert-oop11-cpp +.. meta:: + :http-equiv=refresh: 5;URL=performance-move-constructor-init.html + +cert-oop11-cpp +============== + +The cert-oop11-cpp check is an alias, please see +`performance-move-constructor-init <performance-move-constructor-init.html>`_ +for more information. diff --git a/docs/clang-tidy/checks/list.rst b/docs/clang-tidy/checks/list.rst index ab740b2b..5c77352c 100644 --- a/docs/clang-tidy/checks/list.rst +++ b/docs/clang-tidy/checks/list.rst @@ -51,7 +51,7 @@ Clang-Tidy Checks 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 @@ Clang-Tidy Checks 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 @@ Clang-Tidy Checks 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 diff --git a/docs/clang-tidy/checks/misc-inefficient-algorithm.rst b/docs/clang-tidy/checks/performance-inefficient-algorithm.rst index 00324876..70027449 100644 --- a/docs/clang-tidy/checks/misc-inefficient-algorithm.rst +++ b/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. diff --git a/docs/clang-tidy/checks/misc-move-constructor-init.rst b/docs/clang-tidy/checks/performance-move-constructor-init.rst index f56c592b..a193b9ee 100644 --- a/docs/clang-tidy/checks/misc-move-constructor-init.rst +++ b/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. diff --git a/test/clang-tidy/cert-oop11-cpp.cpp b/test/clang-tidy/cert-oop11-cpp.cpp index a4493bdc..650d6ec3 100644 --- a/test/clang-tidy/cert-oop11-cpp.cpp +++ b/test/clang-tidy/cert-oop11-cpp.cpp @@ -16,6 +16,6 @@ struct D { // 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) {} }; diff --git a/test/clang-tidy/misc-inefficient-algorithm.cpp b/test/clang-tidy/performance-inefficient-algorithm.cpp index 830c79ca..19a6701c 100644 --- a/test/clang-tidy/misc-inefficient-algorithm.cpp +++ b/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 @@ template <typename T> void f(const T &t) { 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 @@ int main() { // 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 diff --git a/test/clang-tidy/misc-move-constructor-init.cpp b/test/clang-tidy/performance-move-constructor-init.cpp index 104c17ab..c9ed3469 100644 --- a/test/clang-tidy/misc-move-constructor-init.cpp +++ b/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 B { 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 L : K { 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) {} }; |