diff options
author | Jonas Devlieghere <jonas@devlieghere.com> | 2020-01-03 09:30:20 -0800 |
---|---|---|
committer | Jonas Devlieghere <jonas@devlieghere.com> | 2020-01-03 09:53:44 -0800 |
commit | c75aac42a635bf710e818487592ea3bc5d7ef9b1 (patch) | |
tree | 8ea0ad17dcc709850bc8811a912ed0424baa6d62 /llvm/lib/DebugInfo | |
parent | cc0216bedb85642e085a53bf046966fc87dd8afc (diff) | |
download | bcm5719-llvm-c75aac42a635bf710e818487592ea3bc5d7ef9b1.tar.gz bcm5719-llvm-c75aac42a635bf710e818487592ea3bc5d7ef9b1.zip |
[DWARF] Don't assume optional always has a value.
When getting the file name form the line table prologue we assume that a
valid string form value can always be extracted as a string. If you look
at the implementation of DWARFormValue this is not necessarily true. I
hit this assertion from LLDB when I create a "dummy" DWARFContext that
was missing the string section.
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp index 5c86858f31a..51535e88285 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -1026,7 +1026,10 @@ bool DWARFDebugLine::Prologue::getFileNameByIndex( if (Kind == FileLineInfoKind::None || !hasFileAtIndex(FileIndex)) return false; const FileNameEntry &Entry = getFileNameEntry(FileIndex); - StringRef FileName = Entry.Name.getAsCString().getValue(); + Optional<const char *> Name = Entry.Name.getAsCString(); + if (!Name) + return false; + StringRef FileName = *Name; if (Kind != FileLineInfoKind::AbsoluteFilePath || isPathAbsoluteOnWindowsOrPosix(FileName)) { Result = FileName; |