bulbazord created this revision. bulbazord added reviewers: JDevlieghere, mib, jingham, jasonmolenda. Herald added a subscriber: emaste. Herald added a project: All. bulbazord requested review of this revision. Herald added subscribers: lldb-commits, MaskRay. Herald added a project: LLDB.
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. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D149663 Files: 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
Index: lldb/source/Utility/XcodeSDK.cpp =================================================================== --- lldb/source/Utility/XcodeSDK.cpp +++ lldb/source/Utility/XcodeSDK.cpp @@ -242,7 +242,7 @@ 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; Index: lldb/source/Utility/FileSpec.cpp =================================================================== --- lldb/source/Utility/FileSpec.cpp +++ lldb/source/Utility/FileSpec.cpp @@ -429,12 +429,6 @@ 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; Index: lldb/source/Target/Platform.cpp =================================================================== --- lldb/source/Target/Platform.cpp +++ lldb/source/Target/Platform.cpp @@ -435,7 +435,7 @@ // 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()) { Index: lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp =================================================================== --- lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp +++ lldb/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp @@ -1268,7 +1268,7 @@ 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; } Index: lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp =================================================================== --- lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -1238,10 +1238,9 @@ 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(); Index: lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp =================================================================== --- lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ lldb/source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -166,7 +166,7 @@ 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 @@ 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. Index: lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp =================================================================== --- lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp +++ lldb/source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp @@ -623,7 +623,7 @@ 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 Index: lldb/include/lldb/Utility/FileSpec.h =================================================================== --- lldb/include/lldb/Utility/FileSpec.h +++ lldb/include/lldb/Utility/FileSpec.h @@ -408,8 +408,6 @@ /// 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);
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits