clang-tools 6.0.0

TypePromotionInMathFnCheck.h
Go to the documentation of this file.
1 //===--- TypePromotionInMathFnCheck.h - clang-tidy---------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_TYPE_PROMOTION_IN_MATH_FN_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_TYPE_PROMOTION_IN_MATH_FN_H
12
13 #include "../ClangTidy.h"
14 #include "../utils/IncludeInserter.h"
15
16 namespace clang {
17 namespace tidy {
18 namespace performance {
19
20 /// Finds calls to C math library functions with implicit float to double
21 /// promotions.
22 ///
23 /// For example, warns on ::sin(0.f), because this funciton's parameter is a
24 /// double. You probably meant to call std::sin(0.f) (in C++), or sinf(0.f) (in
25 /// C).
26 ///
27 /// For the user-facing documentation see:
28 /// http://clang.llvm.org/extra/clang-tidy/checks/performance-type-promotion-in-math-fn.html
29 class TypePromotionInMathFnCheck : public ClangTidyCheck {
30 public:
31 TypePromotionInMathFnCheck(StringRef Name, ClangTidyContext *Context);
32
33 void registerPPCallbacks(CompilerInstance &Compiler) override;
34 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
35 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
36 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
37
38 private:
39 std::unique_ptr<utils::IncludeInserter> IncludeInserter;
40 const utils::IncludeSorter::IncludeStyle IncludeStyle;
41 };
42
43 } // namespace performance
44 } // namespace tidy
45 } // namespace clang
46
47 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_TYPE_PROMOTION_IN_MATH_FN_H
clang::tidy::performance::TypePromotionInMathFnCheck::storeOptions
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
Definition: TypePromotionInMathFnCheck.cpp:46
Name
StringHandle Name
Definition: PreprocessorTracker.cpp:525
clang::tidy::utils::IncludeSorter::IncludeStyle
IncludeStyle
Supported include styles.
Definition: IncludeSorter.h:27
clang::tidy::performance::TypePromotionInMathFnCheck::registerPPCallbacks
void registerPPCallbacks(CompilerInstance &Compiler) override
Override this to register PPCallbacks with Compiler.
Definition: TypePromotionInMathFnCheck.cpp:38
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
clang::tidy::performance::TypePromotionInMathFnCheck::TypePromotionInMathFnCheck
TypePromotionInMathFnCheck(StringRef Name, ClangTidyContext *Context)
Definition: TypePromotionInMathFnCheck.cpp:32
clang::tidy::performance::TypePromotionInMathFnCheck
Finds calls to C math library functions with implicit float to double promotions. ...
Definition: TypePromotionInMathFnCheck.h:29
clang::tidy::ClangTidyOptions::OptionMap
std::map< std::string, std::string > OptionMap
Definition: ClangTidyOptions.h:99
clang::tidy::performance::TypePromotionInMathFnCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: TypePromotionInMathFnCheck.cpp:52
clang
Definition: AndroidTidyModule.cpp:28
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:104
clang::tidy::performance::TypePromotionInMathFnCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: TypePromotionInMathFnCheck.cpp:160