RedundantStrcatCallsCheck.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //===--- RedundantStrcatCallsCheck.h - clang-tidy----------------*- C++ -*-===//
  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. #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_REDUNDANTSTRCATCALLSCHECK_H
  9. #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_REDUNDANTSTRCATCALLSCHECK_H
  10. #include "../ClangTidyCheck.h"
  11. namespace clang::tidy::abseil {
  12. /// Flags redundant calls to absl::StrCat when the result is being passed to
  13. /// another call of absl::StrCat/absl::StrAppend. Also suggests a fix to
  14. /// collapse the calls.
  15. /// Example:
  16. /// StrCat(1, StrCat(2, 3)) ==> StrCat(1, 2, 3)
  17. ///
  18. /// For the user-facing documentation see:
  19. /// http://clang.llvm.org/extra/clang-tidy/checks/abseil/redundant-strcat-calls.html
  20. class RedundantStrcatCallsCheck : public ClangTidyCheck {
  21. public:
  22. RedundantStrcatCallsCheck(StringRef Name, ClangTidyContext *Context)
  23. : ClangTidyCheck(Name, Context) {}
  24. bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
  25. return LangOpts.CPlusPlus;
  26. }
  27. void registerMatchers(ast_matchers::MatchFinder *Finder) override;
  28. void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
  29. };
  30. } // namespace clang::tidy::abseil
  31. #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_ABSEIL_REDUNDANTSTRCATCALLSCHECK_H