<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Wed, Oct 26, 2016 at 3:08 PM Adrian Prantl <<a href="mailto:aprantl@apple.com">aprantl@apple.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">aprantl added inline comments.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
================<br class="gmail_msg">
Comment at: lib/DebugInfo/DWARF/DWARFFormValue.cpp:126<br class="gmail_msg">
     return (FC == FC_String);<br class="gmail_msg">
+  default:<br class="gmail_msg">
+    break;<br class="gmail_msg">
----------------<br class="gmail_msg">
Here's an idea: How about adding a<br class="gmail_msg">
```<br class="gmail_msg">
template<typename EnumType><br class="gmail_msg">
llvm::Optional<EnumType><br class="gmail_msg">
getULEB128AsEnum() {<br class="gmail_msg">
  // Decode ULEB.<br class="gmail_msg">
  uint64_t Val = ...; // what about larger values?<br class="gmail_msg">
  if (Val >= EnumType::getMinValue() && Val <= EnumType::getMaxValue())<br class="gmail_msg">
    return static_cast<EnumType>(Val);<br class="gmail_msg">
  return None;<br class="gmail_msg">
}<br class="gmail_msg">
```<br class="gmail_msg">
?<br class="gmail_msg">
<br class="gmail_msg">
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.<br class="gmail_msg">
<br class="gmail_msg">
Is that feasible?<br class="gmail_msg"></blockquote><div><br>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).<br><br>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)<br><br>- Dave<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br class="gmail_msg">
<br class="gmail_msg">
Repository:<br class="gmail_msg">
  rL LLVM<br class="gmail_msg">
<br class="gmail_msg">
<a href="https://reviews.llvm.org/D26013" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D26013</a><br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div></div>