File indexing completed on 2026-05-10 08:36:18
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_IMPLICITWIDENINGOFMULTIPLICATIONRESULTCHECK_H
0010 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_IMPLICITWIDENINGOFMULTIPLICATIONRESULTCHECK_H
0011
0012 #include "../ClangTidyCheck.h"
0013 #include "../utils/IncludeInserter.h"
0014 #include <optional>
0015
0016 namespace clang::tidy::bugprone {
0017
0018
0019
0020
0021
0022 class ImplicitWideningOfMultiplicationResultCheck : public ClangTidyCheck {
0023 const ast_matchers::MatchFinder::MatchResult *Result;
0024 bool ShouldUseCXXStaticCast;
0025 bool ShouldUseCXXHeader;
0026
0027 std::optional<FixItHint> includeStddefHeader(SourceLocation File);
0028
0029 void handleImplicitCastExpr(const ImplicitCastExpr *ICE);
0030 void handlePointerOffsetting(const Expr *E);
0031
0032 public:
0033 ImplicitWideningOfMultiplicationResultCheck(StringRef Name,
0034 ClangTidyContext *Context);
0035 void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
0036 Preprocessor *ModuleExpanderPP) override;
0037 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
0038 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
0039 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
0040
0041 private:
0042 const bool UseCXXStaticCastsInCppSources;
0043 const bool UseCXXHeadersInCppSources;
0044 const bool IgnoreConstantIntExpr;
0045 utils::IncludeInserter IncludeInserter;
0046 };
0047
0048 }
0049
0050 #endif