PerformanceTidyModule.cpp 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //===-- PerformanceTidyModule.cpp - clang-tidy ----------------------------===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. #include "../ClangTidy.h"
  9. #include "../ClangTidyModule.h"
  10. #include "../ClangTidyModuleRegistry.h"
  11. #include "FasterStringFindCheck.h"
  12. #include "ForRangeCopyCheck.h"
  13. #include "ImplicitConversionInLoopCheck.h"
  14. #include "InefficientAlgorithmCheck.h"
  15. #include "InefficientStringConcatenationCheck.h"
  16. #include "InefficientVectorOperationCheck.h"
  17. #include "MoveConstArgCheck.h"
  18. #include "MoveConstructorInitCheck.h"
  19. #include "NoAutomaticMoveCheck.h"
  20. #include "NoIntToPtrCheck.h"
  21. #include "NoexceptMoveConstructorCheck.h"
  22. #include "TriviallyDestructibleCheck.h"
  23. #include "TypePromotionInMathFnCheck.h"
  24. #include "UnnecessaryCopyInitialization.h"
  25. #include "UnnecessaryValueParamCheck.h"
  26. namespace clang::tidy {
  27. namespace performance {
  28. class PerformanceModule : public ClangTidyModule {
  29. public:
  30. void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
  31. CheckFactories.registerCheck<FasterStringFindCheck>(
  32. "performance-faster-string-find");
  33. CheckFactories.registerCheck<ForRangeCopyCheck>(
  34. "performance-for-range-copy");
  35. CheckFactories.registerCheck<ImplicitConversionInLoopCheck>(
  36. "performance-implicit-conversion-in-loop");
  37. CheckFactories.registerCheck<InefficientAlgorithmCheck>(
  38. "performance-inefficient-algorithm");
  39. CheckFactories.registerCheck<InefficientStringConcatenationCheck>(
  40. "performance-inefficient-string-concatenation");
  41. CheckFactories.registerCheck<InefficientVectorOperationCheck>(
  42. "performance-inefficient-vector-operation");
  43. CheckFactories.registerCheck<MoveConstArgCheck>(
  44. "performance-move-const-arg");
  45. CheckFactories.registerCheck<MoveConstructorInitCheck>(
  46. "performance-move-constructor-init");
  47. CheckFactories.registerCheck<NoAutomaticMoveCheck>(
  48. "performance-no-automatic-move");
  49. CheckFactories.registerCheck<NoIntToPtrCheck>("performance-no-int-to-ptr");
  50. CheckFactories.registerCheck<NoexceptMoveConstructorCheck>(
  51. "performance-noexcept-move-constructor");
  52. CheckFactories.registerCheck<TriviallyDestructibleCheck>(
  53. "performance-trivially-destructible");
  54. CheckFactories.registerCheck<TypePromotionInMathFnCheck>(
  55. "performance-type-promotion-in-math-fn");
  56. CheckFactories.registerCheck<UnnecessaryCopyInitialization>(
  57. "performance-unnecessary-copy-initialization");
  58. CheckFactories.registerCheck<UnnecessaryValueParamCheck>(
  59. "performance-unnecessary-value-param");
  60. }
  61. };
  62. // Register the PerformanceModule using this statically initialized variable.
  63. static ClangTidyModuleRegistry::Add<PerformanceModule>
  64. X("performance-module", "Adds performance checks.");
  65. } // namespace performance
  66. // This anchor is used to force the linker to link in the generated object file
  67. // and thus register the PerformanceModule.
  68. volatile int PerformanceModuleAnchorSource = 0;
  69. } // namespace clang::tidy