[Clang] Fix how we set the NumPositiveBits on an EnumDecl to cover the case of single...
authorShafik Yaghmour <shafik.yaghmour@intel.com>
Mon, 25 Jul 2022 22:56:44 +0000 (15:56 -0700)
committerShafik Yaghmour <shafik.yaghmour@intel.com>
Mon, 25 Jul 2022 23:01:01 +0000 (16:01 -0700)
commitaea82d4551139ded0290afab739f0b367d055628
treefc099af9d0d2987bbc86e283b18a69901d90fc43
parent45944e7cf45915eb2a0a2fae24e3396fc91dfc22
[Clang] Fix how we set the NumPositiveBits on an EnumDecl to cover the case of single enumerator with value zero or an empty enum

Currently in Sema::ActOnEnumBody(...) when calculating NumPositiveBits we miss
the case where there is only a single enumerator with value zero and the case of
an empty enum. In both cases we end up with zero positive bits when in fact we
need one bit to store the value zero.

This PR updates the calculation to account for these cases.

Differential Revision: https://reviews.llvm.org/D130301
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaDecl.cpp
clang/test/CodeGenCXX/pr12251.cpp
compiler-rt/test/ubsan/TestCases/Misc/enum.cpp