[llvm-bugs] [Bug 52226] New: `-Wbitwise-instead-of-logical` is emitted 4 times for a single `&` operator

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Oct 19 12:34:34 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=52226

            Bug ID: 52226
           Summary: `-Wbitwise-instead-of-logical` is emitted 4 times for
                    a single `&` operator
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

% cat test.mm
// objc/objc.h does this based on __OBJC_BOOL_IS_BOOL, which
// clang/lib/Basic/Targets/AArch64.cpp defines by setting
// `UseSignedCharForObjCBool = false;`.
typedef bool BOOL;
#define YES __objc_yes

@interface Foo
@property(nonatomic, assign) BOOL shouldEnableSave;
- (void)foo;
@end

@implementation Foo
@synthesize shouldEnableSave;
- (void)foo {
  self.shouldEnableSave = [self checkIfValidSite] & [self
checkIfValidPassword];
}
- (BOOL)checkIfValidSite { return YES; }
- (BOOL)checkIfValidPassword { return YES; }
@end



% out/gn/bin/clang -c test.mm --target=arm64-darwin-macos -Wall
test.mm:15:27: warning: use of bitwise '&' with boolean operands
[-Wbitwise-instead-of-logical]
  self.shouldEnableSave = [self checkIfValidSite] & [self
checkIfValidPassword];
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                  &&
test.mm:15:27: note: cast one or both operands to int to silence this warning
test.mm:15:27: warning: use of bitwise '&' with boolean operands
[-Wbitwise-instead-of-logical]
  self.shouldEnableSave = [self checkIfValidSite] & [self
checkIfValidPassword];
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                  &&
test.mm:15:27: note: cast one or both operands to int to silence this warning
test.mm:15:27: warning: use of bitwise '&' with boolean operands
[-Wbitwise-instead-of-logical]
  self.shouldEnableSave = [self checkIfValidSite] & [self
checkIfValidPassword];
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                  &&
test.mm:15:27: note: cast one or both operands to int to silence this warning
test.mm:15:27: warning: use of bitwise '&' with boolean operands
[-Wbitwise-instead-of-logical]
  self.shouldEnableSave = [self checkIfValidSite] & [self
checkIfValidPassword];
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                  &&
test.mm:15:27: note: cast one or both operands to int to silence this warning



This is a great warning, but emitting it once should be sufficient :)

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20211019/7cf8858a/attachment.html>


More information about the llvm-bugs mailing list