[Lldb-commits] [lldb] c4f3f52 - [lldb] Remove FileSpec::GetLastPathComponent
Alex Langford via lldb-commits
lldb-commits at lists.llvm.org
Tue May 2 17:23:03 PDT 2023
Author: Alex Langford
Date: 2023-05-02T17:21:33-07:00
New Revision: c4f3f5225df73cf83042b5e3615549aae0be2422
URL: https://github.com/llvm/llvm-project/commit/c4f3f5225df73cf83042b5e3615549aae0be2422
DIFF: https://github.com/llvm/llvm-project/commit/c4f3f5225df73cf83042b5e3615549aae0be2422.diff
LOG: [lldb] Remove FileSpec::GetLastPathComponent
As far as I can tell, this just computes the filename of the FileSpec,
which is already conveniently stored in m_filename. We can use
FileSpec::GetFilename() instead.
Differential Revision: https://reviews.llvm.org/D149663
Added:
Modified:
lldb/include/lldb/Utility/FileSpec.h
lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
lldb/source/Target/Platform.cpp
lldb/source/Utility/FileSpec.cpp
lldb/source/Utility/XcodeSDK.cpp
Removed:
################################################################################
diff --git a/lldb/include/lldb/Utility/FileSpec.h b/lldb/include/lldb/Utility/FileSpec.h
index 3238bacacb929..919b5e8564583 100644
--- a/lldb/include/lldb/Utility/FileSpec.h
+++ b/lldb/include/lldb/Utility/FileSpec.h
@@ -408,8 +408,6 @@ class FileSpec {
/// A boolean value indicating whether the path was updated.
bool RemoveLastPathComponent();
- ConstString GetLastPathComponent() const;
-
protected:
// Convenience method for setting the file without changing the style.
void SetFile(llvm::StringRef path);
diff --git a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
index 11fee6e4e7b96..937d1482e4ab4 100644
--- a/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+++ b/lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
@@ -623,7 +623,7 @@ size_t ObjectFileELF::GetModuleSpecifications(
if (!gnu_debuglink_crc) {
LLDB_SCOPED_TIMERF(
"Calculating module crc32 %s with size %" PRIu64 " KiB",
- file.GetLastPathComponent().AsCString(),
+ file.GetFilename().AsCString(),
(length - file_offset) / 1024);
// For core files - which usually don't happen to have a
diff --git a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
index 4f1ce5c640513..97f40aef769b4 100644
--- a/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
+++ b/lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp
@@ -166,7 +166,7 @@ static UUID GetCoffUUID(llvm::object::COFFObjectFile &coff_obj) {
auto raw_data = coff_obj.getData();
LLDB_SCOPED_TIMERF(
"Calculating module crc32 %s with size %" PRIu64 " KiB",
- FileSpec(coff_obj.getFileName()).GetLastPathComponent().AsCString(),
+ FileSpec(coff_obj.getFileName()).GetFilename().AsCString(),
static_cast<lldb::offset_t>(raw_data.size()) / 1024);
gnu_debuglink_crc = llvm::crc32(0, llvm::arrayRefFromStringRef(raw_data));
}
@@ -295,7 +295,7 @@ size_t ObjectFilePECOFF::GetModuleSpecifications(
const auto *map = GetGlobalPluginProperties().ModuleABIMap();
if (map->GetNumValues() > 0) {
// Step 1: Try with the exact file name.
- auto name = file.GetLastPathComponent();
+ auto name = file.GetFilename();
module_env_option = map->GetValueForKey(name);
if (!module_env_option) {
// Step 2: Try with the file name in lowercase.
diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index 87586e13fe7a7..76c6b535679a6 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1238,10 +1238,9 @@ lldb_private::Status PlatformDarwin::FindBundleBinaryInExecSearchPaths(
FileSpec platform_pull_upart(platform_file);
std::vector<std::string> path_parts;
- path_parts.push_back(
- platform_pull_upart.GetLastPathComponent().AsCString());
+ path_parts.push_back(platform_pull_upart.GetFilename().AsCString());
while (platform_pull_upart.RemoveLastPathComponent()) {
- ConstString part = platform_pull_upart.GetLastPathComponent();
+ ConstString part = platform_pull_upart.GetFilename();
path_parts.push_back(part.AsCString());
}
const size_t path_parts_size = path_parts.size();
diff --git a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
index 375b171e6d6ce..53c89bd5f618b 100644
--- a/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
+++ b/lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
@@ -1268,7 +1268,7 @@ void StructuredDataDarwinLog::ModulesDidLoad(Process &process,
auto &file_spec = module_sp->GetFileSpec();
found_logging_support_module =
- (file_spec.GetLastPathComponent() == logging_module_name);
+ (file_spec.GetFilename() == logging_module_name);
if (found_logging_support_module)
break;
}
diff --git a/lldb/source/Target/Platform.cpp b/lldb/source/Target/Platform.cpp
index d141d05685d62..eb1fea96c97c1 100644
--- a/lldb/source/Target/Platform.cpp
+++ b/lldb/source/Target/Platform.cpp
@@ -435,7 +435,7 @@ RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft,
// make the new directory and get in there
FileSpec dst_dir = rc_baton->dst;
if (!dst_dir.GetFilename())
- dst_dir.SetFilename(src.GetLastPathComponent());
+ dst_dir.SetFilename(src.GetFilename());
Status error = rc_baton->platform_ptr->MakeDirectory(
dst_dir, lldb::eFilePermissionsDirectoryDefault);
if (error.Fail()) {
diff --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp
index 5ab8e8200a419..6688e45650505 100644
--- a/lldb/source/Utility/FileSpec.cpp
+++ b/lldb/source/Utility/FileSpec.cpp
@@ -429,12 +429,6 @@ FileSpec FileSpec::CopyByRemovingLastPathComponent() const {
return *this;
}
-ConstString FileSpec::GetLastPathComponent() const {
- llvm::SmallString<64> current_path;
- GetPath(current_path, false);
- return ConstString(llvm::sys::path::filename(current_path, m_style));
-}
-
void FileSpec::PrependPathComponent(llvm::StringRef component) {
llvm::SmallString<64> new_path(component);
llvm::SmallString<64> current_path;
diff --git a/lldb/source/Utility/XcodeSDK.cpp b/lldb/source/Utility/XcodeSDK.cpp
index 9e382f1b51087..84f3ccbd01e2d 100644
--- a/lldb/source/Utility/XcodeSDK.cpp
+++ b/lldb/source/Utility/XcodeSDK.cpp
@@ -242,7 +242,7 @@ bool XcodeSDK::SupportsSwift() const {
bool XcodeSDK::SDKSupportsModules(XcodeSDK::Type desired_type,
const FileSpec &sdk_path) {
- ConstString last_path_component = sdk_path.GetLastPathComponent();
+ ConstString last_path_component = sdk_path.GetFilename();
if (!last_path_component)
return false;
More information about the lldb-commits
mailing list