9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_NARROWING_CONVERSIONS_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_NARROWING_CONVERSIONS_H
12#include "../ClangTidyCheck.h"
29 void check(
const ast_matchers::MatchFinder::MatchResult &Result)
override;
32 void diagNarrowType(SourceLocation SourceLoc,
const Expr &Lhs,
35 void diagNarrowTypeToSignedInt(SourceLocation SourceLoc,
const Expr &Lhs,
38 void diagNarrowIntegerConstant(SourceLocation SourceLoc,
const Expr &Lhs,
39 const Expr &Rhs,
const llvm::APSInt &Value);
41 void diagNarrowIntegerConstantToSignedInt(SourceLocation SourceLoc,
42 const Expr &Lhs,
const Expr &Rhs,
43 const llvm::APSInt &Value,
44 const uint64_t HexBits);
46 void diagNarrowConstant(SourceLocation SourceLoc,
const Expr &Lhs,
49 void diagConstantCast(SourceLocation SourceLoc,
const Expr &Lhs,
52 void diagNarrowTypeOrConstant(
const ASTContext &Context,
53 SourceLocation SourceLoc,
const Expr &Lhs,
56 void handleIntegralCast(
const ASTContext &Context, SourceLocation SourceLoc,
57 const Expr &Lhs,
const Expr &Rhs);
59 void handleIntegralToBoolean(
const ASTContext &Context,
60 SourceLocation SourceLoc,
const Expr &Lhs,
63 void handleIntegralToFloating(
const ASTContext &Context,
64 SourceLocation SourceLoc,
const Expr &Lhs,
67 void handleFloatingToIntegral(
const ASTContext &Context,
68 SourceLocation SourceLoc,
const Expr &Lhs,
71 void handleFloatingToBoolean(
const ASTContext &Context,
72 SourceLocation SourceLoc,
const Expr &Lhs,
75 void handleBooleanToSignedIntegral(
const ASTContext &Context,
76 SourceLocation SourceLoc,
const Expr &Lhs,
79 void handleFloatingCast(
const ASTContext &Context, SourceLocation SourceLoc,
80 const Expr &Lhs,
const Expr &Rhs);
82 void handleBinaryOperator(
const ASTContext &Context, SourceLocation SourceLoc,
83 const Expr &Lhs,
const Expr &Rhs);
85 bool handleConditionalOperator(
const ASTContext &Context,
const Expr &Lhs,
88 void handleImplicitCast(
const ASTContext &Context,
89 const ImplicitCastExpr &Cast);
91 void handleBinaryOperator(
const ASTContext &Context,
92 const BinaryOperator &Op);
94 bool isWarningInhibitedByEquivalentSize(
const ASTContext &Context,
95 const BuiltinType &FromType,
96 const BuiltinType &ToType)
const;
98 const bool WarnOnIntegerNarrowingConversion;
99 const bool WarnOnIntegerToFloatingPointNarrowingConversion;
100 const bool WarnOnFloatingPointNarrowingConversion;
101 const bool WarnWithinTemplateInstantiation;
102 const bool WarnOnEquivalentBitWidth;
103 const StringRef IgnoreConversionFromTypes;
104 const bool PedanticMode;
llvm::SmallString< 256U > Name
Base class for all clang-tidy checks.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Checks for narrowing conversions, e.g: int i = 0; i += 0.1;.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
llvm::StringMap< ClangTidyValue > OptionMap