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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

% 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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to