This is an archive of the discontinued LLVM Phabricator instance.

Wbitfiled-constant-conversion : allow ~0 , ~(1<<A), etc
ClosedPublic

Authored by danielmarjamaki on Sep 5 2016, 6:59 AM.

Details

Summary

To set all bits,~0 is often used.

x.y = ~0;

and to set all bits except (1<<A) this is often used:

x.y = ~(1 << A);

.. do not warn about these.

I think it might make sense to warn about the opposite:

x.y = ~0xffffffff;

But that is a possible false negative for now.

I believe this is somewhat related to r277796.

Diff Detail

Repository
rL LLVM

Event Timeline

danielmarjamaki retitled this revision from to Wbitfiled-constant-conversion : allow ~0 , ~(1<<A), etc.
danielmarjamaki updated this object.
danielmarjamaki added a reviewer: rtrieu.
This revision was automatically updated to reflect the committed changes.