InefficientStringConcatenationCheck.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //===--- InefficientStringConcatenationCheck.h - clang-tidy-----------*- C++
  2. //-*-===//
  3. //
  4. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5. // See https://llvm.org/LICENSE.txt for license information.
  6. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7. //
  8. //===----------------------------------------------------------------------===//
  9. #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_INEFFICIENTSTRINGCONCATENATION_H
  10. #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_INEFFICIENTSTRINGCONCATENATION_H
  11. #include "../ClangTidyCheck.h"
  12. namespace clang::tidy::performance {
  13. /// This check is to warn about the performance overhead arising from
  14. /// concatenating strings, using the operator+, instead of operator+=.
  15. ///
  16. /// For the user-facing documentation see:
  17. /// http://clang.llvm.org/extra/clang-tidy/checks/performance/inefficient-string-concatenation.html
  18. class InefficientStringConcatenationCheck : public ClangTidyCheck {
  19. public:
  20. InefficientStringConcatenationCheck(StringRef Name,
  21. ClangTidyContext *Context);
  22. bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
  23. return LangOpts.CPlusPlus;
  24. }
  25. void registerMatchers(ast_matchers::MatchFinder *Finder) override;
  26. void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
  27. void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
  28. private:
  29. const bool StrictMode;
  30. };
  31. } // namespace clang::tidy::performance
  32. #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_INEFFICIENTSTRINGCONCATENATION_H