[Lldb-commits] [PATCH] D104724: Modernize Module::RemapFile to return an Optional
Adrian Prantl via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 22 10:16:00 PDT 2021
aprantl created this revision.
aprantl added reviewers: shafik, JDevlieghere.
aprantl requested review of this revision.
This addresses feedback raised in https://reviews.llvm.org/D104404.
https://reviews.llvm.org/D104724
Files:
lldb/include/lldb/Core/Module.h
lldb/source/Core/Module.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Index: lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
===================================================================
--- lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -240,9 +240,12 @@
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 (!module->RemapSourceFile(llvm::StringRef(*file_path), remapped_file))
+ if (auto file_path = GetFileByIndex(prologue, idx, compile_dir, style)) {
+ if (auto remapped = module->RemapSourceFile(llvm::StringRef(*file_path)))
+ remapped_file = *remapped;
+ else
remapped_file = std::move(*file_path);
+ }
// Unconditionally add an entry, so the indices match up.
support_files.EmplaceBack(remapped_file, style);
@@ -681,9 +684,8 @@
// files are NFS mounted.
file_spec.MakeAbsolute(dwarf_cu.GetCompilationDirectory());
- std::string remapped_file;
- if (module_sp->RemapSourceFile(file_spec.GetPath(), remapped_file))
- file_spec.SetFile(remapped_file, FileSpec::Style::native);
+ if (auto remapped_file = module_sp->RemapSourceFile(file_spec.GetPath()))
+ file_spec.SetFile(*remapped_file, FileSpec::Style::native);
}
lldb::CompUnitSP SymbolFileDWARF::ParseCompileUnit(DWARFCompileUnit &dwarf_cu) {
Index: lldb/source/Core/Module.cpp
===================================================================
--- lldb/source/Core/Module.cpp
+++ lldb/source/Core/Module.cpp
@@ -1605,14 +1605,11 @@
return false;
}
-bool Module::RemapSourceFile(llvm::StringRef path,
- std::string &new_path) const {
+llvm::Optional<std::string> Module::RemapSourceFile(llvm::StringRef path) const {
std::lock_guard<std::recursive_mutex> guard(m_mutex);
- if (auto remapped = m_source_mappings.RemapPath(path)) {
- new_path = remapped->GetPath();
- return true;
- }
- return false;
+ if (auto remapped = m_source_mappings.RemapPath(path))
+ return remapped->GetPath();
+ return {};
}
void Module::RegisterXcodeSDK(llvm::StringRef sdk_name, llvm::StringRef sysroot) {
Index: lldb/include/lldb/Core/Module.h
===================================================================
--- lldb/include/lldb/Core/Module.h
+++ lldb/include/lldb/Core/Module.h
@@ -850,13 +850,10 @@
/// \param[in] path
/// The original source file path to try and remap.
///
- /// \param[out] new_path
- /// The newly remapped filespec that is may or may not exist.
- ///
/// \return
- /// /b true if \a path was successfully located and \a new_path
- /// is filled in with a new source path, \b false otherwise.
- bool RemapSourceFile(llvm::StringRef path, std::string &new_path) const;
+ /// The newly remapped filespec that is may or may not exist if
+ /// \a path was successfully located.
+ llvm::Optional<std::string> RemapSourceFile(llvm::StringRef path) const;
bool RemapSourceFile(const char *, std::string &) const = delete;
/// Update the ArchSpec to a more specific variant.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104724.353695.patch
Type: text/x-patch
Size: 3221 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210622/2bdd8641/attachment.bin>
More information about the lldb-commits
mailing list