18b63bfbfSqt-tatiana //===--- UseIntegerSignComparisonCheck.h - clang-tidy -----------*- C++ -*-===// 28b63bfbfSqt-tatiana // 38b63bfbfSqt-tatiana // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 48b63bfbfSqt-tatiana // See https://llvm.org/LICENSE.txt for license information. 58b63bfbfSqt-tatiana // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 68b63bfbfSqt-tatiana // 78b63bfbfSqt-tatiana //===----------------------------------------------------------------------===// 88b63bfbfSqt-tatiana 98b63bfbfSqt-tatiana #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USEINTEGERSIGNCOMPARISONCHECK_H 108b63bfbfSqt-tatiana #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USEINTEGERSIGNCOMPARISONCHECK_H 118b63bfbfSqt-tatiana 128b63bfbfSqt-tatiana #include "../ClangTidyCheck.h" 138b63bfbfSqt-tatiana #include "../utils/IncludeInserter.h" 148b63bfbfSqt-tatiana #include "clang/ASTMatchers/ASTMatchFinder.h" 158b63bfbfSqt-tatiana 168b63bfbfSqt-tatiana namespace clang::tidy::modernize { 178b63bfbfSqt-tatiana 188b63bfbfSqt-tatiana /// Replace comparisons between signed and unsigned integers with their safe 198b63bfbfSqt-tatiana /// C++20 ``std::cmp_*`` alternative, if available. 208b63bfbfSqt-tatiana /// 218b63bfbfSqt-tatiana /// For the user-facing documentation see: 228b63bfbfSqt-tatiana /// http://clang.llvm.org/extra/clang-tidy/checks/modernize/use-integer-sign-comparison.html 238b63bfbfSqt-tatiana class UseIntegerSignComparisonCheck : public ClangTidyCheck { 248b63bfbfSqt-tatiana public: 258b63bfbfSqt-tatiana UseIntegerSignComparisonCheck(StringRef Name, ClangTidyContext *Context); 268b63bfbfSqt-tatiana 278b63bfbfSqt-tatiana void storeOptions(ClangTidyOptions::OptionMap &Opts) override; 288b63bfbfSqt-tatiana void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, 298b63bfbfSqt-tatiana Preprocessor *ModuleExpanderPP) override; 308b63bfbfSqt-tatiana void registerMatchers(ast_matchers::MatchFinder *Finder) override; 318b63bfbfSqt-tatiana void check(const ast_matchers::MatchFinder::MatchResult &Result) override; 328b63bfbfSqt-tatiana bool isLanguageVersionSupported(const LangOptions &LangOpts) const override { 33*aa580c2eSqt-tatiana return LangOpts.CPlusPlus20 || (LangOpts.CPlusPlus17 && EnableQtSupport); 348b63bfbfSqt-tatiana } 358b63bfbfSqt-tatiana 368b63bfbfSqt-tatiana private: 378b63bfbfSqt-tatiana utils::IncludeInserter IncludeInserter; 38*aa580c2eSqt-tatiana const bool EnableQtSupport; 398b63bfbfSqt-tatiana }; 408b63bfbfSqt-tatiana 418b63bfbfSqt-tatiana } // namespace clang::tidy::modernize 428b63bfbfSqt-tatiana 438b63bfbfSqt-tatiana #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USEINTEGERSIGNCOMPARISONCHECK_H 44