Debian Codegraph @

clang-tools-extra/clang-tidy/modernize/UseStdNumbersCheck.h

raw
1 //===--- UseStdNumbersCheck.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_MODERNIZE_USESTDNUMBERSCHECK_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USESTDNUMBERSCHECK_H
11
12 #include "../ClangTidyCheck.h"
13 #include "../utils/IncludeInserter.h"
14
15 namespace clang::tidy::modernize {
16
17 /// Finds constants and function calls to math functions that can be replaced
18 /// with c++20's mathematical constants from the ``numbers`` header and
19 /// offers fix-it hints.
20 /// Does not match the use of variables with that value, and instead,
21 /// offers a replacement at the definition of those variables.
22 ///
23 /// For the user-facing documentation see:
24 /// http://clang.llvm.org/extra/clang-tidy/checks/modernize/use-std-numbers.html
25 class UseStdNumbersCheck : public ClangTidyCheck {
26 public:
27 UseStdNumbersCheck(StringRef Name, ClangTidyContext *Context);
28
29 bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
30 return LangOpts.CPlusPlus20;
31 }
32 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
33 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
34 void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
35 Preprocessor *ModuleExpanderPP) override;
36 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
37 std::optional<TraversalKind> getCheckTraversalKind() const override {
38 return TK_IgnoreUnlessSpelledInSource;
39 }
40
41 private:
42 utils::IncludeInserter IncludeInserter;
43 StringRef DiffThresholdString;
44 double DiffThreshold;
45 };
46
47 } // namespace clang::tidy::modernize
48
49 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USESTDNUMBERSCHECK_H