[llvm] r369072 - [DebugLine] Don't try to guess the path style
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 15 16:53:15 PDT 2019
Author: jdevlieghere
Date: Thu Aug 15 16:53:15 2019
New Revision: 369072
URL: http://llvm.org/viewvc/llvm-project?rev=369072&view=rev
Log:
[DebugLine] Don't try to guess the path style
In r368879 I made an attempt to guess the path style from the files in
the line table. After some consideration I now think this is a poor
idea. This patch undoes that behavior and instead adds an optional
argument to specify the path style. This allows us to make that decision
elsewhere where we have more information. In case of LLDB based on the
Unit.
Modified:
llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
Modified: llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h?rev=369072&r1=369071&r2=369072&view=diff
==============================================================================
--- llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h (original)
+++ llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h Thu Aug 15 16:53:15 2019
@@ -18,6 +18,7 @@
#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
#include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h"
#include "llvm/Support/MD5.h"
+#include "llvm/Support/Path.h"
#include <cstdint>
#include <map>
#include <string>
@@ -128,9 +129,11 @@ public:
bool hasFileAtIndex(uint64_t FileIndex) const;
- bool getFileNameByIndex(uint64_t FileIndex, StringRef CompDir,
- DILineInfoSpecifier::FileLineInfoKind Kind,
- std::string &Result) const;
+ bool
+ getFileNameByIndex(uint64_t FileIndex, StringRef CompDir,
+ DILineInfoSpecifier::FileLineInfoKind Kind,
+ std::string &Result,
+ sys::path::Style Style = sys::path::Style::native) const;
void clear();
void dump(raw_ostream &OS, DIDumpOptions DumpOptions) const;
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp?rev=369072&r1=369071&r2=369072&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFDebugLine.cpp Thu Aug 15 16:53:15 2019
@@ -16,7 +16,6 @@
#include "llvm/DebugInfo/DWARF/DWARFRelocMap.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Format.h"
-#include "llvm/Support/Path.h"
#include "llvm/Support/WithColor.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
@@ -1041,28 +1040,9 @@ 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,
- std::string &Result) const {
+bool DWARFDebugLine::Prologue::getFileNameByIndex(
+ uint64_t FileIndex, StringRef CompDir, FileLineInfoKind Kind,
+ std::string &Result, sys::path::Style Style) const {
if (Kind == FileLineInfoKind::None || !hasFileAtIndex(FileIndex))
return false;
const FileNameEntry &Entry = getFileNameEntry(FileIndex);
@@ -1088,11 +1068,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, GuessPathStyle(CompDir), CompDir);
+ sys::path::append(FilePath, Style, CompDir);
}
// sys::path::append skips empty strings.
- sys::path::append(FilePath, GuessPathStyle(IncludeDir), IncludeDir, FileName);
+ sys::path::append(FilePath, Style, IncludeDir, FileName);
Result = FilePath.str();
return true;
}
More information about the llvm-commits
mailing list