clang-tools 20.0.0git
ImplicitWideningOfMultiplicationResultCheck.h
Go to the documentation of this file.
1//===--- ImplicitWideningOfMultiplicationResultCheck.h ----------*- 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_BUGPRONE_IMPLICITWIDENINGOFMULTIPLICATIONRESULTCHECK_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_IMPLICITWIDENINGOFMULTIPLICATIONRESULTCHECK_H
11
12#include "../ClangTidyCheck.h"
13#include "../utils/IncludeInserter.h"
14#include <optional>
15
16namespace clang::tidy::bugprone {
17
18/// Diagnoses instances of an implicit widening of multiplication result.
19///
20/// For the user-facing documentation see:
21/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone/implicit-widening-of-multiplication-result.html
23 const ast_matchers::MatchFinder::MatchResult *Result;
24 bool ShouldUseCXXStaticCast;
25 bool ShouldUseCXXHeader;
26
27 std::optional<FixItHint> includeStddefHeader(SourceLocation File);
28
29 void handleImplicitCastExpr(const ImplicitCastExpr *ICE);
30 void handlePointerOffsetting(const Expr *E);
31
32public:
34 ClangTidyContext *Context);
35 void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
36 Preprocessor *ModuleExpanderPP) override;
37 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
38 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
39 void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
40
41private:
42 const bool UseCXXStaticCastsInCppSources;
43 const bool UseCXXHeadersInCppSources;
44 const bool IgnoreConstantIntExpr;
45 utils::IncludeInserter IncludeInserter;
46};
47
48} // namespace clang::tidy::bugprone
49
50#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_IMPLICITWIDENINGOFMULTIPLICATIONRESULTCHECK_H
const Expr * E
llvm::SmallString< 256U > Name
Base class for all clang-tidy checks.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Diagnoses instances of an implicit widening of multiplication result.
void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) override
Override this to register PPCallbacks in the preprocessor.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Produces fixes to insert specified includes to source files, if not yet present.
llvm::StringMap< ClangTidyValue > OptionMap