[PATCH] D68694: [clang-tidy] hicpp-signed-bitwise: Do not show "use of a signed integer operand with a binary bitwise operator" for positive integer operands

Vladimir Plyashkun via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 11 08:14:30 PDT 2019


vladimir.plyashkun marked 2 inline comments as done.
vladimir.plyashkun added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp:23-24
+    : ClangTidyCheck(Name, Context),
+      IgnorePositiveIntegerLiterals(
+          Options.getLocalOrGlobal("IgnorePositiveIntegerLiterals", false)) {}
+
----------------
lebedev.ri wrote:
> vladimir.plyashkun wrote:
> > lebedev.ri wrote:
> > > i'm not sure this should look for a global option with such name?
> > I think that this method is common and used in so many inspections. 
> > For example this [[ https://clang.llvm.org/extra/clang-tidy/checks/readability-inconsistent-declaration-parameter-name.html  | check ]] also have option called `IgnoreMacros` which is retrieved in same way (by calling getLocalOrGlobal method)
> I'm very specifically discriminating against `"IgnorePositiveIntegerLiterals"` here.
> I know `getLocalOrGlobal()` is widely used, because in those places the same flag
> is used in multiple modules with same meaning.
> Is that the case here?
Ok, i agree. Fixed.


================
Comment at: clang-tools-extra/test/clang-tidy/hicpp-signed-bitwise-integer-literals.cpp:19
+  int Int = 30;
+  IResult = Int << 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
----------------
JonasToth wrote:
> Could you please add `URes << 1` as well? I believe that was problematic in the stack-overflow-question, wasn't it?
Yes, sure.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68694/new/

https://reviews.llvm.org/D68694





More information about the cfe-commits mailing list