[PATCH] D26013: Change DWARF parser to use enumerations for DWARF tags, attributes and forms.

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 26 15:11:40 PDT 2016


On Wed, Oct 26, 2016 at 3:08 PM Adrian Prantl <aprantl at apple.com> wrote:

> aprantl added inline comments.
>
>
> ================
> Comment at: lib/DebugInfo/DWARF/DWARFFormValue.cpp:126
>      return (FC == FC_String);
> +  default:
> +    break;
> ----------------
> Here's an idea: How about adding a
> ```
> template<typename EnumType>
> llvm::Optional<EnumType>
> getULEB128AsEnum() {
>   // Decode ULEB.
>   uint64_t Val = ...; // what about larger values?
>   if (Val >= EnumType::getMinValue() && Val <= EnumType::getMaxValue())
>     return static_cast<EnumType>(Val);
>   return None;
> }
> ```
> ?
>
> This way we could guarantee that on of the enums if it is passed as an
> enum is always well-formed. Then we would never need a default case in a
> switch over a dwarf enum and could benefit from the
> not-all-enum-cases-covered-by-switch warning.
>
> Is that feasible?
>

There's no nice way to get the min/max values of an enum (well, not of the
enumerators - of the representable range, yes - which is actually probably
what we want, but then we still have the issue with switches, etc).

If that makes sense, (see my reply for another way we might be able to deal
with the switch-covered-default warning by adding the enumerator for the
implementation defined range and just never specifying that value in a
switch)

- Dave


>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D26013
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161026/7e731e90/attachment.html>


More information about the llvm-commits mailing list