[lldb] Introduce FileSpec::GetComponents
authorAlex Langford <alangford@apple.com>
Thu, 25 May 2023 02:42:15 +0000 (19:42 -0700)
committerAlex Langford <alangford@apple.com>
Tue, 30 May 2023 22:13:17 +0000 (15:13 -0700)
commit57154a63a07f732552968141136279350bcdf99d
treed1b5a58e5fb343612c551be6e8dda8ee499f5f7d
parent454163354b0b2755746f9b3c32059adff4d34bd3
[lldb] Introduce FileSpec::GetComponents

This patch introduces FileSpec::GetComponents, a method that splits a
FileSpec's path into its individual components. For example, given
/foo/bar/baz, you'll get back a vector of strings {"foo", "bar", baz"}.

The motivation here is to reduce the use of
`FileSpec::RemoveLastPathComponent`. Mutating a FileSpec is expensive,
so providing a way of doing this without mutation is useful.

Differential Revision: https://reviews.llvm.org/D151399
lldb/include/lldb/Utility/FileSpec.h
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
lldb/source/Utility/FileSpec.cpp
lldb/unittests/Utility/FileSpecTest.cpp