clang-tools  14.0.0git
IntegerTypesCheck.h
Go to the documentation of this file.
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
32 public:
33  IntegerTypesCheck(StringRef Name, ClangTidyContext *Context);
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;
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
clang::tidy::ClangTidyOptions::OptionMap
llvm::StringMap< ClangTidyValue > OptionMap
Definition: ClangTidyOptions.h:115
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidyCheck.h:54
clang::tidy::google::runtime::IntegerTypesCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: IntegerTypesCheck.cpp:55
clang::tidy::ClangTidyCheck::Options
OptionsView Options
Definition: ClangTidyCheck.h:416
clang::tidy::google::runtime::IntegerTypesCheck::storeOptions
void storeOptions(ClangTidyOptions::OptionMap &Options) override
Should store all options supported by this check with their current values or default values for opti...
Definition: IntegerTypesCheck.cpp:49
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:71
Name
static constexpr llvm::StringLiteral Name
Definition: UppercaseLiteralSuffixCheck.cpp:28
clang::tidy::google::runtime::IntegerTypesCheck
Finds uses of short, long and long long and suggest replacing them with u?intXX(_t)?...
Definition: IntegerTypesCheck.h:31
clang::tidy::google::runtime::IntegerTypesCheck::IntegerTypesCheck
IntegerTypesCheck(StringRef Name, ClangTidyContext *Context)
Definition: IntegerTypesCheck.cpp:43
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition: ApplyReplacements.h:27
clang::tidy::google::runtime::IntegerTypesCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: IntegerTypesCheck.cpp:69
clang::tidy::google::runtime::IntegerTypesCheck::isLanguageVersionSupported
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
Override this to disable registering matchers and PP callbacks if an invalid language version is bein...
Definition: IntegerTypesCheck.h:34