[clang-tidy] Fix bug 34845, offending standard bitmask types
authorJonas Toth <jonas.toth@gmail.com>
Fri, 27 Oct 2017 14:44:08 +0000 (14:44 +0000)
committerJonas Toth <jonas.toth@gmail.com>
Fri, 27 Oct 2017 14:44:08 +0000 (14:44 +0000)
commit8ba28c720091c9f99d0bd14c5fdf5981b65f28b8
tree6a4a10e140a3c117ad7a0305aca337068f88e0d9
parent822dfe271becad81173ccd398a7098cc81546223
[clang-tidy] Fix bug 34845, offending standard bitmask types

Summary:
The C++ standard allows implementations to choose the underlying type for
bitmask types (e.g. std::ios_base::openmode). MSVC implemented some of them
as signed integers resulting in warnings for usual code like
`auto dd = std::ios_base::badbit | std::ios_base::failbit;`

These false positives were reported in https://bugs.llvm.org/show_bug.cgi?id=34845

The fix allows bitwise |,&,^ for known standard bitmask types under the condition
that both operands are such bitmask types.
Shifting and bitwise complement are still forbidden.

Reviewers: aaron.ballman, alexfh, hokein

Reviewed By: aaron.ballman

Subscribers: xazax.hun

Differential Revision: https://reviews.llvm.org/D39099

llvm-svn: 316767
clang-tools-extra/clang-tidy/hicpp/SignedBitwiseCheck.cpp
clang-tools-extra/test/clang-tidy/hicpp-signed-bitwise-standard-types.cpp [new file with mode: 0644]
clang-tools-extra/test/clang-tidy/hicpp-signed-bitwise-standard-types.h [new file with mode: 0644]