Skip to content

Commit a4933f5

Browse files
Revert "[Clang] Extend -Wbool-operation to warn about bitwise and of bools with side effects"
This reverts commit f62d18f. Found some cases in LLVM itself.
1 parent f62d18f commit a4933f5

File tree

6 files changed

+1
-147
lines changed

6 files changed

+1
-147
lines changed

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,7 @@ def StringConversion : DiagGroup<"string-conversion">;
6464
def SignConversion : DiagGroup<"sign-conversion">;
6565
def PointerBoolConversion : DiagGroup<"pointer-bool-conversion">;
6666
def UndefinedBoolConversion : DiagGroup<"undefined-bool-conversion">;
67-
def BitwiseInsteadOfLogical : DiagGroup<"bitwise-instead-of-logical">;
68-
def BoolOperation : DiagGroup<"bool-operation", [BitwiseInsteadOfLogical]>;
67+
def BoolOperation : DiagGroup<"bool-operation">;
6968
def BoolConversion : DiagGroup<"bool-conversion", [PointerBoolConversion,
7069
UndefinedBoolConversion]>;
7170
def IntConversion : DiagGroup<"int-conversion">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ def warn_infinite_recursive_function : Warning<
6666
def warn_comma_operator : Warning<"possible misuse of comma operator here">,
6767
InGroup<DiagGroup<"comma">>, DefaultIgnore;
6868
def note_cast_to_void : Note<"cast expression to void to silence warning">;
69-
def note_cast_operand_to_int : Note<"cast one or both operands to int to silence this warning">;
7069

7170
// Constant expressions
7271
def err_expr_not_ice : Error<
@@ -7424,9 +7423,6 @@ def note_member_declared_here : Note<
74247423
"member %0 declared here">;
74257424
def note_member_first_declared_here : Note<
74267425
"member %0 first declared here">;
7427-
def warn_bitwise_instead_of_logical : Warning<
7428-
"use of bitwise '%0' with boolean operands">,
7429-
InGroup<BitwiseInsteadOfLogical>, DefaultIgnore;
74307426
def warn_bitwise_negation_bool : Warning<
74317427
"bitwise negation of a boolean expression%select{;| always evaluates to 'true';}0 "
74327428
"did you mean logical negation?">,

clang/lib/Sema/SemaChecking.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13249,20 +13249,6 @@ static void AnalyzeImplicitConversions(
1324913249
<< OrigE->getSourceRange() << T->isBooleanType()
1325013250
<< FixItHint::CreateReplacement(UO->getBeginLoc(), "!");
1325113251

13252-
if (const auto *BO = dyn_cast<BinaryOperator>(SourceExpr))
13253-
if ((BO->getOpcode() == BO_And || BO->getOpcode() == BO_Or) &&
13254-
BO->getLHS()->isKnownToHaveBooleanValue() &&
13255-
BO->getRHS()->isKnownToHaveBooleanValue() &&
13256-
BO->getLHS()->HasSideEffects(S.Context) &&
13257-
BO->getRHS()->HasSideEffects(S.Context)) {
13258-
S.Diag(BO->getBeginLoc(), diag::warn_bitwise_instead_of_logical)
13259-
<< (BO->getOpcode() == BO_And ? "&" : "|") << OrigE->getSourceRange()
13260-
<< FixItHint::CreateReplacement(
13261-
BO->getOperatorLoc(),
13262-
(BO->getOpcode() == BO_And ? "&&" : "||"));
13263-
S.Diag(BO->getBeginLoc(), diag::note_cast_operand_to_int);
13264-
}
13265-
1326613252
// For conditional operators, we analyze the arguments as if they
1326713253
// were being fed directly into the output.
1326813254
if (auto *CO = dyn_cast<AbstractConditionalOperator>(SourceExpr)) {

clang/test/Misc/warning-wall.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ RUN: FileCheck --input-file=%t %s
44
CHECK:-Wall
55
CHECK-NEXT: -Wmost
66
CHECK-NEXT: -Wbool-operation
7-
CHECK-NEXT: -Wbitwise-instead-of-logical
87
CHECK-NEXT: -Wchar-subscripts
98
CHECK-NEXT: -Wcomment
109
CHECK-NEXT: -Wdelete-non-virtual-dtor

clang/test/Sema/warn-bitwise-and-bool.c

Lines changed: 0 additions & 63 deletions
This file was deleted.

clang/test/Sema/warn-bitwise-or-bool.c

Lines changed: 0 additions & 63 deletions
This file was deleted.

0 commit comments

Comments
 (0)