[llvm] r368879 - [DebugLine] Improve path handling.
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 14 10:00:11 PDT 2019
Author: jdevlieghere
Date: Wed Aug 14 10:00:10 2019
New Revision: 368879
URL: http://llvm.org/viewvc/llvm-project?rev=368879&view=rev
Log:
[DebugLine] Improve path handling.
After switching over LLDB's line table parser to libDebugInfo, we
noticed two regressions on the Windows bot. The problem is that when
obtaining a file from the line table prologue, we append paths without
specifying a path style. This leads to incorrect results on Windows for
debug info containing Posix paths:
0x0000000000201000: /tmp\b.c, is_start_of_statement = TRUE
This patch is an attempt to fix that by guessing the path style whenever
possible.
Differential revision: https://reviews.llvm.org/D66227
Modified:
llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp?rev=368879&r1=368878&r2=368879&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp Wed Aug 14 10:00:10 2019
@@ -1041,6 +1041,24 @@ static bool isPathAbsoluteOnWindowsOrPos
sys::path::is_absolute(Path, sys::path::Style::windows);
}
+/// If given an absolute path, guess the path style.
+static sys::path::Style GuessPathStyle(StringRef Path) {
+ bool Posix = sys::path::is_absolute(Path, sys::path::Style::posix);
+ bool Windows = sys::path::is_absolute(Path, sys::path::Style::windows);
+ // This is a relative path.
+ if (!Posix && !Windows)
+ return sys::path::Style::native;
+ // This is a valid absolute path for both Windows and Posix.
+ if (Posix && Windows)
+ return sys::path::Style::native;
+ if (Posix)
+ return sys::path::Style::posix;
+ if (Windows)
+ return sys::path::Style::windows;
+
+ llvm_unreachable("All combinations should have been handled.");
+}
+
bool DWARFDebugLine::Prologue::getFileNameByIndex(uint64_t FileIndex,
StringRef CompDir,
FileLineInfoKind Kind,
@@ -1070,11 +1088,11 @@ bool DWARFDebugLine::Prologue::getFileNa
// 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.empty() && !isPathAbsoluteOnWindowsOrPosix(IncludeDir))
- sys::path::append(FilePath, CompDir);
+ sys::path::append(FilePath, GuessPathStyle(CompDir), CompDir);
}
// sys::path::append skips empty strings.
- sys::path::append(FilePath, IncludeDir, FileName);
+ sys::path::append(FilePath, GuessPathStyle(IncludeDir), IncludeDir, FileName);
Result = FilePath.str();
return true;
}
More information about the llvm-commits
mailing list