• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===--- IntegerTypesCheck.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 
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_INTEGERTYPESCHECK_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_INTEGERTYPESCHECK_H
11 
12 #include "../ClangTidyCheck.h"
13 
14 #include <memory>
15 
16 namespace clang {
17 
18 class IdentifierTable;
19 
20 namespace tidy {
21 namespace google {
22 namespace runtime {
23 
24 /// Finds uses of `short`, `long` and `long long` and suggest replacing them
25 /// with `u?intXX(_t)?`.
26 ///
27 /// Corresponding cpplint.py check: 'runtime/int'.
28 ///
29 /// For the user-facing documentation see:
30 /// http://clang.llvm.org/extra/clang-tidy/checks/google-runtime-int.html
31 class IntegerTypesCheck : public ClangTidyCheck {
32 public:
33   IntegerTypesCheck(StringRef Name, ClangTidyContext *Context);
isLanguageVersionSupported(const LangOptions & LangOpts)34   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
35     return LangOpts.CPlusPlus && !LangOpts.ObjC;
36   }
37   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
38   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
39   void storeOptions(ClangTidyOptions::OptionMap &Options) override;
40 
41 private:
42   const std::string UnsignedTypePrefix;
43   const std::string SignedTypePrefix;
44   const std::string TypeSuffix;
45 
46   std::unique_ptr<IdentifierTable> IdentTable;
47 };
48 
49 } // namespace runtime
50 } // namespace google
51 } // namespace tidy
52 } // namespace clang
53 
54 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_INTEGERTYPESCHECK_H
55