[Lldb-commits] [PATCH] D35036: switch on enum should be exhaustive and warning-free

Stephane Sezer via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed Jul 5 22:10:01 PDT 2017


sas accepted this revision.
sas added a comment.
This revision is now accepted and ready to land.

Looks like the numeric values of `TypeCode` are contiguous. It would probably be cleaner to a check after the cast to validate the value instead of having to add a line for each label in the `switch` statement. Something like this:

  if (type_code < TypeCodes::sint8 || type_code > TypeCodes::sint128)
      return false;

You could also add `TypeCodesBegin = -1` and `TypeCodesEnd` as the first and last enumerations of `TypeCodes` so the above check would not have to be modified when you change the definition of `TypeCodes`.

Other than that, looks good.


https://reviews.llvm.org/D35036





More information about the lldb-commits mailing list