[PATCH] D91651: [clang] Add a warning (à la gcc) for too small enum bitfields

2020-11-25 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added a comment. In D91651#2416423 , @thakis wrote: > Do you have any numbers on false positives / true positives uncovered by this > tweak? That's a great question - and unfortunately not only do I have no hard data to support or discourage the

[PATCH] D91651: [clang] Add a warning (à la gcc) for too small enum bitfields

2020-11-25 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment. Do you have any numbers on false positives / true positives uncovered by this tweak? In general, warning at use time instead of at declaration time tends to be much better for this rate, and we do this differently than gcc in several instances, because the gcc way has so

[PATCH] D91651: [clang] Add a warning (à la gcc) for too small enum bitfields

2020-11-23 Thread Faisal Vali via Phabricator via cfe-commits
faisalv requested review of this revision. faisalv marked 4 inline comments as done. faisalv added a comment. *ping* Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D91651/new/ https://reviews.llvm.org/D91651 _

[PATCH] D91651: [clang] Add a warning (à la gcc) for too small enum bitfields

2020-11-17 Thread Faisal Vali via Phabricator via cfe-commits
faisalv planned changes to this revision. faisalv marked 3 inline comments as done. faisalv added inline comments. Comment at: clang/lib/Sema/SemaDecl.cpp:16443-16446 + const unsigned BitsNeeded = + IsSignedEnum + ? std::max(ED->getNumPositiveBits() + 1

[PATCH] D91651: [clang] Add a warning (à la gcc) for too small enum bitfields

2020-11-17 Thread Faisal Vali via Phabricator via cfe-commits
faisalv updated this revision to Diff 305970. faisalv added a comment. Based on Richards Feedback, this update includes the following changes: - avoids calling the fragile getZextValue() for comparing against bit-field width, and uses APSInt's comparison operator overload - suppresses/avoids the

[PATCH] D91651: [clang] Add a warning (à la gcc) for too small enum bitfields

2020-11-17 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments. Comment at: clang/lib/Sema/SemaDecl.cpp:16443-16446 + const unsigned BitsNeeded = + IsSignedEnum + ? std::max(ED->getNumPositiveBits() + 1, ED->getNumNegativeBits()) + : ED->getNumPositiveBits(); -

[PATCH] D91651: [clang] Add a warning (à la gcc) for too small enum bitfields

2020-11-17 Thread Faisal Vali via Phabricator via cfe-commits
faisalv created this revision. faisalv added reviewers: aaron.ballman, wchilders, bruno, rnk, BRevzin, thakis. faisalv added a project: clang. faisalv requested review of this revision. Currently clang warns on 'assigning' to an enum bit-field that can not accommodate all its enumerators - but no