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
30 public:
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
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
StringHandle Name
IncludeStyle
Supported include styles.
Definition: IncludeSorter.h:27
void registerPPCallbacks(CompilerInstance &Compiler) override
Override this to register PPCallbacks with Compiler.
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
TypePromotionInMathFnCheck(StringRef Name, ClangTidyContext *Context)
Finds calls to C math library functions with implicit float to double promotions. ...
std::map< std::string, std::string > OptionMap
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.