Author: Kazu Hirata Date: 2023-12-16T14:39:37-08:00 New Revision: 744f38913fa380580431df0ae89ef5fb3df30240
URL: https://github.com/llvm/llvm-project/commit/744f38913fa380580431df0ae89ef5fb3df30240 DIFF: https://github.com/llvm/llvm-project/commit/744f38913fa380580431df0ae89ef5fb3df30240.diff LOG: [lldb] Use StringRef::{starts,ends}_with (NFC) This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with. Added: Modified: lldb/include/lldb/Utility/CompletionRequest.h lldb/source/Breakpoint/BreakpointResolverFileLine.cpp lldb/source/Commands/CommandCompletions.cpp lldb/source/Commands/CommandObjectCommands.cpp lldb/source/Commands/CommandObjectMemory.cpp lldb/source/Commands/CommandObjectThread.cpp lldb/source/Commands/CommandObjectType.cpp lldb/source/Core/IOHandlerCursesGUI.cpp lldb/source/Core/Mangled.cpp lldb/source/Core/Module.cpp lldb/source/Core/PluginManager.cpp lldb/source/Core/RichManglingContext.cpp lldb/source/Core/ValueObject.cpp lldb/source/Expression/IRExecutionUnit.cpp lldb/source/Expression/REPL.cpp lldb/source/Interpreter/CommandAlias.cpp lldb/source/Interpreter/OptionArgParser.cpp lldb/source/Interpreter/Options.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp lldb/source/Plugins/Language/ObjC/NSDictionary.cpp lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp lldb/source/Symbol/ObjectFile.cpp lldb/source/Symbol/Symbol.cpp lldb/source/Symbol/Symtab.cpp lldb/source/Symbol/Variable.cpp lldb/source/Target/TargetList.cpp lldb/source/Utility/Args.cpp lldb/source/Utility/CompletionRequest.cpp lldb/source/Utility/FileSpec.cpp lldb/source/Utility/FileSpecList.cpp lldb/source/Utility/NameMatches.cpp lldb/source/Utility/StringExtractor.cpp lldb/source/Utility/TildeExpressionResolver.cpp lldb/source/Utility/XcodeSDK.cpp lldb/tools/lldb-dap/IOStream.cpp lldb/tools/lldb-dap/JSONUtils.cpp lldb/tools/lldb-dap/lldb-dap.cpp lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp lldb/unittests/Process/minidump/RegisterContextMinidumpTest.cpp lldb/unittests/TestingSupport/MockTildeExpressionResolver.cpp Removed: ################################################################################ diff --git a/lldb/include/lldb/Utility/CompletionRequest.h b/lldb/include/lldb/Utility/CompletionRequest.h index 1fbc96944e82d5..1a2b1d639950fc 100644 --- a/lldb/include/lldb/Utility/CompletionRequest.h +++ b/lldb/include/lldb/Utility/CompletionRequest.h @@ -184,7 +184,7 @@ class CompletionRequest { // this can be a static_assert. static_assert(M != CompletionMode::RewriteLine, "Shouldn't rewrite line with this function"); - if (completion.startswith(GetCursorArgumentPrefix())) + if (completion.starts_with(GetCursorArgumentPrefix())) AddCompletion(completion, description, M); } diff --git a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp index 61bef498438bdd..cc4e1d26724f04 100644 --- a/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverFileLine.cpp @@ -206,7 +206,7 @@ void BreakpointResolverFileLine::DeduceSourceMapping( [path_separator](llvm::StringRef a, llvm::StringRef b, bool case_sensitive) -> std::optional<llvm::StringRef> { if (case_sensitive ? a.consume_back(b) : a.consume_back_insensitive(b)) { - if (a.empty() || a.endswith(path_separator)) { + if (a.empty() || a.ends_with(path_separator)) { return a; } } diff --git a/lldb/source/Commands/CommandCompletions.cpp b/lldb/source/Commands/CommandCompletions.cpp index e766a6c8c10bcc..16078a92ab5fe7 100644 --- a/lldb/source/Commands/CommandCompletions.cpp +++ b/lldb/source/Commands/CommandCompletions.cpp @@ -424,7 +424,7 @@ static void DiskFilesOrDirectories(const llvm::Twine &partial_name, auto Name = path::filename(Entry.path()); // Omit ".", ".." - if (Name == "." || Name == ".." || !Name.startswith(PartialItem)) + if (Name == "." || Name == ".." || !Name.starts_with(PartialItem)) continue; bool is_dir = Status->isDirectory(); @@ -608,7 +608,7 @@ void CommandCompletions::Registers(CommandInterpreter &interpreter, CompletionRequest &request, SearchFilter *searcher) { std::string reg_prefix; - if (request.GetCursorArgumentPrefix().startswith("$")) + if (request.GetCursorArgumentPrefix().starts_with("$")) reg_prefix = "$"; RegisterContext *reg_ctx = diff --git a/lldb/source/Commands/CommandObjectCommands.cpp b/lldb/source/Commands/CommandObjectCommands.cpp index 74d97b0db16cbe..5b9af4a3e1b880 100644 --- a/lldb/source/Commands/CommandObjectCommands.cpp +++ b/lldb/source/Commands/CommandObjectCommands.cpp @@ -411,7 +411,7 @@ rather than using a positional placeholder:" // Get the alias command. auto alias_command = args[0].ref(); - if (alias_command.startswith("-")) { + if (alias_command.starts_with("-")) { result.AppendError("aliases starting with a dash are not supported"); if (alias_command == "--help" || alias_command == "--long-help") { result.AppendWarning("if trying to pass options to 'command alias' add " diff --git a/lldb/source/Commands/CommandObjectMemory.cpp b/lldb/source/Commands/CommandObjectMemory.cpp index 4ecac732d0dca4..b78a0492cca558 100644 --- a/lldb/source/Commands/CommandObjectMemory.cpp +++ b/lldb/source/Commands/CommandObjectMemory.cpp @@ -1421,7 +1421,7 @@ class CommandObjectMemoryWrite : public CommandObjectParsed { // Be careful, getAsInteger with a radix of 16 rejects "0xab" so we // have to special case that: bool success = false; - if (entry.ref().startswith("0x")) + if (entry.ref().starts_with("0x")) success = !entry.ref().getAsInteger(0, uval64); if (!success) success = !entry.ref().getAsInteger(16, uval64); diff --git a/lldb/source/Commands/CommandObjectThread.cpp b/lldb/source/Commands/CommandObjectThread.cpp index dd9fab4bbddabc..a1e7e3f11361e7 100644 --- a/lldb/source/Commands/CommandObjectThread.cpp +++ b/lldb/source/Commands/CommandObjectThread.cpp @@ -145,14 +145,14 @@ class CommandObjectThreadBacktrace : public CommandObjectIterateOverThreads { for (size_t idx = 0; idx < num_entries; idx++) { llvm::StringRef arg_string = copy_args[idx].ref(); - if (arg_string.equals("-c") || count_opt.startswith(arg_string)) { + if (arg_string.equals("-c") || count_opt.starts_with(arg_string)) { idx++; if (idx == num_entries) return std::nullopt; count_idx = idx; if (copy_args[idx].ref().getAsInteger(0, count_val)) return std::nullopt; - } else if (arg_string.equals("-s") || start_opt.startswith(arg_string)) { + } else if (arg_string.equals("-s") || start_opt.starts_with(arg_string)) { idx++; if (idx == num_entries) return std::nullopt; @@ -1575,7 +1575,7 @@ class CommandObjectThreadReturn : public CommandObjectRaw { // I am going to handle this by hand, because I don't want you to have to // say: // "thread return -- -5". - if (command.startswith("-x")) { + if (command.starts_with("-x")) { if (command.size() != 2U) result.AppendWarning("Return values ignored when returning from user " "called expressions"); diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp index 411dc2fb723cea..f76420f3cc6837 100644 --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@ -1570,7 +1570,7 @@ void CommandObjectTypeSummaryAdd::DoExecute(Args &command, static bool FixArrayTypeNameWithRegex(ConstString &type_name) { llvm::StringRef type_name_ref(type_name.GetStringRef()); - if (type_name_ref.endswith("[]")) { + if (type_name_ref.ends_with("[]")) { std::string type_name_str(type_name.GetCString()); type_name_str.resize(type_name_str.length() - 2); if (type_name_str.back() != ' ') diff --git a/lldb/source/Core/IOHandlerCursesGUI.cpp b/lldb/source/Core/IOHandlerCursesGUI.cpp index abf0b6b801f37f..620e68a28510ef 100644 --- a/lldb/source/Core/IOHandlerCursesGUI.cpp +++ b/lldb/source/Core/IOHandlerCursesGUI.cpp @@ -7052,7 +7052,7 @@ class SourceFileWindowDelegate : public WindowDelegate { m_file_sp->DisplaySourceLines(curr_line + 1, column, 0, 0, &lineStream); StringRef line = lineStream.GetString(); - if (line.endswith("\n")) + if (line.ends_with("\n")) line = line.drop_back(); bool wasWritten = window.OutputColoredStringTruncated( 1, line, m_first_visible_column, is_pc_line); diff --git a/lldb/source/Core/Mangled.cpp b/lldb/source/Core/Mangled.cpp index 4587119519e98e..23ae3913093faf 100644 --- a/lldb/source/Core/Mangled.cpp +++ b/lldb/source/Core/Mangled.cpp @@ -42,20 +42,20 @@ Mangled::ManglingScheme Mangled::GetManglingScheme(llvm::StringRef const name) { if (name.empty()) return Mangled::eManglingSchemeNone; - if (name.startswith("?")) + if (name.starts_with("?")) return Mangled::eManglingSchemeMSVC; - if (name.startswith("_R")) + if (name.starts_with("_R")) return Mangled::eManglingSchemeRustV0; - if (name.startswith("_D")) + if (name.starts_with("_D")) return Mangled::eManglingSchemeD; - if (name.startswith("_Z")) + if (name.starts_with("_Z")) return Mangled::eManglingSchemeItanium; // ___Z is a clang extension of block invocations - if (name.startswith("___Z")) + if (name.starts_with("___Z")) return Mangled::eManglingSchemeItanium; // Swift's older style of mangling used "_T" as a mangling prefix. This can @@ -64,16 +64,16 @@ Mangled::ManglingScheme Mangled::GetManglingScheme(llvm::StringRef const name) { // for select old-style swift mangled names. The known cases are ObjC classes // and protocols. Classes are either prefixed with "_TtC" or "_TtGC". // Protocols are prefixed with "_TtP". - if (name.startswith("_TtC") || name.startswith("_TtGC") || - name.startswith("_TtP")) + if (name.starts_with("_TtC") || name.starts_with("_TtGC") || + name.starts_with("_TtP")) return Mangled::eManglingSchemeSwift; // Swift 4.2 used "$S" and "_$S". // Swift 5 and onward uses "$s" and "_$s". // Swift also uses "@__swiftmacro_" as a prefix for mangling filenames. - if (name.startswith("$S") || name.startswith("_$S") || - name.startswith("$s") || name.startswith("_$s") || - name.startswith("@__swiftmacro_")) + if (name.starts_with("$S") || name.starts_with("_$S") || + name.starts_with("$s") || name.starts_with("_$s") || + name.starts_with("@__swiftmacro_")) return Mangled::eManglingSchemeSwift; return Mangled::eManglingSchemeNone; diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp index 65a65c455efa76..c0574b724ace7b 100644 --- a/lldb/source/Core/Module.cpp +++ b/lldb/source/Core/Module.cpp @@ -1354,7 +1354,7 @@ void Module::SetSymbolFileFileSpec(const FileSpec &file) { if (FileSystem::Instance().IsDirectory(file)) { std::string new_path(file.GetPath()); std::string old_path(obj_file->GetFileSpec().GetPath()); - if (llvm::StringRef(old_path).startswith(new_path)) { + if (llvm::StringRef(old_path).starts_with(new_path)) { // We specified the same bundle as the symbol file that we already // have return; diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp index dea380e47f4eed..b428370d7f333a 100644 --- a/lldb/source/Core/PluginManager.cpp +++ b/lldb/source/Core/PluginManager.cpp @@ -821,7 +821,7 @@ PluginManager::GetPlatformCreateCallbackForPluginName(llvm::StringRef name) { void PluginManager::AutoCompletePlatformName(llvm::StringRef name, CompletionRequest &request) { for (const auto &instance : GetPlatformInstances().GetInstances()) { - if (instance.name.startswith(name)) + if (instance.name.starts_with(name)) request.AddCompletion(instance.name); } } @@ -869,7 +869,7 @@ PluginManager::GetProcessCreateCallbackForPluginName(llvm::StringRef name) { void PluginManager::AutoCompleteProcessName(llvm::StringRef name, CompletionRequest &request) { for (const auto &instance : GetProcessInstances().GetInstances()) { - if (instance.name.startswith(name)) + if (instance.name.starts_with(name)) request.AddCompletion(instance.name, instance.description); } } diff --git a/lldb/source/Core/RichManglingContext.cpp b/lldb/source/Core/RichManglingContext.cpp index 08c9b280b8ccb2..b68c9e11581b4c 100644 --- a/lldb/source/Core/RichManglingContext.cpp +++ b/lldb/source/Core/RichManglingContext.cpp @@ -72,7 +72,7 @@ bool RichManglingContext::IsCtorOrDtor() const { // We can only check for destructors here. auto base_name = get<CPlusPlusLanguage::MethodName>(m_cxx_method_parser)->GetBasename(); - return base_name.startswith("~"); + return base_name.starts_with("~"); } case None: return false; diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index b13bffa0ca809b..b82e6082eebddf 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -2112,7 +2112,7 @@ ValueObjectSP ValueObject::GetValueForExpressionPath_Impl( *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; return ValueObjectSP(); } - if (!temp_expression.startswith(">")) { + if (!temp_expression.starts_with(">")) { *reason_to_stop = ValueObject::eExpressionPathScanEndReasonUnexpectedSymbol; *final_result = ValueObject::eExpressionPathEndResultTypeInvalid; diff --git a/lldb/source/Expression/IRExecutionUnit.cpp b/lldb/source/Expression/IRExecutionUnit.cpp index 562bf3cdd2ed07..0682746e448e30 100644 --- a/lldb/source/Expression/IRExecutionUnit.cpp +++ b/lldb/source/Expression/IRExecutionUnit.cpp @@ -537,7 +537,7 @@ lldb::SectionType IRExecutionUnit::GetSectionTypeFromSectionName( sect_type = lldb::eSectionTypeCode; else if (name.equals("__data") || name.equals(".data")) sect_type = lldb::eSectionTypeCode; - else if (name.startswith("__debug_") || name.startswith(".debug_")) { + else if (name.starts_with("__debug_") || name.starts_with(".debug_")) { const uint32_t name_idx = name[0] == '_' ? 8 : 7; llvm::StringRef dwarf_name(name.substr(name_idx)); switch (dwarf_name[0]) { @@ -596,7 +596,7 @@ lldb::SectionType IRExecutionUnit::GetSectionTypeFromSectionName( default: break; } - } else if (name.startswith("__apple_") || name.startswith(".apple_")) + } else if (name.starts_with("__apple_") || name.starts_with(".apple_")) sect_type = lldb::eSectionTypeInvalid; else if (name.equals("__objc_imageinfo")) sect_type = lldb::eSectionTypeOther; diff --git a/lldb/source/Expression/REPL.cpp b/lldb/source/Expression/REPL.cpp index 07d5b5b3dd9346..a6a4ffb5e0af9e 100644 --- a/lldb/source/Expression/REPL.cpp +++ b/lldb/source/Expression/REPL.cpp @@ -497,7 +497,7 @@ void REPL::IOHandlerInputComplete(IOHandler &io_handler, std::string &code) { void REPL::IOHandlerComplete(IOHandler &io_handler, CompletionRequest &request) { // Complete an LLDB command if the first character is a colon... - if (request.GetRawLine().startswith(":")) { + if (request.GetRawLine().starts_with(":")) { Debugger &debugger = m_target.GetDebugger(); // auto complete LLDB commands diff --git a/lldb/source/Interpreter/CommandAlias.cpp b/lldb/source/Interpreter/CommandAlias.cpp index b95d3c91fcbc2e..c5971b52f837fa 100644 --- a/lldb/source/Interpreter/CommandAlias.cpp +++ b/lldb/source/Interpreter/CommandAlias.cpp @@ -182,7 +182,7 @@ bool CommandAlias::IsDashDashCommand() { for (const auto &opt_entry : *GetOptionArguments()) { std::tie(opt, std::ignore, value) = opt_entry; if (opt == CommandInterpreter::g_argument && !value.empty() && - llvm::StringRef(value).endswith("--")) { + llvm::StringRef(value).ends_with("--")) { m_is_dashdash_alias = eLazyBoolYes; break; } diff --git a/lldb/source/Interpreter/OptionArgParser.cpp b/lldb/source/Interpreter/OptionArgParser.cpp index 8a92c7d08c4766..d13805a75ffbf7 100644 --- a/lldb/source/Interpreter/OptionArgParser.cpp +++ b/lldb/source/Interpreter/OptionArgParser.cpp @@ -61,7 +61,7 @@ int64_t OptionArgParser::ToOptionEnum(llvm::StringRef s, for (const auto &enum_value : enum_values) { llvm::StringRef this_enum(enum_value.string_value); - if (this_enum.startswith(s)) + if (this_enum.starts_with(s)) return enum_value.value; } diff --git a/lldb/source/Interpreter/Options.cpp b/lldb/source/Interpreter/Options.cpp index acbde7660440b1..89fe69009d9036 100644 --- a/lldb/source/Interpreter/Options.cpp +++ b/lldb/source/Interpreter/Options.cpp @@ -636,7 +636,7 @@ bool Options::HandleOptionCompletion(CompletionRequest &request, // upper level code will know this is a full match and add the " ". const OptionDefinition &opt = opt_defs[opt_defs_index]; llvm::StringRef long_option = opt.long_option; - if (cur_opt_str.startswith("--") && cur_opt_str != long_option) { + if (cur_opt_str.starts_with("--") && cur_opt_str != long_option) { request.AddCompletion("--" + long_option.str(), opt.usage_text); return true; } else @@ -652,7 +652,7 @@ bool Options::HandleOptionCompletion(CompletionRequest &request, if (cur_opt_str.consume_front("--")) { for (auto &def : opt_defs) { llvm::StringRef long_option(def.long_option); - if (long_option.startswith(cur_opt_str)) + if (long_option.starts_with(cur_opt_str)) request.AddCompletion("--" + long_option.str(), def.usage_text); } } @@ -890,8 +890,8 @@ static size_t FindArgumentIndexForOption(const Args &args, std::string long_opt = std::string(llvm::formatv("--{0}", long_option.definition->long_option)); for (const auto &entry : llvm::enumerate(args)) { - if (entry.value().ref().startswith(short_opt) || - entry.value().ref().startswith(long_opt)) + if (entry.value().ref().starts_with(short_opt) || + entry.value().ref().starts_with(long_opt)) return entry.index(); } diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp index 00ab6a04bd3236..79dd306f7627fd 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp @@ -571,8 +571,8 @@ bool ClangASTSource::IgnoreName(const ConstString name, // The ClangASTSource is not responsible for finding $-names. return name_string_ref.empty() || - (ignore_all_dollar_names && name_string_ref.startswith("$")) || - name_string_ref.startswith("_$"); + (ignore_all_dollar_names && name_string_ref.starts_with("$")) || + name_string_ref.starts_with("_$"); } void ClangASTSource::FindExternalVisibleDecls( diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp index 6fbc0bb22f82bd..2d306b42760b18 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp @@ -1369,7 +1369,7 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( if (!namespace_decl) SearchPersistenDecls(context, name); - if (name.GetStringRef().startswith("$") && !namespace_decl) { + if (name.GetStringRef().starts_with("$") && !namespace_decl) { if (name == "$__lldb_class") { LookUpLldbClass(context); return; @@ -1385,7 +1385,7 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( } // any other $__lldb names should be weeded out now - if (name.GetStringRef().startswith("$__lldb")) + if (name.GetStringRef().starts_with("$__lldb")) return; // No ParserVars means we can't do register or variable lookup. @@ -1400,7 +1400,7 @@ void ClangExpressionDeclMap::FindExternalVisibleDecls( return; } - assert(name.GetStringRef().startswith("$")); + assert(name.GetStringRef().starts_with("$")); llvm::StringRef reg_name = name.GetStringRef().substr(1); if (m_parser_vars->m_exe_ctx.GetRegisterContext()) { diff --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp index f6856b1a2558cb..574d661e2a215e 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp @@ -834,13 +834,13 @@ class CodeComplete : public CodeCompleteConsumer { case CodeCompletionResult::RK_Declaration: return !( Result.Declaration->getIdentifier() && - Result.Declaration->getIdentifier()->getName().startswith(Filter)); + Result.Declaration->getIdentifier()->getName().starts_with(Filter)); case CodeCompletionResult::RK_Keyword: - return !StringRef(Result.Keyword).startswith(Filter); + return !StringRef(Result.Keyword).starts_with(Filter); case CodeCompletionResult::RK_Macro: - return !Result.Macro->getName().startswith(Filter); + return !Result.Macro->getName().starts_with(Filter); case CodeCompletionResult::RK_Pattern: - return !StringRef(Result.Pattern->getAsString()).startswith(Filter); + return !StringRef(Result.Pattern->getAsString()).starts_with(Filter); } // If we trigger this assert or the above switch yields a warning, then // CodeCompletionResult has been enhanced with more kinds of completion @@ -904,7 +904,7 @@ class CodeComplete : public CodeCompleteConsumer { } // We also filter some internal lldb identifiers here. The user // shouldn't see these. - if (llvm::StringRef(ToInsert).startswith("$__lldb_")) + if (llvm::StringRef(ToInsert).starts_with("$__lldb_")) return std::nullopt; if (ToInsert.empty()) return std::nullopt; diff --git a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp index 847dab6592b886..62443d1290dc72 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/CppModuleConfiguration.cpp @@ -72,7 +72,7 @@ bool CppModuleConfiguration::analyzeFile(const FileSpec &f, // path. Ignore subdirectories such as /c++/v1/experimental as those don't // need to be specified in the header search. if (libcpp_regex.match(f.GetPath()) && - parent_path(posix_dir, Style::posix).endswith("c++")) { + parent_path(posix_dir, Style::posix).ends_with("c++")) { if (!m_std_inc.TrySet(posix_dir)) return false; if (triple.str().empty()) diff --git a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp index 33e5dd0015aebf..597873af8b2aed 100644 --- a/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp +++ b/lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp @@ -154,9 +154,10 @@ clang::NamedDecl *IRForTarget::DeclForGlobal(GlobalValue *global_val) { /// Returns true iff the mangled symbol is for a static guard variable. static bool isGuardVariableSymbol(llvm::StringRef mangled_symbol, bool check_ms_abi = true) { - bool result = mangled_symbol.startswith("_ZGV"); // Itanium ABI guard variable + bool result = + mangled_symbol.starts_with("_ZGV"); // Itanium ABI guard variable if (check_ms_abi) - result |= mangled_symbol.endswith("@4IA"); // Microsoft ABI + result |= mangled_symbol.ends_with("@4IA"); // Microsoft ABI return result; } @@ -720,8 +721,9 @@ bool IRForTarget::RewriteObjCConstStrings() { static bool IsObjCSelectorRef(Value *value) { GlobalVariable *global_variable = dyn_cast<GlobalVariable>(value); - return !(!global_variable || !global_variable->hasName() || - !global_variable->getName().startswith("OBJC_SELECTOR_REFERENCES_")); + return !( + !global_variable || !global_variable->hasName() || + !global_variable->getName().starts_with("OBJC_SELECTOR_REFERENCES_")); } // This function does not report errors; its callers are responsible. @@ -940,7 +942,7 @@ bool IRForTarget::RewritePersistentAllocs(llvm::BasicBlock &basic_block) { if (AllocaInst *alloc = dyn_cast<AllocaInst>(&inst)) { llvm::StringRef alloc_name = alloc->getName(); - if (alloc_name.startswith("$") && !alloc_name.startswith("$__lldb")) { + if (alloc_name.starts_with("$") && !alloc_name.starts_with("$__lldb")) { if (alloc_name.find_first_of("0123456789") == 1) { LLDB_LOG(log, "Rejecting a numeric persistent variable."); @@ -1017,7 +1019,7 @@ bool IRForTarget::MaybeHandleVariable(Value *llvm_value_ptr) { const Type *value_type = nullptr; - if (name.startswith("$")) { + if (name.starts_with("$")) { // The $__lldb_expr_result name indicates the return value has allocated // as a static variable. Per the comment at // ASTResultSynthesizer::SynthesizeBodyResult, accesses to this static @@ -1223,7 +1225,7 @@ bool IRForTarget::ResolveExternals(Function &llvm_function) { LLDB_LOG(log, "Examining {0}, DeclForGlobalValue returns {1}", global_name, static_cast<void *>(DeclForGlobal(&global_var))); - if (global_name.startswith("OBJC_IVAR")) { + if (global_name.starts_with("OBJC_IVAR")) { if (!HandleSymbol(&global_var)) { m_error_stream.Format("Error [IRForTarget]: Couldn't find Objective-C " "indirect ivar symbol {0}\n", diff --git a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp index f4537b4133b93e..586cc08a6f1233 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp @@ -466,7 +466,7 @@ class ManglingSubstitutor } void trySubstitute(llvm::StringRef From, llvm::StringRef To) { - if (!llvm::StringRef(currentParserPos(), this->numLeft()).startswith(From)) + if (!llvm::StringRef(currentParserPos(), this->numLeft()).starts_with(From)) return; // We found a match. Append unmodified input up to this point. diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp index 2e8da396a4a7b2..ff7043bdf97ffa 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibCxxUnorderedMap.cpp @@ -84,7 +84,7 @@ static bool isStdTemplate(ConstString type_name, llvm::StringRef type) { // The type name may be prefixed with `std::__<inline-namespace>::`. if (name.consume_front("std::")) consumeInlineNamespace(name); - return name.consume_front(type) && name.startswith("<"); + return name.consume_front(type) && name.starts_with("<"); } static bool isUnorderedMap(ConstString type_name) { diff --git a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp index aef7cbac603f2c..f1bfeae5099b7c 100644 --- a/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp +++ b/lldb/source/Plugins/Language/CPlusPlus/LibStdcppTuple.cpp @@ -69,9 +69,9 @@ bool LibStdcppTupleSyntheticFrontEnd::Update() { for (size_t i = 0; i < child_count; ++i) { ValueObjectSP child_sp = current_child->GetChildAtIndex(i); llvm::StringRef name_str = child_sp->GetName().GetStringRef(); - if (name_str.startswith("std::_Tuple_impl<")) { + if (name_str.starts_with("std::_Tuple_impl<")) { next_child_sp = child_sp; - } else if (name_str.startswith("std::_Head_base<")) { + } else if (name_str.starts_with("std::_Head_base<")) { ValueObjectSP value_sp = child_sp->GetChildMemberWithName("_M_head_impl"); if (value_sp) { diff --git a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp index 605c79cbd9b554..5ae0751cb065f3 100644 --- a/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp +++ b/lldb/source/Plugins/Language/ObjC/NSDictionary.cpp @@ -37,7 +37,7 @@ NSDictionary_Additionals::AdditionalFormatterMatching::Prefix::Prefix( bool NSDictionary_Additionals::AdditionalFormatterMatching::Prefix::Match( ConstString class_name) { - return class_name.GetStringRef().startswith(m_prefix.GetStringRef()); + return class_name.GetStringRef().starts_with(m_prefix.GetStringRef()); } NSDictionary_Additionals::AdditionalFormatterMatching::Full::Full(ConstString n) diff --git a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp index 82b037129c2443..742ae7b1494547 100644 --- a/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ b/lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -81,9 +81,9 @@ ObjCLanguage::MethodName::Create(llvm::StringRef name, bool strict) { // Figure out type Type type = eTypeUnspecified; - if (name.startswith("+[")) + if (name.starts_with("+[")) type = eTypeClassMethod; - else if (name.startswith("-[")) + else if (name.starts_with("-[")) type = eTypeInstanceMethod; // If there's no type and it's strict, this is invalid diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp index e65b99f44be6dc..300ecc8e8ed587 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/CPPLanguageRuntime.cpp @@ -220,7 +220,7 @@ CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo( llvm::StringRef vtable_name(symbol->GetName().GetStringRef()); bool found_expected_start_string = - vtable_name.startswith("vtable for std::__1::__function::__func<"); + vtable_name.starts_with("vtable for std::__1::__function::__func<"); if (!found_expected_start_string) return optional_info; @@ -277,7 +277,7 @@ CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo( } // Case 4 or 5 - if (symbol && !symbol->GetName().GetStringRef().startswith("vtable for") && + if (symbol && !symbol->GetName().GetStringRef().starts_with("vtable for") && !contains_lambda_identifier(first_template_parameter) && !has_invoke) { optional_info.callable_case = LibCppStdFunctionCallableCase::FreeOrMemberFunction; @@ -312,7 +312,7 @@ CPPLanguageRuntime::FindLibCppStdFunctionCallableInfo( lldb::FunctionSP func_sp = vtable_cu->FindFunction([name_to_use](const FunctionSP &f) { auto name = f->GetName().GetStringRef(); - if (name.startswith(name_to_use) && name.contains("operator")) + if (name.starts_with(name_to_use) && name.contains("operator")) return true; return false; @@ -373,7 +373,7 @@ CPPLanguageRuntime::GetStepThroughTrampolinePlan(Thread &thread, // step into the wrapped callable. // bool found_expected_start_string = - function_name.startswith("std::__1::function<"); + function_name.starts_with("std::__1::function<"); if (!found_expected_start_string) return ret_plan_sp; diff --git a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp index 0ea9201901ab38..47b1db16f1e904 100644 --- a/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp +++ b/lldb/source/Plugins/LanguageRuntime/CPlusPlus/ItaniumABI/ItaniumABILanguageRuntime.cpp @@ -274,7 +274,7 @@ llvm::Expected<LanguageRuntime::VTableInfo> "no symbol found for 0x%" PRIx64, vtable_load_addr); llvm::StringRef name = symbol->GetMangled().GetDemangledName().GetStringRef(); - if (name.startswith(vtable_demangled_prefix)) { + if (name.starts_with(vtable_demangled_prefix)) { VTableInfo info = {vtable_addr, symbol}; std::lock_guard<std::mutex> locker(m_mutex); auto pos = m_vtable_info_map[vtable_addr] = info; @@ -450,7 +450,7 @@ class CommandObjectMultiwordItaniumABI_Demangle : public CommandObjectParsed { // on behalf of the user. This is the moral equivalent of the -_/-n // options to c++filt auto name = entry.ref(); - if (name.startswith("__Z")) + if (name.starts_with("__Z")) name = name.drop_front(); Mangled mangled(name); diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp index 1fd7d027731de0..dc492ac0f06d30 100644 --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -2641,7 +2641,7 @@ static bool DoesProcessHaveSharedCache(Process &process) { return true; // this should not happen llvm::StringRef platform_plugin_name_sr = platform_sp->GetPluginName(); - if (platform_plugin_name_sr.endswith("-simulator")) + if (platform_plugin_name_sr.ends_with("-simulator")) return false; return true; @@ -2731,7 +2731,7 @@ lldb::addr_t AppleObjCRuntimeV2::LookupRuntimeSymbol(ConstString name) { llvm::StringRef ivar_prefix("OBJC_IVAR_$_"); llvm::StringRef class_prefix("OBJC_CLASS_$_"); - if (name_strref.startswith(ivar_prefix)) { + if (name_strref.starts_with(ivar_prefix)) { llvm::StringRef ivar_skipped_prefix = name_strref.substr(ivar_prefix.size()); std::pair<llvm::StringRef, llvm::StringRef> class_and_ivar = @@ -2764,7 +2764,7 @@ lldb::addr_t AppleObjCRuntimeV2::LookupRuntimeSymbol(ConstString name) { ivar_func); } } - } else if (name_strref.startswith(class_prefix)) { + } else if (name_strref.starts_with(class_prefix)) { llvm::StringRef class_skipped_prefix = name_strref.substr(class_prefix.size()); const ConstString class_name_cs(class_skipped_prefix); diff --git a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp index 24f3939a8f2ba5..58275c052f74e6 100644 --- a/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ b/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -2164,20 +2164,20 @@ static SymbolType GetSymbolType(const char *&symbol_name, if (symbol_name) { llvm::StringRef symbol_name_ref(symbol_name); - if (symbol_name_ref.startswith("OBJC_")) { + if (symbol_name_ref.starts_with("OBJC_")) { static const llvm::StringRef g_objc_v2_prefix_class("OBJC_CLASS_$_"); static const llvm::StringRef g_objc_v2_prefix_metaclass( "OBJC_METACLASS_$_"); static const llvm::StringRef g_objc_v2_prefix_ivar("OBJC_IVAR_$_"); - if (symbol_name_ref.startswith(g_objc_v2_prefix_class)) { + if (symbol_name_ref.starts_with(g_objc_v2_prefix_class)) { symbol_name = symbol_name + g_objc_v2_prefix_class.size(); type = eSymbolTypeObjCClass; demangled_is_synthesized = true; - } else if (symbol_name_ref.startswith(g_objc_v2_prefix_metaclass)) { + } else if (symbol_name_ref.starts_with(g_objc_v2_prefix_metaclass)) { symbol_name = symbol_name + g_objc_v2_prefix_metaclass.size(); type = eSymbolTypeObjCMetaClass; demangled_is_synthesized = true; - } else if (symbol_name_ref.startswith(g_objc_v2_prefix_ivar)) { + } else if (symbol_name_ref.starts_with(g_objc_v2_prefix_ivar)) { symbol_name = symbol_name + g_objc_v2_prefix_ivar.size(); type = eSymbolTypeObjCIVar; demangled_is_synthesized = true; @@ -3789,18 +3789,19 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) { if (symbol_name && symbol_name[0] == '_' && symbol_name[1] == 'O') { llvm::StringRef symbol_name_ref(symbol_name); - if (symbol_name_ref.startswith(g_objc_v2_prefix_class)) { + if (symbol_name_ref.starts_with(g_objc_v2_prefix_class)) { symbol_name_non_abi_mangled = symbol_name + 1; symbol_name = symbol_name + g_objc_v2_prefix_class.size(); type = eSymbolTypeObjCClass; demangled_is_synthesized = true; - } else if (symbol_name_ref.startswith(g_objc_v2_prefix_metaclass)) { + } else if (symbol_name_ref.starts_with( + g_objc_v2_prefix_metaclass)) { symbol_name_non_abi_mangled = symbol_name + 1; symbol_name = symbol_name + g_objc_v2_prefix_metaclass.size(); type = eSymbolTypeObjCMetaClass; demangled_is_synthesized = true; - } else if (symbol_name_ref.startswith(g_objc_v2_prefix_ivar)) { + } else if (symbol_name_ref.starts_with(g_objc_v2_prefix_ivar)) { symbol_name_non_abi_mangled = symbol_name + 1; symbol_name = symbol_name + g_objc_v2_prefix_ivar.size(); type = eSymbolTypeObjCIVar; @@ -4250,27 +4251,27 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) { if (symbol_name) { llvm::StringRef symbol_name_ref(symbol_name); - if (symbol_name_ref.startswith("_OBJC_")) { + if (symbol_name_ref.starts_with("_OBJC_")) { llvm::StringRef g_objc_v2_prefix_class( "_OBJC_CLASS_$_"); llvm::StringRef g_objc_v2_prefix_metaclass( "_OBJC_METACLASS_$_"); llvm::StringRef g_objc_v2_prefix_ivar( "_OBJC_IVAR_$_"); - if (symbol_name_ref.startswith(g_objc_v2_prefix_class)) { + if (symbol_name_ref.starts_with(g_objc_v2_prefix_class)) { symbol_name_non_abi_mangled = symbol_name + 1; symbol_name = symbol_name + g_objc_v2_prefix_class.size(); type = eSymbolTypeObjCClass; demangled_is_synthesized = true; - } else if (symbol_name_ref.startswith( + } else if (symbol_name_ref.starts_with( g_objc_v2_prefix_metaclass)) { symbol_name_non_abi_mangled = symbol_name + 1; symbol_name = symbol_name + g_objc_v2_prefix_metaclass.size(); type = eSymbolTypeObjCMetaClass; demangled_is_synthesized = true; - } else if (symbol_name_ref.startswith( + } else if (symbol_name_ref.starts_with( g_objc_v2_prefix_ivar)) { symbol_name_non_abi_mangled = symbol_name + 1; symbol_name = @@ -4297,7 +4298,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) { llvm::StringRef symbol_name_ref(symbol_name); llvm::StringRef g_objc_v1_prefix_class( ".objc_class_name_"); - if (symbol_name_ref.startswith(g_objc_v1_prefix_class)) { + if (symbol_name_ref.starts_with(g_objc_v1_prefix_class)) { symbol_name_non_abi_mangled = symbol_name; symbol_name = symbol_name + g_objc_v1_prefix_class.size(); type = eSymbolTypeObjCClass; @@ -5163,10 +5164,10 @@ uint32_t ObjectFileMachO::GetDependentModules(FileSpecList &files) { std::string loader_path("@loader_path"); std::string executable_path("@executable_path"); for (auto &rpath : rpath_paths) { - if (llvm::StringRef(rpath).startswith(loader_path)) { + if (llvm::StringRef(rpath).starts_with(loader_path)) { rpath.erase(0, loader_path.size()); rpath.insert(0, this_file_spec.GetDirectory().GetCString()); - } else if (llvm::StringRef(rpath).startswith(executable_path)) { + } else if (llvm::StringRef(rpath).starts_with(executable_path)) { rpath.erase(0, executable_path.size()); rpath.insert(0, this_file_spec.GetDirectory().GetCString()); } diff --git a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp index 8b64412ddd98e3..8c69989702c2aa 100644 --- a/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp +++ b/lldb/source/Plugins/Process/Linux/IntelPTSingleBufferTrace.cpp @@ -62,7 +62,7 @@ static Expected<uint32_t> ReadIntelPTConfigFile(const char *file, if (type == BitOffset) { const char *prefix = "config:"; - if (!text_buffer.startswith(prefix)) + if (!text_buffer.starts_with(prefix)) return createStringError(inconvertibleErrorCode(), "The file '%s' contents doesn't start with '%s'", file, prefix); diff --git a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp index a4540de4acc451..7723009787f7f6 100644 --- a/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp +++ b/lldb/source/Plugins/Process/elf-core/ProcessElfCore.cpp @@ -832,7 +832,7 @@ llvm::Error ProcessElfCore::parseOpenBSDNotes(llvm::ArrayRef<CoreNote> notes) { for (const auto ¬e : notes) { // OpenBSD per-thread information is stored in notes named "OpenBSD@nnn" so // match on the initial part of the string. - if (!llvm::StringRef(note.info.n_name).startswith("OpenBSD")) + if (!llvm::StringRef(note.info.n_name).starts_with("OpenBSD")) continue; switch (note.info.n_type) { diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp index 2cf8c29bf9d2fe..ad72b3d121e673 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp @@ -4042,7 +4042,7 @@ void GDBRemoteCommunicationClient::ServeSymbolLookups( return; } else { llvm::StringRef response_str(response.GetStringRef()); - if (response_str.startswith("qSymbol:")) { + if (response_str.starts_with("qSymbol:")) { response.SetFilePos(strlen("qSymbol:")); std::string symbol_name; if (response.GetHexByteString(symbol_name)) { diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index 187c23a206094c..3d37bb226a65fd 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -3921,7 +3921,7 @@ GDBRemoteCommunicationServerLLGS::Handle_qSaveCore( std::string path_hint; StringRef packet_str{packet.GetStringRef()}; - assert(packet_str.startswith("qSaveCore")); + assert(packet_str.starts_with("qSaveCore")); if (packet_str.consume_front("qSaveCore;")) { for (auto x : llvm::split(packet_str, ';')) { if (x.consume_front("path-hint:")) @@ -3947,7 +3947,7 @@ GDBRemoteCommunicationServerLLGS::Handle_QNonStop( Log *log = GetLog(LLDBLog::Process); StringRef packet_str{packet.GetStringRef()}; - assert(packet_str.startswith("QNonStop:")); + assert(packet_str.starts_with("QNonStop:")); packet_str.consume_front("QNonStop:"); if (packet_str == "0") { if (m_non_stop) @@ -4306,7 +4306,7 @@ lldb_private::process_gdb_remote::LLGSArgToURL(llvm::StringRef url_arg, std::string host_port = url_arg.str(); // If host_and_port starts with ':', default the host to be "localhost" and // expect the remainder to be the port. - if (url_arg.startswith(":")) + if (url_arg.starts_with(":")) host_port.insert(0, "localhost"); // Try parsing the (preprocessed) argument as host:port pair. diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp index d5e557b4b88c07..316be471df9295 100644 --- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -4472,7 +4472,7 @@ bool ParseRegisters( // and a simple type. Just in case, look for that too (setting both // does no harm). if (!gdb_type.empty() && !(encoding_set || format_set)) { - if (llvm::StringRef(gdb_type).startswith("int")) { + if (llvm::StringRef(gdb_type).starts_with("int")) { reg_info.format = eFormatHex; reg_info.encoding = eEncodingUint; } else if (gdb_type == "data_ptr" || gdb_type == "code_ptr") { @@ -4482,7 +4482,7 @@ bool ParseRegisters( reg_info.format = eFormatFloat; reg_info.encoding = eEncodingIEEE754; } else if (gdb_type == "aarch64v" || - llvm::StringRef(gdb_type).startswith("vec") || + llvm::StringRef(gdb_type).starts_with("vec") || gdb_type == "i387_ext" || gdb_type == "uint128") { // lldb doesn't handle 128-bit uints correctly (for ymm*h), so // treat them as vector (similarly to xmm/ymm) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp index 6f771c66a725cf..0e2f4d45543bb5 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -809,7 +809,7 @@ removeHostnameFromPathname(llvm::StringRef path_from_dwarf) { // check whether we have a windows path, and so the first character is a // drive-letter not a hostname. if (host.size() == 1 && llvm::isAlpha(host[0]) && - (path.startswith("\\") || path.startswith("/"))) + (path.starts_with("\\") || path.starts_with("/"))) return path_from_dwarf; return path; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index 7eddc5074eff12..505ea29ca4d4f5 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -1982,7 +1982,7 @@ void SymbolFileDWARF::UpdateExternalModuleListIfNeeded() { // (corresponding to .dwo) so we simply skip it. if (m_objfile_sp->GetFileSpec().GetFileNameExtension() == ".dwo" && llvm::StringRef(m_objfile_sp->GetFileSpec().GetPath()) - .endswith(dwo_module_spec.GetFileSpec().GetPath())) { + .ends_with(dwo_module_spec.GetFileSpec().GetPath())) { continue; } diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp index 06cb720b1e9f7f..25d04f999ad675 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/CompileUnitIndex.cpp @@ -236,7 +236,7 @@ CompileUnitIndex::GetMainSourceFile(const CompilandIndexItem &item) const { llvm::cantFail( TypeDeserializer::deserializeAs<StringIdRecord>(file_cvt, file_name)); - llvm::sys::path::Style style = working_dir.String.startswith("/") + llvm::sys::path::Style style = working_dir.String.starts_with("/") ? llvm::sys::path::Style::posix : llvm::sys::path::Style::windows; if (llvm::sys::path::is_absolute(file_name.String, style)) diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp index 5b690ead1e8dea..b79d3e63f72b1d 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/PdbAstBuilder.cpp @@ -1264,9 +1264,9 @@ void PdbAstBuilder::ParseNamespace(clang::DeclContext &context) { clang::NamespaceDecl *ns = llvm::cast<clang::NamespaceDecl>(context); llvm::StringRef ns_name = ns->getName(); - if (ns_name.startswith(qname)) { + if (ns_name.starts_with(qname)) { ns_name = ns_name.drop_front(qname.size()); - if (ns_name.startswith("::")) + if (ns_name.starts_with("::")) GetOrCreateType(tid); } } diff --git a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp index 35c2575028d85e..ad08013399369e 100644 --- a/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp +++ b/lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp @@ -1379,7 +1379,7 @@ bool SymbolFileNativePDB::ParseSupportFiles(CompileUnit &comp_unit, for (llvm::StringRef f : cci->m_file_list) { FileSpec::Style style = - f.startswith("/") ? FileSpec::Style::posix : FileSpec::Style::windows; + f.starts_with("/") ? FileSpec::Style::posix : FileSpec::Style::windows; FileSpec spec(f, style); support_files.Append(spec); } diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 47024cd03536a3..797df8c098af10 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -7593,7 +7593,7 @@ clang::CXXMethodDecl *TypeSystemClang::AddMethodToCXXRecordType( nullptr /*expr*/, is_explicit ? clang::ExplicitSpecKind::ResolvedTrue : clang::ExplicitSpecKind::ResolvedFalse); - if (name.startswith("~")) { + if (name.starts_with("~")) { cxx_dtor_decl = clang::CXXDestructorDecl::CreateDeserialized(getASTContext(), 0); cxx_dtor_decl->setDeclContext(cxx_record_decl); diff --git a/lldb/source/Symbol/ObjectFile.cpp b/lldb/source/Symbol/ObjectFile.cpp index 07f79aaedab820..d890ad92e83122 100644 --- a/lldb/source/Symbol/ObjectFile.cpp +++ b/lldb/source/Symbol/ObjectFile.cpp @@ -607,15 +607,15 @@ lldb::SymbolType ObjectFile::GetSymbolTypeFromName(llvm::StringRef name, lldb::SymbolType symbol_type_hint) { if (!name.empty()) { - if (name.startswith("_OBJC_")) { + if (name.starts_with("_OBJC_")) { // ObjC - if (name.startswith("_OBJC_CLASS_$_")) + if (name.starts_with("_OBJC_CLASS_$_")) return lldb::eSymbolTypeObjCClass; - if (name.startswith("_OBJC_METACLASS_$_")) + if (name.starts_with("_OBJC_METACLASS_$_")) return lldb::eSymbolTypeObjCMetaClass; - if (name.startswith("_OBJC_IVAR_$_")) + if (name.starts_with("_OBJC_IVAR_$_")) return lldb::eSymbolTypeObjCIVar; - } else if (name.startswith(".objc_class_name_")) { + } else if (name.starts_with(".objc_class_name_")) { // ObjC v1 return lldb::eSymbolTypeObjCClass; } diff --git a/lldb/source/Symbol/Symbol.cpp b/lldb/source/Symbol/Symbol.cpp index fcc45f861c2255..08900a3ef34914 100644 --- a/lldb/source/Symbol/Symbol.cpp +++ b/lldb/source/Symbol/Symbol.cpp @@ -634,7 +634,7 @@ bool Symbol::IsSyntheticWithAutoGeneratedName() const { if (!m_mangled) return true; ConstString demangled = m_mangled.GetDemangledName(); - return demangled.GetStringRef().startswith(GetSyntheticSymbolPrefix()); + return demangled.GetStringRef().starts_with(GetSyntheticSymbolPrefix()); } void Symbol::SynthesizeNameIfNeeded() const { diff --git a/lldb/source/Symbol/Symtab.cpp b/lldb/source/Symbol/Symtab.cpp index 1aebe198f9e78a..564a3a94cfa202 100644 --- a/lldb/source/Symbol/Symtab.cpp +++ b/lldb/source/Symbol/Symtab.cpp @@ -233,7 +233,7 @@ static bool lldb_skip_name(llvm::StringRef mangled, Mangled::ManglingScheme scheme) { switch (scheme) { case Mangled::eManglingSchemeItanium: { - if (mangled.size() < 3 || !mangled.startswith("_Z")) + if (mangled.size() < 3 || !mangled.starts_with("_Z")) return true; // Avoid the following types of symbols in the index. diff --git a/lldb/source/Symbol/Variable.cpp b/lldb/source/Symbol/Variable.cpp index db740cb7cb6e41..2bb2ff7db4b721 100644 --- a/lldb/source/Symbol/Variable.cpp +++ b/lldb/source/Symbol/Variable.cpp @@ -510,7 +510,7 @@ static void PrivateAutoCompleteMembers( i, member_name, nullptr, nullptr, nullptr); if (partial_member_name.empty() || - llvm::StringRef(member_name).startswith(partial_member_name)) { + llvm::StringRef(member_name).starts_with(partial_member_name)) { if (member_name == partial_member_name) { PrivateAutoComplete( frame, partial_path, @@ -685,7 +685,7 @@ static void PrivateAutoComplete( continue; llvm::StringRef variable_name = var_sp->GetName().GetStringRef(); - if (variable_name.startswith(token)) { + if (variable_name.starts_with(token)) { if (variable_name == token) { Type *variable_type = var_sp->GetType(); if (variable_type) { diff --git a/lldb/source/Target/TargetList.cpp b/lldb/source/Target/TargetList.cpp index 3ec523b9410103..121b6253d2a59d 100644 --- a/lldb/source/Target/TargetList.cpp +++ b/lldb/source/Target/TargetList.cpp @@ -271,7 +271,7 @@ Status TargetList::CreateTargetInternal(Debugger &debugger, arch = specified_arch; FileSpec file(user_exe_path); - if (!FileSystem::Instance().Exists(file) && user_exe_path.startswith("~")) { + if (!FileSystem::Instance().Exists(file) && user_exe_path.starts_with("~")) { // we want to expand the tilde but we don't want to resolve any symbolic // links so we can't use the FileSpec constructor's resolve flag llvm::SmallString<64> unglobbed_path; diff --git a/lldb/source/Utility/Args.cpp b/lldb/source/Utility/Args.cpp index 152be96a22128b..13b993bc74c9f4 100644 --- a/lldb/source/Utility/Args.cpp +++ b/lldb/source/Utility/Args.cpp @@ -641,7 +641,7 @@ void OptionsWithRaw::SetFromString(llvm::StringRef arg_string) { // If the string doesn't start with a dash, we just have no options and just // a raw part. - if (!arg_string.startswith("-")) { + if (!arg_string.starts_with("-")) { m_suffix = std::string(original_args); return; } diff --git a/lldb/source/Utility/CompletionRequest.cpp b/lldb/source/Utility/CompletionRequest.cpp index 8f9dbb79d37bcf..e12609ca75e7d5 100644 --- a/lldb/source/Utility/CompletionRequest.cpp +++ b/lldb/source/Utility/CompletionRequest.cpp @@ -36,8 +36,8 @@ CompletionRequest::CompletionRequest(llvm::StringRef command_line, // The cursor is after a space but the space is not part of the argument. // Let's add an empty fake argument to the end to make sure the completion // code. Note: The space could be part of the last argument when it's quoted. - if (partial_command.endswith(" ") && - !GetCursorArgumentPrefix().endswith(" ")) + if (partial_command.ends_with(" ") && + !GetCursorArgumentPrefix().ends_with(" ")) AppendEmptyArgument(); } diff --git a/lldb/source/Utility/FileSpec.cpp b/lldb/source/Utility/FileSpec.cpp index 4bbfbb7c1fab5e..5387be9a681f68 100644 --- a/lldb/source/Utility/FileSpec.cpp +++ b/lldb/source/Utility/FileSpec.cpp @@ -311,9 +311,9 @@ bool FileSpec::Match(const FileSpec &pattern, const FileSpec &file) { std::optional<FileSpec::Style> FileSpec::GuessPathStyle(llvm::StringRef absolute_path) { - if (absolute_path.startswith("/")) + if (absolute_path.starts_with("/")) return Style::posix; - if (absolute_path.startswith(R"(\\)")) + if (absolute_path.starts_with(R"(\\)")) return Style::windows; if (absolute_path.size() >= 3 && llvm::isAlpha(absolute_path[0]) && (absolute_path.substr(1, 2) == R"(:\)" || diff --git a/lldb/source/Utility/FileSpecList.cpp b/lldb/source/Utility/FileSpecList.cpp index d5369ac4bbe516..e3d8ea650c75dc 100644 --- a/lldb/source/Utility/FileSpecList.cpp +++ b/lldb/source/Utility/FileSpecList.cpp @@ -117,7 +117,7 @@ size_t FileSpecList::FindCompatibleIndex(size_t start_idx, auto is_suffix = [](llvm::StringRef a, llvm::StringRef b, bool case_sensitive) -> bool { if (case_sensitive ? a.consume_back(b) : a.consume_back_insensitive(b)) - return a.empty() || a.endswith("/"); + return a.empty() || a.ends_with("/"); return false; }; const bool case_sensitive = diff --git a/lldb/source/Utility/NameMatches.cpp b/lldb/source/Utility/NameMatches.cpp index 1c8cd6a0ca31df..f002b86f163bf6 100644 --- a/lldb/source/Utility/NameMatches.cpp +++ b/lldb/source/Utility/NameMatches.cpp @@ -22,9 +22,9 @@ bool lldb_private::NameMatches(llvm::StringRef name, NameMatch match_type, case NameMatch::Contains: return name.contains(match); case NameMatch::StartsWith: - return name.startswith(match); + return name.starts_with(match); case NameMatch::EndsWith: - return name.endswith(match); + return name.ends_with(match); case NameMatch::RegularExpression: { RegularExpression regex(match); return regex.Execute(name); diff --git a/lldb/source/Utility/StringExtractor.cpp b/lldb/source/Utility/StringExtractor.cpp index c7e4ac79428426..579faa3da42f3d 100644 --- a/lldb/source/Utility/StringExtractor.cpp +++ b/lldb/source/Utility/StringExtractor.cpp @@ -254,7 +254,7 @@ uint64_t StringExtractor::GetHexMaxU64(bool little_endian, bool StringExtractor::ConsumeFront(const llvm::StringRef &str) { llvm::StringRef S = GetStringRef(); - if (!S.startswith(str)) + if (!S.starts_with(str)) return false; else m_index += str.size(); diff --git a/lldb/source/Utility/TildeExpressionResolver.cpp b/lldb/source/Utility/TildeExpressionResolver.cpp index 6311ae062f1f53..2e334b2aae540c 100644 --- a/lldb/source/Utility/TildeExpressionResolver.cpp +++ b/lldb/source/Utility/TildeExpressionResolver.cpp @@ -60,7 +60,7 @@ bool StandardTildeExpressionResolver::ResolvePartial(StringRef Expr, while ((user_entry = getpwent()) != nullptr) { StringRef ThisName(user_entry->pw_name); - if (!ThisName.startswith(Expr)) + if (!ThisName.starts_with(Expr)) continue; Buffer.resize(1); @@ -75,7 +75,7 @@ bool StandardTildeExpressionResolver::ResolvePartial(StringRef Expr, bool TildeExpressionResolver::ResolveFullPath( StringRef Expr, llvm::SmallVectorImpl<char> &Output) { - if (!Expr.startswith("~")) { + if (!Expr.starts_with("~")) { Output.assign(Expr.begin(), Expr.end()); return false; } diff --git a/lldb/source/Utility/XcodeSDK.cpp b/lldb/source/Utility/XcodeSDK.cpp index 154ddbebe8b30d..d744336373b23b 100644 --- a/lldb/source/Utility/XcodeSDK.cpp +++ b/lldb/source/Utility/XcodeSDK.cpp @@ -152,7 +152,7 @@ void XcodeSDK::Merge(const XcodeSDK &other) { *this = other; else { // The Internal flag always wins. - if (llvm::StringRef(m_name).endswith(".sdk")) + if (llvm::StringRef(m_name).ends_with(".sdk")) if (!l.internal && r.internal) m_name = m_name.substr(0, m_name.size() - 3) + std::string("Internal.sdk"); @@ -291,7 +291,7 @@ std::string XcodeSDK::FindXcodeContentsDirectoryInPath(llvm::StringRef path) { // .app. If the next component is Contents then we've found the Contents // directory. for (auto it = begin; it != end; ++it) { - if (it->endswith(".app")) { + if (it->ends_with(".app")) { auto next = it; if (++next != end && *next == "Contents") { llvm::SmallString<128> buffer; diff --git a/lldb/tools/lldb-dap/IOStream.cpp b/lldb/tools/lldb-dap/IOStream.cpp index 897ab791ed062d..96e9a1ed49532f 100644 --- a/lldb/tools/lldb-dap/IOStream.cpp +++ b/lldb/tools/lldb-dap/IOStream.cpp @@ -138,7 +138,7 @@ bool InputStream::read_line(std::ofstream *log, std::string &line) { if (!read_full(log, 1, line)) return false; - if (llvm::StringRef(line).endswith("\r\n")) + if (llvm::StringRef(line).ends_with("\r\n")) break; } line.erase(line.size() - 2); diff --git a/lldb/tools/lldb-dap/JSONUtils.cpp b/lldb/tools/lldb-dap/JSONUtils.cpp index c8e5304ecec81a..a0a175f960bcf1 100644 --- a/lldb/tools/lldb-dap/JSONUtils.cpp +++ b/lldb/tools/lldb-dap/JSONUtils.cpp @@ -455,8 +455,9 @@ llvm::json::Value CreateBreakpoint(lldb::SBBreakpoint &bp, static uint64_t GetDebugInfoSizeInSection(lldb::SBSection section) { uint64_t debug_info_size = 0; llvm::StringRef section_name(section.GetName()); - if (section_name.startswith(".debug") || section_name.startswith("__debug") || - section_name.startswith(".apple") || section_name.startswith("__apple")) + if (section_name.starts_with(".debug") || + section_name.starts_with("__debug") || + section_name.starts_with(".apple") || section_name.starts_with("__apple")) debug_info_size += section.GetFileByteSize(); size_t num_sub_sections = section.GetNumSubSections(); for (size_t i = 0; i < num_sub_sections; i++) { diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp index d36e9b4d1b0982..75b3948b5efb7b 100644 --- a/lldb/tools/lldb-dap/lldb-dap.cpp +++ b/lldb/tools/lldb-dap/lldb-dap.cpp @@ -3094,7 +3094,7 @@ void request_setVariable(const llvm::json::Object &request) { lldb::SBValue container = g_dap.variables.GetVariable(variablesReference); variable = container.GetChildMemberWithName(name.data()); if (!variable.IsValid()) { - if (name.startswith("[")) { + if (name.starts_with("[")) { llvm::StringRef index_str(name.drop_front(1)); uint64_t index = 0; if (!index_str.consumeInteger(0, index)) { diff --git a/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp b/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp index 77bd85bcb942c7..1c07119d4497fe 100644 --- a/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp +++ b/lldb/unittests/Expression/ClangExpressionDeclMapTest.cpp @@ -35,7 +35,7 @@ struct FakeClangExpressionDeclMap : public ClangExpressionDeclMap { // The declaration needs to have '$' prefix in its name like every // persistent declaration and must be inside the scratch AST context. assert(d); - assert(d->getName().startswith("$")); + assert(d->getName().starts_with("$")); assert(&d->getASTContext() == &m_scratch_context->getASTContext()); m_persistent_decls[d->getName()] = d; } diff --git a/lldb/unittests/Process/minidump/RegisterContextMinidumpTest.cpp b/lldb/unittests/Process/minidump/RegisterContextMinidumpTest.cpp index 0bacd882d8e89f..f179ded7fa6b6e 100644 --- a/lldb/unittests/Process/minidump/RegisterContextMinidumpTest.cpp +++ b/lldb/unittests/Process/minidump/RegisterContextMinidumpTest.cpp @@ -152,7 +152,7 @@ static void TestARMRegInfo(const lldb_private::RegisterInfo *info) { // correctly when using this information. llvm::StringRef name(info->name); llvm::StringRef alt_name(info->alt_name); - if (name.startswith("r") || alt_name.startswith("r")) { + if (name.starts_with("r") || alt_name.starts_with("r")) { EXPECT_NE(info->kinds[lldb::eRegisterKindEHFrame], LLDB_INVALID_REGNUM); EXPECT_NE(info->kinds[lldb::eRegisterKindDWARF], LLDB_INVALID_REGNUM); } diff --git a/lldb/unittests/TestingSupport/MockTildeExpressionResolver.cpp b/lldb/unittests/TestingSupport/MockTildeExpressionResolver.cpp index 0e64e1977ca44a..08381b34e6769f 100644 --- a/lldb/unittests/TestingSupport/MockTildeExpressionResolver.cpp +++ b/lldb/unittests/TestingSupport/MockTildeExpressionResolver.cpp @@ -69,7 +69,7 @@ bool MockTildeExpressionResolver::ResolvePartial(StringRef Expr, SmallString<16> QualifiedName("~"); for (const auto &User : UserDirectories) { - if (!User.getKey().startswith(Expr)) + if (!User.getKey().starts_with(Expr)) continue; QualifiedName.resize(1); QualifiedName.append(User.getKey().begin(), User.getKey().end()); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits