[PATCH] D37511: [dwarfdump] Verify line table prologue
Greg Clayton via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 6 11:10:46 PDT 2017
clayborg added a comment.
Why assert and not emit an error???
================
Comment at: lib/DebugInfo/DWARF/DWARFVerifier.cpp:455
+ } else {
+ llvm_unreachable("Invalid index?");
+ }
----------------
JDevlieghere wrote:
> JDevlieghere wrote:
> > dblaikie wrote:
> > > Don't branch-to-unreachable. Use an assert instead.
> > >
> > > Is the false return from getFileNameByIndex really impossible? (has the FileIndex been checked for validity? What other error paths does getFileNameByIndex have, if any?)
> > Thanks, an assert definitely better expresses the intent. The only path that returns false is this:
> > ```
> > if (Kind == FileLineInfoKind::None || !hasFileAtIndex(FileIndex))
> > return false;
> > ```
> > 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.
> 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.
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?
Repository:
rL LLVM
https://reviews.llvm.org/D37511
More information about the llvm-commits
mailing list