diff options
author | Paul Robinson <paul.robinson@sony.com> | 2017-05-02 17:37:32 +0000 |
---|---|---|
committer | Paul Robinson <paul.robinson@sony.com> | 2017-05-02 17:37:32 +0000 |
commit | ba1c91564b69ce6d5cee6524fe6d46f280102ff4 (patch) | |
tree | 4c64d2cac7bba88e7ad3fb35e87beff6f57b63d3 /llvm/lib | |
parent | 705103e523897c2f75a74d047a3b5250b802768a (diff) | |
download | bcm5719-llvm-ba1c91564b69ce6d5cee6524fe6d46f280102ff4.tar.gz bcm5719-llvm-ba1c91564b69ce6d5cee6524fe6d46f280102ff4.zip |
Make DWARFDebugLine use StringRef for directory/file tables. NFC
Differential Revision: http://reviews.llvm.org/D32728
llvm-svn: 301940
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp | 29 | ||||
-rw-r--r-- | llvm/lib/Support/DataExtractor.cpp | 10 |
2 files changed, 23 insertions, 16 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp index 77f3c00cc03..634c431b5da 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -107,25 +107,22 @@ bool DWARFDebugLine::Prologue::parse(DataExtractor DebugLineData, } while (*OffsetPtr < EndPrologueOffset) { - const char *S = DebugLineData.getCStr(OffsetPtr); - if (S && S[0]) - IncludeDirectories.push_back(S); - else + StringRef S = DebugLineData.getCStrRef(OffsetPtr); + if (S.empty()) break; + IncludeDirectories.push_back(S); } while (*OffsetPtr < EndPrologueOffset) { - const char *Name = DebugLineData.getCStr(OffsetPtr); - if (Name && Name[0]) { - FileNameEntry FileEntry; - FileEntry.Name = Name; - FileEntry.DirIdx = DebugLineData.getULEB128(OffsetPtr); - FileEntry.ModTime = DebugLineData.getULEB128(OffsetPtr); - FileEntry.Length = DebugLineData.getULEB128(OffsetPtr); - FileNames.push_back(FileEntry); - } else { + StringRef Name = DebugLineData.getCStrRef(OffsetPtr); + if (Name.empty()) break; - } + FileNameEntry FileEntry; + FileEntry.Name = Name; + FileEntry.DirIdx = DebugLineData.getULEB128(OffsetPtr); + FileEntry.ModTime = DebugLineData.getULEB128(OffsetPtr); + FileEntry.Length = DebugLineData.getULEB128(OffsetPtr); + FileNames.push_back(FileEntry); } if (*OffsetPtr != EndPrologueOffset) { @@ -637,7 +634,7 @@ bool DWARFDebugLine::LineTable::getFileNameByIndex(uint64_t FileIndex, if (Kind == FileLineInfoKind::None || !hasFileAtIndex(FileIndex)) return false; const FileNameEntry &Entry = Prologue.FileNames[FileIndex - 1]; - const char *FileName = Entry.Name; + StringRef FileName = Entry.Name; if (Kind != FileLineInfoKind::AbsoluteFilePath || sys::path::is_absolute(FileName)) { Result = FileName; @@ -646,7 +643,7 @@ bool DWARFDebugLine::LineTable::getFileNameByIndex(uint64_t FileIndex, SmallString<16> FilePath; uint64_t IncludeDirIndex = Entry.DirIdx; - const char *IncludeDir = ""; + StringRef IncludeDir; // Be defensive about the contents of Entry. if (IncludeDirIndex > 0 && IncludeDirIndex <= Prologue.IncludeDirectories.size()) diff --git a/llvm/lib/Support/DataExtractor.cpp b/llvm/lib/Support/DataExtractor.cpp index 5d6d60a87fb..53c10bcc562 100644 --- a/llvm/lib/Support/DataExtractor.cpp +++ b/llvm/lib/Support/DataExtractor.cpp @@ -128,6 +128,16 @@ const char *DataExtractor::getCStr(uint32_t *offset_ptr) const { return nullptr; } +StringRef DataExtractor::getCStrRef(uint32_t *OffsetPtr) const { + uint32_t Start = *OffsetPtr; + StringRef::size_type Pos = Data.find('\0', Start); + if (Pos != StringRef::npos) { + *OffsetPtr = Pos + 1; + return StringRef(Data.data() + Start, Pos - Start); + } + return StringRef(); +} + uint64_t DataExtractor::getULEB128(uint32_t *offset_ptr) const { uint64_t result = 0; if (Data.empty()) |