diff --git a/lldb/include/lldb/Interpreter/OptionValueRegex.h b/lldb/include/lldb/Interpreter/OptionValueRegex.h --- a/lldb/include/lldb/Interpreter/OptionValueRegex.h +++ b/lldb/include/lldb/Interpreter/OptionValueRegex.h @@ -17,8 +17,7 @@ class OptionValueRegex : public Cloneable { public: OptionValueRegex(const char *value = nullptr) - : m_regex(llvm::StringRef::withNullAsEmpty(value)), - m_default_regex_str(llvm::StringRef::withNullAsEmpty(value).str()) {} + : m_regex(value), m_default_regex_str(value) {} ~OptionValueRegex() override = default; diff --git a/lldb/include/lldb/Interpreter/OptionValueString.h b/lldb/include/lldb/Interpreter/OptionValueString.h --- a/lldb/include/lldb/Interpreter/OptionValueString.h +++ b/lldb/include/lldb/Interpreter/OptionValueString.h @@ -85,7 +85,7 @@ const Flags &GetOptions() const { return m_options; } const char *operator=(const char *value) { - SetCurrentValue(llvm::StringRef::withNullAsEmpty(value)); + SetCurrentValue(value); return m_current_value.c_str(); } diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1387,7 +1387,7 @@ LLDB_RECORD_METHOD(void, SBDebugger, SetPrompt, (const char *), prompt); if (m_opaque_sp) - m_opaque_sp->SetPrompt(llvm::StringRef::withNullAsEmpty(prompt)); + m_opaque_sp->SetPrompt(llvm::StringRef(prompt)); } const char *SBDebugger::GetReproducerPath() const { diff --git a/lldb/source/API/SBLanguageRuntime.cpp b/lldb/source/API/SBLanguageRuntime.cpp --- a/lldb/source/API/SBLanguageRuntime.cpp +++ b/lldb/source/API/SBLanguageRuntime.cpp @@ -18,8 +18,7 @@ LLDB_RECORD_STATIC_METHOD(lldb::LanguageType, SBLanguageRuntime, GetLanguageTypeFromString, (const char *), string); - return Language::GetLanguageTypeFromString( - llvm::StringRef::withNullAsEmpty(string)); + return Language::GetLanguageTypeFromString(llvm::StringRef(string)); } const char * diff --git a/lldb/source/API/SBPlatform.cpp b/lldb/source/API/SBPlatform.cpp --- a/lldb/source/API/SBPlatform.cpp +++ b/lldb/source/API/SBPlatform.cpp @@ -413,8 +413,7 @@ PlatformSP platform_sp(GetSP()); if (platform_sp && connect_options.GetURL()) { Args args; - args.AppendArgument( - llvm::StringRef::withNullAsEmpty(connect_options.GetURL())); + args.AppendArgument(connect_options.GetURL()); sb_error.ref() = platform_sp->ConnectRemote(args); } else { sb_error.SetErrorString("invalid platform"); diff --git a/lldb/source/API/SBTypeCategory.cpp b/lldb/source/API/SBTypeCategory.cpp --- a/lldb/source/API/SBTypeCategory.cpp +++ b/lldb/source/API/SBTypeCategory.cpp @@ -363,9 +363,7 @@ if (type_name.IsRegex()) m_opaque_sp->GetRegexTypeFormatsContainer()->Add( - RegularExpression( - llvm::StringRef::withNullAsEmpty(type_name.GetName())), - format.GetSP()); + RegularExpression(type_name.GetName()), format.GetSP()); else m_opaque_sp->GetTypeFormatsContainer()->Add( ConstString(type_name.GetName()), format.GetSP()); @@ -442,9 +440,7 @@ if (type_name.IsRegex()) m_opaque_sp->GetRegexTypeSummariesContainer()->Add( - RegularExpression( - llvm::StringRef::withNullAsEmpty(type_name.GetName())), - summary.GetSP()); + RegularExpression(type_name.GetName()), summary.GetSP()); else m_opaque_sp->GetTypeSummariesContainer()->Add( ConstString(type_name.GetName()), summary.GetSP()); @@ -487,9 +483,7 @@ if (type_name.IsRegex()) m_opaque_sp->GetRegexTypeFiltersContainer()->Add( - RegularExpression( - llvm::StringRef::withNullAsEmpty(type_name.GetName())), - filter.GetSP()); + RegularExpression(type_name.GetName()), filter.GetSP()); else m_opaque_sp->GetTypeFiltersContainer()->Add( ConstString(type_name.GetName()), filter.GetSP()); @@ -566,9 +560,7 @@ if (type_name.IsRegex()) m_opaque_sp->GetRegexTypeSyntheticsContainer()->Add( - RegularExpression( - llvm::StringRef::withNullAsEmpty(type_name.GetName())), - synth.GetSP()); + RegularExpression(type_name.GetName()), synth.GetSP()); else m_opaque_sp->GetTypeSyntheticsContainer()->Add( ConstString(type_name.GetName()), synth.GetSP()); diff --git a/lldb/source/Breakpoint/BreakpointResolverName.cpp b/lldb/source/Breakpoint/BreakpointResolverName.cpp --- a/lldb/source/Breakpoint/BreakpointResolverName.cpp +++ b/lldb/source/Breakpoint/BreakpointResolverName.cpp @@ -31,7 +31,7 @@ m_class_name(), m_regex(), m_match_type(type), m_language(language), m_skip_prologue(skip_prologue) { if (m_match_type == Breakpoint::Regexp) { - m_regex = RegularExpression(llvm::StringRef::withNullAsEmpty(name_cstr)); + m_regex = RegularExpression(name_cstr); if (!m_regex.IsValid()) { Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS)); diff --git a/lldb/source/Commands/CommandObjectFrame.cpp b/lldb/source/Commands/CommandObjectFrame.cpp --- a/lldb/source/Commands/CommandObjectFrame.cpp +++ b/lldb/source/Commands/CommandObjectFrame.cpp @@ -460,7 +460,7 @@ protected: llvm::StringRef GetScopeString(VariableSP var_sp) { if (!var_sp) - return llvm::StringRef::withNullAsEmpty(nullptr); + return llvm::StringRef(); switch (var_sp->GetScope()) { case eValueTypeVariableGlobal: @@ -477,7 +477,7 @@ break; } - return llvm::StringRef::withNullAsEmpty(nullptr); + return llvm::StringRef(); } bool DoExecute(Args &command, CommandReturnObject &result) override { diff --git a/lldb/source/Commands/CommandObjectTarget.cpp b/lldb/source/Commands/CommandObjectTarget.cpp --- a/lldb/source/Commands/CommandObjectTarget.cpp +++ b/lldb/source/Commands/CommandObjectTarget.cpp @@ -848,8 +848,7 @@ size_t matches = 0; bool use_var_name = false; if (m_option_variable.use_regex) { - RegularExpression regex( - llvm::StringRef::withNullAsEmpty(arg.c_str())); + RegularExpression regex(arg.ref()); if (!regex.IsValid()) { result.GetErrorStream().Printf( "error: invalid regular expression: '%s'\n", arg.c_str()); diff --git a/lldb/source/Commands/CommandObjectType.cpp b/lldb/source/Commands/CommandObjectType.cpp --- a/lldb/source/Commands/CommandObjectType.cpp +++ b/lldb/source/Commands/CommandObjectType.cpp @@ -1080,8 +1080,7 @@ if (argc == 1) { const char *arg = command.GetArgumentAtIndex(0); - formatter_regex = std::make_unique( - llvm::StringRef::withNullAsEmpty(arg)); + formatter_regex = std::make_unique(arg); if (!formatter_regex->IsValid()) { result.AppendErrorWithFormat("syntax error in regular expression '%s'", arg); @@ -1167,9 +1166,7 @@ bool escape = true; if (category->GetName() == category_regex->GetText()) { escape = false; - } else if (category_regex->Execute( - llvm::StringRef::withNullAsEmpty( - category->GetName()))) { + } else if (category_regex->Execute(category->GetName())) { escape = false; } @@ -2175,8 +2172,7 @@ if (argc == 1) { const char *arg = command.GetArgumentAtIndex(0); - regex = std::make_unique( - llvm::StringRef::withNullAsEmpty(arg)); + regex = std::make_unique(arg); if (!regex->IsValid()) { result.AppendErrorWithFormat( "syntax error in category regular expression '%s'", arg); @@ -2196,8 +2192,7 @@ bool escape = true; if (regex->GetText() == category_sp->GetName()) { escape = false; - } else if (regex->Execute(llvm::StringRef::withNullAsEmpty( - category_sp->GetName()))) { + } else if (regex->Execute(category_sp->GetName())) { escape = false; } diff --git a/lldb/source/Interpreter/CommandInterpreter.cpp b/lldb/source/Interpreter/CommandInterpreter.cpp --- a/lldb/source/Interpreter/CommandInterpreter.cpp +++ b/lldb/source/Interpreter/CommandInterpreter.cpp @@ -2986,9 +2986,9 @@ IOHandlerSP io_handler_sp( new IOHandlerEditline(debugger, IOHandler::Type::CommandList, "lldb", // Name of input reader for history - llvm::StringRef::withNullAsEmpty(prompt), // Prompt - llvm::StringRef(), // Continuation prompt - true, // Get multiple lines + llvm::StringRef(prompt), // Prompt + llvm::StringRef(), // Continuation prompt + true, // Get multiple lines debugger.GetUseColor(), 0, // Don't show line numbers delegate, // IOHandlerDelegate @@ -3006,9 +3006,9 @@ IOHandlerSP io_handler_sp( new IOHandlerEditline(debugger, IOHandler::Type::PythonCode, "lldb-python", // Name of input reader for history - llvm::StringRef::withNullAsEmpty(prompt), // Prompt - llvm::StringRef(), // Continuation prompt - true, // Get multiple lines + llvm::StringRef(prompt), // Prompt + llvm::StringRef(), // Continuation prompt + true, // Get multiple lines debugger.GetUseColor(), 0, // Don't show line numbers delegate, // IOHandlerDelegate diff --git a/lldb/source/Interpreter/OptionValue.cpp b/lldb/source/Interpreter/OptionValue.cpp --- a/lldb/source/Interpreter/OptionValue.cpp +++ b/lldb/source/Interpreter/OptionValue.cpp @@ -543,8 +543,7 @@ } if (value_sp) - error = value_sp->SetValueFromString( - llvm::StringRef::withNullAsEmpty(value_cstr), eVarSetOperationAssign); + error = value_sp->SetValueFromString(value_cstr, eVarSetOperationAssign); else error.SetErrorString("unsupported type mask"); return value_sp; diff --git a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp --- a/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp +++ b/lldb/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp @@ -663,8 +663,8 @@ case 0: break; case 1: { - regex_up = std::make_unique( - llvm::StringRef::withNullAsEmpty(command.GetArgumentAtIndex(0))); + regex_up = + std::make_unique(command.GetArgumentAtIndex(0)); if (!regex_up->IsValid()) { result.AppendError( "invalid argument - please provide a valid regular expression"); diff --git a/lldb/source/Target/ThreadPlanStepInRange.cpp b/lldb/source/Target/ThreadPlanStepInRange.cpp --- a/lldb/source/Target/ThreadPlanStepInRange.cpp +++ b/lldb/source/Target/ThreadPlanStepInRange.cpp @@ -291,11 +291,10 @@ } void ThreadPlanStepInRange::SetAvoidRegexp(const char *name) { - auto name_ref = llvm::StringRef::withNullAsEmpty(name); if (m_avoid_regexp_up) - *m_avoid_regexp_up = RegularExpression(name_ref); + *m_avoid_regexp_up = RegularExpression(name); else - m_avoid_regexp_up = std::make_unique(name_ref); + m_avoid_regexp_up = std::make_unique(name); } void ThreadPlanStepInRange::SetDefaultFlagValue(uint32_t new_value) {