Skip to content

Commit 52844e3

Browse files
committed
No parentheses for single stmt ifs
1 parent 14dcf62 commit 52844e3

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

clang-tools-extra/clang-tidy/misc/BoolBitwiseOperationCheck.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,15 @@ static bool assignsToBoolean(const BinaryOperator *BinOp, ASTContext *AC) {
3939
// Special handling for `template<bool bb=true|1>` cases
4040
if (const auto *D = ParentNoParen->get<Decl>()) {
4141
if (const auto *NTTPD = dyn_cast<NonTypeTemplateParmDecl>(D)) {
42-
if (NTTPD->getType()->isBooleanType()) {
42+
if (NTTPD->getType()->isBooleanType())
4343
return true;
44-
}
4544
}
4645
}
4746

4847
if (const auto *S = ParentNoParen->get<Stmt>()) {
4948
if (const auto *ICE = dyn_cast<ImplicitCastExpr>(S)) {
50-
if (ICE->getType()->isBooleanType()) {
49+
if (ICE->getType()->isBooleanType())
5150
return true;
52-
}
5351
}
5452
}
5553
}
@@ -79,9 +77,8 @@ constexpr std::array<std::pair<llvm::StringRef, llvm::StringRef>, 8U>
7977

8078
static llvm::StringRef translate(llvm::StringRef Value) {
8179
for (const auto &[Bitwise, Logical] : OperatorsTransformation) {
82-
if (Value == Bitwise) {
80+
if (Value == Bitwise)
8381
return Logical;
84-
}
8582
}
8683

8784
return {};
@@ -235,13 +232,11 @@ void BoolBitwiseOperationCheck::visitBinaryTreesNode(
235232
const BinaryOperator *BinOp, const BinaryOperator *ParentBinOp,
236233
const clang::SourceManager &SM, clang::ASTContext &Ctx,
237234
std::optional<bool>& rootAssignsToBoolean) {
238-
if (!BinOp) {
235+
if (!BinOp)
239236
return;
240-
}
241237

242-
if (isBooleanBitwise(BinOp, &Ctx, rootAssignsToBoolean)) {
238+
if (isBooleanBitwise(BinOp, &Ctx, rootAssignsToBoolean))
243239
emitWarningAndChangeOperatorsIfPossible(BinOp, ParentBinOp, SM, Ctx);
244-
}
245240

246241
visitBinaryTreesNode(
247242
dyn_cast<BinaryOperator>(BinOp->getLHS()->IgnoreParenImpCasts()), BinOp,

0 commit comments

Comments
 (0)