brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · aca7ae1 Raw
37 lines · cpp
1// RUN: %check_clang_tidy %s hicpp-signed-bitwise %t -- \2// RUN:   -config="{CheckOptions: {hicpp-signed-bitwise.IgnorePositiveIntegerLiterals: true}}" \3// RUN: -- -std=c++114 5void examples() {6  unsigned UValue = 40u;7  unsigned URes;8 9  URes = UValue & 1u; //Ok10  URes = UValue & -1;11  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use of a signed integer operand with a binary bitwise operator12 13  unsigned URes2 = URes << 1; //Ok14  unsigned URes3 = URes & 1; //Ok15 16  int IResult;17  IResult = 10 & 2; //Ok18  IResult = 3 << -1;19  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: use of a signed integer operand with a binary bitwise operator20 21  int Int = 30;22  IResult = Int << 1;23  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator24  IResult = ~0; //Ok25  IResult = -1 & 1;26  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise]27}28 29enum EnumConstruction {30  one = 1,31  two = 2,32  test1 = 1 << 12, //Ok33  test2 = one << two,34  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: use of a signed integer operand with a binary bitwise operator35  test3 = 1u << 12, //Ok36};37