Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:21

0001 //===--- TypePromotionInMathFnCheck.h - clang-tidy---------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_TYPE_PROMOTION_IN_MATH_FN_H
0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_TYPE_PROMOTION_IN_MATH_FN_H
0011 
0012 #include "../ClangTidyCheck.h"
0013 #include "../utils/IncludeInserter.h"
0014 
0015 namespace clang::tidy::performance {
0016 
0017 /// Finds calls to C math library functions with implicit float to double
0018 /// promotions.
0019 ///
0020 /// For example, warns on ::sin(0.f), because this function's parameter is a
0021 /// double.  You probably meant to call std::sin(0.f) (in C++), or sinf(0.f) (in
0022 /// C).
0023 ///
0024 /// For the user-facing documentation see:
0025 /// http://clang.llvm.org/extra/clang-tidy/checks/performance/type-promotion-in-math-fn.html
0026 class TypePromotionInMathFnCheck : public ClangTidyCheck {
0027 public:
0028   TypePromotionInMathFnCheck(StringRef Name, ClangTidyContext *Context);
0029 
0030   void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
0031                            Preprocessor *ModuleExpanderPP) override;
0032   void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
0033   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
0034   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
0035 
0036 private:
0037   utils::IncludeInserter IncludeInserter;
0038 };
0039 
0040 } // namespace clang::tidy::performance
0041 
0042 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_TYPE_PROMOTION_IN_MATH_FN_H