Getting number of possible values for an enum

Hi,

I am trying to fix a bug in a clang-tidy check. This is the bug: https://bugs.llvm.org/show_bug.cgi?id=42929 . The problem is that when this code tries to find the amount of possible enum values it just asks Context.getTypeSize(T) on QualType T. In this case the enum is treated as 32-bit integer and will return the wrong result.

I would like to know how a find the maximum amount of possible values for an enum. Can anyone help me out?

Best regards,
Mads Ravn