/// filename has no extension, ConstString(nullptr) is returned. The dot
/// ('.') character is the first character in the returned string.
///
- /// \return Returns the extension of the file as a ConstString object.
- ConstString GetFileNameExtension() const;
+ /// \return Returns the extension of the file as a StringRef.
+ llvm::StringRef GetFileNameExtension() const;
/// Return the filename without the extension part
///
const char *pcm_path = command.GetArgumentAtIndex(0);
FileSpec pcm_file{pcm_path};
- if (pcm_file.GetFileNameExtension().GetStringRef() != ".pcm") {
+ if (pcm_file.GetFileNameExtension() != ".pcm") {
result.AppendError("file must have a .pcm extension");
return false;
}
llvm::StringRef path) {
Status error;
- static ConstString g_dylibext(".dylib");
- static ConstString g_solibext(".so");
+ static constexpr llvm::StringLiteral g_dylibext(".dylib");
+ static constexpr llvm::StringLiteral g_solibext(".so");
if (!baton)
return FileSystem::eEnumerateDirectoryResultQuit;
// contain the note section specifying the environment to Android but the
// custom extension and file name makes it highly unlikely that this will
// collide with anything else.
- ConstString file_extension = m_file.GetFileNameExtension();
+ llvm::StringRef file_extension = m_file.GetFileNameExtension();
bool skip_oatdata_oatexec =
file_extension == ".oat" || file_extension == ".odex";
Status PlatformAndroid::DownloadSymbolFile(const lldb::ModuleSP &module_sp,
const FileSpec &dst_file_spec) {
// For oat file we can try to fetch additional debug info from the device
- ConstString extension = module_sp->GetFileSpec().GetFileNameExtension();
+ llvm::StringRef extension = module_sp->GetFileSpec().GetFileNameExtension();
if (extension != ".oat" && extension != ".odex")
return Status(
"Symbol file downloading only supported for oat and odex files");
FileSystem::EnumerateDirectoryResult
PlatformDarwinKernel::FindKDKandSDKDirectoriesInDirectory(
void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path) {
- static ConstString g_sdk_suffix = ConstString(".sdk");
- static ConstString g_kdk_suffix = ConstString(".kdk");
+ static constexpr llvm::StringLiteral g_sdk_suffix = ".sdk";
+ static constexpr llvm::StringLiteral g_kdk_suffix = ".kdk";
PlatformDarwinKernel *thisp = (PlatformDarwinKernel *)baton;
FileSpec file_spec(path);
PlatformDarwinKernel::GetKernelsAndKextsInDirectoryHelper(
void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path,
bool recurse) {
- static ConstString g_kext_suffix = ConstString(".kext");
- static ConstString g_dsym_suffix = ConstString(".dSYM");
+ static constexpr llvm::StringLiteral g_kext_suffix = ".kext";
+ static constexpr llvm::StringLiteral g_dsym_suffix = ".dSYM";
FileSpec file_spec(path);
- ConstString file_spec_extension = file_spec.GetFileNameExtension();
+ llvm::StringRef file_spec_extension = file_spec.GetFileNameExtension();
Log *log = GetLog(LLDBLog::Platform);
// /dir/dir/mach.development.t7004
bool PlatformDarwinKernel::KerneldSYMHasNoSiblingBinary(
const FileSpec &kernel_dsym) {
- static ConstString g_dsym_suffix = ConstString(".dSYM");
+ static constexpr llvm::StringLiteral g_dsym_suffix = ".dSYM";
std::string possible_path = kernel_dsym.GetPath();
if (kernel_dsym.GetFileNameExtension() != g_dsym_suffix)
return false;
std::vector<FileSpec>
PlatformDarwinKernel::GetDWARFBinaryInDSYMBundle(FileSpec dsym_bundle) {
std::vector<FileSpec> results;
- static ConstString g_dsym_suffix = ConstString(".dSYM");
+ static constexpr llvm::StringLiteral g_dsym_suffix = ".dSYM";
if (dsym_bundle.GetFileNameExtension() != g_dsym_suffix) {
return results;
}
llvm::inconvertibleErrorCode());
}
- ConstString module_extension = file.GetFileNameExtension();
+ llvm::StringRef module_extension = file.GetFileNameExtension();
if (module_extension != ".lua") {
return llvm::make_error<llvm::StringError>("invalid extension",
llvm::inconvertibleErrorCode());
// On windows, we need to manually back out of the python tree, and go into
// the bin directory. This is pretty much the inverse of what ComputePythonDir
// does.
- if (this_file.GetFileNameExtension() == ConstString(".pyd")) {
+ if (this_file.GetFileNameExtension() == ".pyd") {
this_file.RemoveLastPathComponent(); // _lldb.pyd or _lldb_d.pyd
this_file.RemoveLastPathComponent(); // lldb
llvm::StringRef libdir = LLDB_PYTHON_RELATIVE_LIBDIR;
Denormalize(path, m_style);
}
-ConstString FileSpec::GetFileNameExtension() const {
- return ConstString(
- llvm::sys::path::extension(m_filename.GetStringRef(), m_style));
+llvm::StringRef FileSpec::GetFileNameExtension() const {
+ return llvm::sys::path::extension(m_filename.GetStringRef(), m_style);
}
ConstString FileSpec::GetFileNameStrippingExtension() const {
/// \b true if the filespec represents an implementation source
/// file, \b false otherwise.
bool FileSpec::IsSourceImplementationFile() const {
- ConstString extension(GetFileNameExtension());
- if (!extension)
+ llvm::StringRef extension = GetFileNameExtension();
+ if (extension.empty())
return false;
static RegularExpression g_source_file_regex(llvm::StringRef(
"cC][pP]|[sS]|[aA][sS][mM]|[fF]|[fF]77|[fF]90|[fF]95|[fF]03|[fF][oO]["
"rR]|[fF][tT][nN]|[fF][pP][pP]|[aA][dD][aA]|[aA][dD][bB]|[aA][dD][sS])"
"$"));
- return g_source_file_regex.Execute(extension.GetStringRef());
+ return g_source_file_regex.Execute(extension);
}
bool FileSpec::IsRelative() const {
FileSpec just_dot = PosixSpec("/tmp/bar.");
EXPECT_TRUE(dylib.GetFileNameExtension() == ".dylib");
- EXPECT_TRUE(exe.GetFileNameExtension() == ConstString(nullptr));
+ EXPECT_TRUE(exe.GetFileNameExtension() == llvm::StringRef());
EXPECT_TRUE(dSYM.GetFileNameExtension() == ".dSYM");
EXPECT_TRUE(just_dot.GetFileNameExtension() == ".");
FileSpec win_noext = WindowsSpec("C:\\tmp\\foo");
EXPECT_TRUE(dll.GetFileNameExtension() == ".dll");
- EXPECT_TRUE(win_noext.GetFileNameExtension() == ConstString(nullptr));
+ EXPECT_TRUE(win_noext.GetFileNameExtension() == llvm::StringRef());
}
TEST(FileSpecTest, TestFileNameStrippingExtension) {