UppercaseLiteralSuffixCheck.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. //===--- UppercaseLiteralSuffixCheck.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_UPPERCASELITERALSUFFIXCHECK_H
  9. #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_UPPERCASELITERALSUFFIXCHECK_H
  10. #include "../ClangTidyCheck.h"
  11. #include "../utils/OptionsUtils.h"
  12. namespace clang::tidy::readability {
  13. /// Detects when the integral literal or floating point literal has
  14. /// non-uppercase suffix, and suggests to make the suffix uppercase.
  15. /// Alternatively, a list of destination suffixes can be provided.
  16. ///
  17. /// For the user-facing documentation see:
  18. /// http://clang.llvm.org/extra/clang-tidy/checks/readability/uppercase-literal-suffix.html
  19. class UppercaseLiteralSuffixCheck : public ClangTidyCheck {
  20. public:
  21. UppercaseLiteralSuffixCheck(StringRef Name, ClangTidyContext *Context);
  22. void registerMatchers(ast_matchers::MatchFinder *Finder) override;
  23. void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
  24. void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
  25. std::optional<TraversalKind> getCheckTraversalKind() const override {
  26. return TK_IgnoreUnlessSpelledInSource;
  27. }
  28. private:
  29. template <typename LiteralType>
  30. bool checkBoundMatch(const ast_matchers::MatchFinder::MatchResult &Result);
  31. const std::vector<StringRef> NewSuffixes;
  32. const bool IgnoreMacros;
  33. };
  34. } // namespace clang::tidy::readability
  35. #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_UPPERCASELITERALSUFFIXCHECK_H