9#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_SIMPLIFY_BOOLEAN_EXPR_H
10#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_SIMPLIFY_BOOLEAN_EXPR_H
12#include "../ClangTidyCheck.h"
27 void check(
const ast_matchers::MatchFinder::MatchResult &Result)
override;
29 return TK_IgnoreUnlessSpelledInSource;
35 void reportBinOp(
const ASTContext &Context,
const BinaryOperator *Op);
37 void replaceWithThenStatement(
const ASTContext &Context,
38 const IfStmt *IfStatement,
39 const Expr *BoolLiteral);
41 void replaceWithElseStatement(
const ASTContext &Context,
42 const IfStmt *IfStatement,
43 const Expr *BoolLiteral);
45 void replaceWithCondition(
const ASTContext &Context,
46 const ConditionalOperator *Ternary,
bool Negated);
48 void replaceWithReturnCondition(
const ASTContext &Context,
const IfStmt *If,
49 const Expr *BoolLiteral,
bool Negated);
51 void replaceWithAssignment(
const ASTContext &Context,
const IfStmt *If,
52 const Expr *Var, SourceLocation
Loc,
bool Negated);
54 void replaceCompoundReturnWithCondition(
const ASTContext &Context,
55 const ReturnStmt *Ret,
bool Negated,
57 const Expr *ThenReturn);
59 bool reportDeMorgan(
const ASTContext &Context,
const UnaryOperator *Outer,
60 const BinaryOperator *
Inner,
bool TryOfferFix,
61 const Stmt *
Parent,
const ParenExpr *Parens);
63 void issueDiag(
const ASTContext &Result, SourceLocation
Loc,
64 StringRef Description, SourceRange ReplacementRange,
65 StringRef Replacement);
67 const bool ChainedConditionalReturn;
68 const bool ChainedConditionalAssignment;
69 const bool SimplifyDeMorgan;
70 const bool SimplifyDeMorganRelaxed;
std::pair< Context, Canceler > Inner
Base class for all clang-tidy checks.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Looks for boolean expressions involving boolean constants and simplifies them to use the appropriate ...
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
void storeOptions(ClangTidyOptions::OptionMap &Options) override
Should store all options supported by this check with their current values or default values for opti...
std::optional< TraversalKind > getCheckTraversalKind() const override
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
llvm::StringMap< ClangTidyValue > OptionMap