<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Gotcha. Makes sense.<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Sep 6, 2017, at 11:44 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">The claim is that the index is valid by construction, not because of the input.<br class=""><br class="">This seems to be true - the index comes from a loop over the Prologue.FileNames (offset by 1) & that's the only condition under which getFileNameByIndex returns false. (well, also Kind == None, and that's hardcoded at this callsite)<br class=""><br class="">So I believe there's no possible input file that could cause this function to return 'false', so there's no error path here. (there would be no test that could be written to exercise it, the code would be dead)<br class=""><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Wed, Sep 6, 2017 at 11:10 AM Greg Clayton via Phabricator <<a href="mailto:reviews@reviews.llvm.org" class="">reviews@reviews.llvm.org</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">clayborg added a comment.<br class="">
<br class="">
Why assert and not emit an error???<br class="">
<br class="">
<br class="">
<br class="">
================<br class="">
Comment at: lib/DebugInfo/DWARF/DWARFVerifier.cpp:455<br class="">
+      } else {<br class="">
+        llvm_unreachable("Invalid index?");<br class="">
+      }<br class="">
----------------<br class="">
JDevlieghere wrote:<br class="">
> JDevlieghere wrote:<br class="">
> > dblaikie wrote:<br class="">
> > > Don't branch-to-unreachable. Use an assert instead.<br class="">
> > ><br class="">
> > > Is the false return from getFileNameByIndex really impossible? (has the FileIndex been checked for validity? What other error paths does getFileNameByIndex have, if any?)<br class="">
> > Thanks, an assert definitely better expresses the intent. The only path that returns false is this:<br class="">
> > ```<br class="">
> >   if (Kind == FileLineInfoKind::None || !hasFileAtIndex(FileIndex))<br class="">
> >     return false;<br class="">
> > ```<br class="">
> > The `FileLineInfoKind` is hard-coded so that can't trigger it. The index can't really be invalid either as we're iterating over the list of indices. If this returns false here it must be a programmer error.<br class="">
> What about the unused variable though? I need the function call to populate the string, so I'd have to assign it to a bool that's only used in the assert.<br class="">
This is a verifier that is trying to validate that the DWARF is valid. A bad file index is quite possible. Why not emit an appropriate error message here?<br class="">
<br class="">
<br class="">
Repository:<br class="">
  rL LLVM<br class="">
<br class="">
<a href="https://reviews.llvm.org/D37511" rel="noreferrer" target="_blank" class="">https://reviews.llvm.org/D37511</a><br class="">
<br class="">
<br class="">
<br class="">
</blockquote></div></div>
</div></blockquote></div><br class=""></div></body></html>