10 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_SIMPLIFY_BOOLEAN_EXPR_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_SIMPLIFY_BOOLEAN_EXPR_H
13 #include "../ClangTidy.h"
17 namespace readability {
97 void check(
const ast_matchers::MatchFinder::MatchResult &
Result)
override;
100 void matchBoolBinOpExpr(ast_matchers::MatchFinder *Finder,
bool Value,
101 StringRef OperatorName, StringRef BooleanId);
103 void matchExprBinOpBool(ast_matchers::MatchFinder *Finder,
bool Value,
104 StringRef OperatorName, StringRef BooleanId);
106 void matchBoolCompOpExpr(ast_matchers::MatchFinder *Finder,
bool Value,
107 StringRef OperatorName, StringRef BooleanId);
109 void matchExprCompOpBool(ast_matchers::MatchFinder *Finder,
bool Value,
110 StringRef OperatorName, StringRef BooleanId);
112 void matchBoolCondition(ast_matchers::MatchFinder *Finder,
bool Value,
113 StringRef BooleanId);
115 void matchTernaryResult(ast_matchers::MatchFinder *Finder,
bool Value,
116 StringRef TernaryId);
118 void matchIfReturnsBool(ast_matchers::MatchFinder *Finder,
bool Value,
121 void matchIfAssignsBool(ast_matchers::MatchFinder *Finder,
bool Value,
124 void matchCompoundIfReturnsBool(ast_matchers::MatchFinder *Finder,
bool Value,
128 replaceWithExpression(
const ast_matchers::MatchFinder::MatchResult &Result,
129 const CXXBoolLiteralExpr *BoolLiteral,
bool UseLHS,
130 bool Negated =
false);
133 replaceWithThenStatement(
const ast_matchers::MatchFinder::MatchResult &Result,
134 const CXXBoolLiteralExpr *BoolLiteral);
137 replaceWithElseStatement(
const ast_matchers::MatchFinder::MatchResult &Result,
138 const CXXBoolLiteralExpr *FalseConditionRemoved);
141 replaceWithCondition(
const ast_matchers::MatchFinder::MatchResult &Result,
142 const ConditionalOperator *Ternary,
143 bool Negated =
false);
145 void replaceWithReturnCondition(
146 const ast_matchers::MatchFinder::MatchResult &Result,
const IfStmt *If,
147 bool Negated =
false);
150 replaceWithAssignment(
const ast_matchers::MatchFinder::MatchResult &Result,
151 const IfStmt *If,
bool Negated =
false);
153 void replaceCompoundReturnWithCondition(
154 const ast_matchers::MatchFinder::MatchResult &Result,
155 const CompoundStmt *Compound,
bool Negated =
false);
157 void issueDiag(
const ast_matchers::MatchFinder::MatchResult &Result,
158 SourceLocation
Loc, StringRef Description,
159 SourceRange ReplacementRange, StringRef Replacement);
161 const bool ChainedConditionalReturn;
162 const bool ChainedConditionalAssignment;
169 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_SIMPLIFY_BOOLEAN_EXPR_H
SourceLocation Loc
'#' location in the include directive
std::unique_ptr< ast_matchers::MatchFinder > Finder
void storeOptions(ClangTidyOptions::OptionMap &Options) override
Should store all options supported by this check with their current values or default values for opti...
Looks for boolean expressions involving boolean constants and simplifies them to use the appropriate ...
Base class for all clang-tidy checks.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
SimplifyBooleanExprCheck(StringRef Name, ClangTidyContext *Context)
std::map< std::string, std::string > OptionMap
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register ASTMatchers with Finder.
ClangTidyContext & Context
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.