RedundantStringCStrCheck.h 1.2 KB

123456789101112131415161718192021222324252627282930
  1. //===--- RedundantStringCStrCheck.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_READABILITY_REDUNDANTSTRINGCSTRCHECK_H
  9. #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANTSTRINGCSTRCHECK_H
  10. #include "../ClangTidyCheck.h"
  11. namespace clang::tidy::readability {
  12. /// Finds unnecessary calls to `std::string::c_str()`.
  13. class RedundantStringCStrCheck : public ClangTidyCheck {
  14. public:
  15. RedundantStringCStrCheck(StringRef Name, ClangTidyContext *Context)
  16. : ClangTidyCheck(Name, Context) {}
  17. bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
  18. return LangOpts.CPlusPlus;
  19. }
  20. void registerMatchers(ast_matchers::MatchFinder *Finder) override;
  21. void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
  22. };
  23. } // namespace clang::tidy::readability
  24. #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANTSTRINGCSTRCHECK_H