[PATCH] D44290: Handle mixed-OS paths in DWARF reader
Eugene Zemtsov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 8 23:58:28 PST 2018
eugene created this revision.
eugene added reviewers: probinson, zturner, labath.
Herald added subscribers: JDevlieghere, aprantl.
Make sure that DWARF line information generated by Windows can be properly read by Posix OS and vice versa.
Repository:
rL LLVM
https://reviews.llvm.org/D44290
Files:
lib/DebugInfo/DWARF/DWARFDebugLine.cpp
Index: lib/DebugInfo/DWARF/DWARFDebugLine.cpp
===================================================================
--- lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -956,6 +956,15 @@
return None;
}
+static
+bool isPathAbsoluteOnWindowsOrPosix(const Twine &Path) {
+ // Debug info can contain paths from any OS, not necessarily
+ // an OS we're currently running on. Moreover different compilation units can
+ // be compiled on different operating systems and linked together later.
+ return sys::path::is_absolute(Path, sys::path::Style::posix) ||
+ sys::path::is_absolute(Path, sys::path::Style::windows);
+}
+
bool DWARFDebugLine::LineTable::getFileNameByIndex(uint64_t FileIndex,
const char *CompDir,
FileLineInfoKind Kind,
@@ -965,7 +974,7 @@
const FileNameEntry &Entry = Prologue.FileNames[FileIndex - 1];
StringRef FileName = Entry.Name.getAsCString().getValue();
if (Kind != FileLineInfoKind::AbsoluteFilePath ||
- sys::path::is_absolute(FileName)) {
+ isPathAbsoluteOnWindowsOrPosix(FileName)) {
Result = FileName;
return true;
}
@@ -984,7 +993,7 @@
// We know that FileName is not absolute, the only way to have an
// absolute path at this point would be if IncludeDir is absolute.
if (CompDir && Kind == FileLineInfoKind::AbsoluteFilePath &&
- sys::path::is_relative(IncludeDir))
+ !isPathAbsoluteOnWindowsOrPosix(IncludeDir))
sys::path::append(FilePath, CompDir);
// sys::path::append skips empty strings.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44290.137701.patch
Type: text/x-patch
Size: 1640 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180309/2b4a855f/attachment.bin>
More information about the llvm-commits
mailing list