Index: lld/COFF/PDB.cpp =================================================================== --- lld/COFF/PDB.cpp +++ lld/COFF/PDB.cpp @@ -17,6 +17,7 @@ #include "Writer.h" #include "lld/Common/ErrorHandler.h" #include "lld/Common/Timer.h" +#include "llvm/ADT/Optional.h" #include "llvm/DebugInfo/CodeView/DebugFrameDataSubsection.h" #include "llvm/DebugInfo/CodeView/DebugSubsectionRecord.h" #include "llvm/DebugInfo/CodeView/GlobalTypeTableBuilder.h" @@ -226,9 +227,8 @@ // decide that it's a unix path if we're fairly certain. Specifically, if // it starts with a forward slash. SmallString<128> absoluteFileName = config->pdbSourcePath; - sys::path::Style guessedStyle = absoluteFileName.startswith("/") - ? sys::path::Style::posix - : sys::path::Style::windows; + sys::path::Style guessedStyle = sys::path::guess_style(absoluteFileName) + .getValueOr(sys::path::Style::native); sys::path::append(absoluteFileName, guessedStyle, fileName); sys::path::native(absoluteFileName, guessedStyle); sys::path::remove_dots(absoluteFileName, true, guessedStyle); Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp =================================================================== --- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -204,17 +204,17 @@ static llvm::Optional GetFileByIndex(const llvm::DWARFDebugLine::Prologue &prologue, size_t idx, - llvm::StringRef compile_dir, FileSpec::Style style) { + llvm::StringRef compile_dir) { // Try to get an absolute path first. std::string abs_path; auto absolute = llvm::DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath; - if (prologue.getFileNameByIndex(idx, compile_dir, absolute, abs_path, style)) + if (prologue.getFileNameByIndex(idx, compile_dir, absolute, abs_path)) return std::move(abs_path); // Otherwise ask for a relative path. std::string rel_path; auto relative = llvm::DILineInfoSpecifier::FileLineInfoKind::RawValue; - if (!prologue.getFileNameByIndex(idx, compile_dir, relative, rel_path, style)) + if (!prologue.getFileNameByIndex(idx, compile_dir, relative, rel_path)) return {}; return std::move(rel_path); } @@ -237,7 +237,7 @@ const size_t number_of_files = prologue.FileNames.size(); for (size_t idx = first_file; idx <= number_of_files; ++idx) { std::string remapped_file; - if (auto file_path = GetFileByIndex(prologue, idx, compile_dir, style)) + if (auto file_path = GetFileByIndex(prologue, idx, compile_dir)) if (!module->RemapSourceFile(llvm::StringRef(*file_path), remapped_file)) remapped_file = std::move(*file_path); Index: llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h =================================================================== --- llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h +++ llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h @@ -123,11 +123,9 @@ Optional getLastValidFileIndex() const; - bool - getFileNameByIndex(uint64_t FileIndex, StringRef CompDir, - DILineInfoSpecifier::FileLineInfoKind Kind, - std::string &Result, - sys::path::Style Style = sys::path::Style::native) const; + bool getFileNameByIndex(uint64_t FileIndex, StringRef CompDir, + DILineInfoSpecifier::FileLineInfoKind Kind, + std::string &Result) const; void clear(); void dump(raw_ostream &OS, DIDumpOptions DumpOptions) const; Index: llvm/include/llvm/Support/Path.h =================================================================== --- llvm/include/llvm/Support/Path.h +++ llvm/include/llvm/Support/Path.h @@ -476,6 +476,11 @@ bool remove_dots(SmallVectorImpl &path, bool remove_dot_dot = false, Style style = Style::native); +/// Attempt to guess path style for a given path string. +/// +/// @param path Input path. +llvm::Optional