summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
index 1b4341d6d33..bc32b742394 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
@@ -1041,6 +1041,24 @@ static bool isPathAbsoluteOnWindowsOrPosix(const Twine &Path) {
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::getFileNameByIndex(uint64_t FileIndex,
// 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;
}
OpenPOWER on IntegriCloud