Index: clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp +++ clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp @@ -19,7 +19,9 @@ void SignedBitwiseCheck::registerMatchers(MatchFinder *Finder) { const auto SignedIntegerOperand = - expr(ignoringImpCasts(hasType(isSignedInteger()))).bind("signed-operand"); + expr(ignoringImpCasts(hasType(isSignedInteger())), + unless(integerLiteral())) + .bind("signed-operand"); // The standard [bitmask.types] allows some integral types to be implemented // as signed types. Exclude these types from diagnosing for bitwise or(|) and Index: clang-tools-extra/test/clang-tidy/hicpp-signed-bitwise.cpp =================================================================== --- clang-tools-extra/test/clang-tidy/hicpp-signed-bitwise.cpp +++ clang-tools-extra/test/clang-tidy/hicpp-signed-bitwise.cpp @@ -96,10 +96,8 @@ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use of a signed integer operand with a binary bitwise operator UByte1<<= UByte2; // Ok - int SignedInt1 = 1 << 12; - // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use of a signed integer operand with a binary bitwise operator - int SignedInt2 = 1u << 12; - // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use of a signed integer operand with a binary bitwise operator + int SignedInt1 = 1 << 12; // Ok + int SignedInt2 = 1u << 12; // Ok } void f1(unsigned char c) {} @@ -157,8 +155,7 @@ r = -1 >> -i; // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use of a signed integer operand with a binary bitwise operator - r = ~0; - // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use of a signed integer operand with a unary bitwise operator + r = ~0; // Ok r = ~0u; // Ok k = ~k; // Ok @@ -231,10 +228,8 @@ enum EnumConstruction { one = 1, two = 2, - test1 = 1 << 12, - // CHECK-MESSAGES: [[@LINE-1]]:11: warning: use of a signed integer operand with a binary bitwise operator + test1 = 1 << 12, // Ok test2 = one << two, // CHECK-MESSAGES: [[@LINE-1]]:11: warning: use of a signed integer operand with a binary bitwise operator - test3 = 1u << 12, - // CHECK-MESSAGES: [[@LINE-1]]:11: warning: use of a signed integer operand with a binary bitwise operator + test3 = 1u << 12, // Ok };