1bc8cff1dSNicolas van Kempen //===--- UseStartsEndsWithCheck.h - clang-tidy ------------------*- C++ -*-===// 2bc8cff1dSNicolas van Kempen // 3bc8cff1dSNicolas van Kempen // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4bc8cff1dSNicolas van Kempen // See https://llvm.org/LICENSE.txt for license information. 5bc8cff1dSNicolas van Kempen // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6bc8cff1dSNicolas van Kempen // 7bc8cff1dSNicolas van Kempen //===----------------------------------------------------------------------===// 8bc8cff1dSNicolas van Kempen 9bc8cff1dSNicolas van Kempen #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USESTARTSENDSWITHCHECK_H 10bc8cff1dSNicolas van Kempen #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USESTARTSENDSWITHCHECK_H 11bc8cff1dSNicolas van Kempen 12bc8cff1dSNicolas van Kempen #include "../ClangTidyCheck.h" 13bc8cff1dSNicolas van Kempen 14bc8cff1dSNicolas van Kempen namespace clang::tidy::modernize { 15bc8cff1dSNicolas van Kempen 16ef590698SNicolas van Kempen /// Checks for common roundabout ways to express ``starts_with`` and 17*f1367a47SNicolas van Kempen /// ``ends_with`` and suggests replacing with the simpler method when it is 18ef590698SNicolas van Kempen /// available. Notably, this will work with ``std::string`` and 19ef590698SNicolas van Kempen /// ``std::string_view``. 20bc8cff1dSNicolas van Kempen /// 21bc8cff1dSNicolas van Kempen /// For the user-facing documentation see: 22bc8cff1dSNicolas van Kempen /// http://clang.llvm.org/extra/clang-tidy/checks/modernize/use-starts-ends-with.html 23bc8cff1dSNicolas van Kempen class UseStartsEndsWithCheck : public ClangTidyCheck { 24bc8cff1dSNicolas van Kempen public: 25bc8cff1dSNicolas van Kempen UseStartsEndsWithCheck(StringRef Name, ClangTidyContext *Context); 26bc8cff1dSNicolas van Kempen void registerMatchers(ast_matchers::MatchFinder *Finder) override; 27bc8cff1dSNicolas van Kempen void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 28bc8cff1dSNicolas van Kempen bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { 29bc8cff1dSNicolas van Kempen return LangOpts.CPlusPlus; 30bc8cff1dSNicolas van Kempen } 31bc8cff1dSNicolas van Kempen std::optional<TraversalKind> getCheckTraversalKind() const override { 32bc8cff1dSNicolas van Kempen return TK_IgnoreUnlessSpelledInSource; 33bc8cff1dSNicolas van Kempen } 34bc8cff1dSNicolas van Kempen }; 35bc8cff1dSNicolas van Kempen 36bc8cff1dSNicolas van Kempen } // namespace clang::tidy::modernize 37bc8cff1dSNicolas van Kempen 38bc8cff1dSNicolas van Kempen #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USESTARTSENDSWITHCHECK_H 39