[Lldb-commits] [lldb] r282079 - Make lldb::Regex use StringRef.

Greg Clayton via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 21 17:00:17 PDT 2016


Please submit a change requests when doing these kinds of things and let people comment on the changes before committing such things.

We deleted functions that were correctly using "const char *" like:

  bool Execute(llvm::StringRef string, Match *match = nullptr) const;
  bool Execute(const char *, Match * = nullptr) = delete;

Yet inside these functions you do "string.str().c_str()" because these need to be null terminated? this indicates that StringRef is NOT the correct choice here. You will make heap copy of all strings (if they are long enough and regex matching string can be very long) that you compile or execute. We already make a copy of the string when we compile, so StringRef didn't really save us anything on compile and execute is always making a copy just to run the expression on. I am fine with both being there in case one might be more efficient, but taking them out just to use a less efficient version that uses llvm::StringRef is not the kind of changes we should be doing all over.

We will make copies of all strings in all of the following changes:

- Unneeded copy:

-        new TypeNameSpecifierImpl(regex->GetText(), true));
+        new TypeNameSpecifierImpl(regex->GetText().str().c_str(), true));


- Unneeded copy just to print in print (there are tons of these):

void BreakpointResolverFileRegex::GetDescription(Stream *s) {
-  s->Printf("source regex = \"%s\", exact_match = %d", m_regex.GetText(),
-            m_exact_match);
+  s->Printf("source regex = \"%s\", exact_match = %d",
+            m_regex.GetText().str().c_str(), m_exact_match);
}

If you use a StringRef in printf, please use "%*s" and then put the count and data pointer into the printf, so the above line would become:

+  s->Printf("source regex = \"%*s\", exact_match = %d",
+            (int)m_regex.GetText().size(), m_regex.GetText().data(), m_exact_match);


- Unneeded copy:

lldb::OptionValueSP OptionValueRegex::DeepCopy() const {
-  return OptionValueSP(new OptionValueRegex(m_regex.GetText()));
+  return OptionValueSP(new OptionValueRegex(m_regex.GetText().str().c_str()));
}

So please submit things for review before committing them so we can catch things like this.

Things I would like to see fixed:
- convert all Printf functions that are not in "if (log) log->Printf(...)" (which eliminates most of the changes you need to make) uses of StringRef over to use the "%*s" and be careful that the "*" requires an integer length, not a size_t length, so you will need to cast the size of the string to int.
- Revert changing RegularExpression::Execute over to using StringRef as it is the wrong thing to do
- Either convert functions over to use StringRef as parameters so we can avoid extra copies (anything that calls "str().c_str()" in a parameters to functions) or revert back to "const char *" and don't use StringRef

> On Sep 21, 2016, at 9:01 AM, Zachary Turner via lldb-commits <lldb-commits at lists.llvm.org> wrote:
> 
> Author: zturner
> Date: Wed Sep 21 11:01:28 2016
> New Revision: 282079
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=282079&view=rev
> Log:
> Make lldb::Regex use StringRef.
> 
> This updates getters and setters to use StringRef instead of
> const char *.  I tested the build on Linux, Windows, and OSX
> and saw no build or test failures.  I cannot test any BSD
> or Android variants, however I expect the required changes
> to be minimal or non-existant.
> 
> Modified:
>    lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h
>    lldb/trunk/include/lldb/Core/RegularExpression.h
>    lldb/trunk/include/lldb/Core/Stream.h
>    lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h
>    lldb/trunk/include/lldb/Interpreter/OptionValueRegex.h
>    lldb/trunk/include/lldb/Interpreter/OptionValueString.h
>    lldb/trunk/source/API/SBTarget.cpp
>    lldb/trunk/source/API/SBTypeCategory.cpp
>    lldb/trunk/source/Breakpoint/BreakpointResolver.cpp
>    lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
>    lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp
>    lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
>    lldb/trunk/source/Commands/CommandCompletions.cpp
>    lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
>    lldb/trunk/source/Commands/CommandObjectFrame.cpp
>    lldb/trunk/source/Commands/CommandObjectTarget.cpp
>    lldb/trunk/source/Commands/CommandObjectType.cpp
>    lldb/trunk/source/Core/AddressResolverName.cpp
>    lldb/trunk/source/Core/Disassembler.cpp
>    lldb/trunk/source/Core/Module.cpp
>    lldb/trunk/source/Core/RegularExpression.cpp
>    lldb/trunk/source/Core/SourceManager.cpp
>    lldb/trunk/source/DataFormatters/FormatManager.cpp
>    lldb/trunk/source/DataFormatters/FormattersHelpers.cpp
>    lldb/trunk/source/Host/common/FileSpec.cpp
>    lldb/trunk/source/Host/common/Socket.cpp
>    lldb/trunk/source/Interpreter/Args.cpp
>    lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp
>    lldb/trunk/source/Interpreter/OptionValueRegex.cpp
>    lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
>    lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
>    lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
>    lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
>    lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
>    lldb/trunk/source/Plugins/Language/Java/JavaLanguage.cpp
>    lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
>    lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
>    lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
>    lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
>    lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
>    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
>    lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
>    lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
>    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
>    lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
>    lldb/trunk/source/Symbol/ObjectFile.cpp
>    lldb/trunk/source/Symbol/Variable.cpp
>    lldb/trunk/source/Target/ThreadPlanStepInRange.cpp
>    lldb/trunk/source/Utility/NameMatches.cpp
> 
> Modified: lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h (original)
> +++ lldb/trunk/include/lldb/Breakpoint/BreakpointResolver.h Wed Sep 21 11:01:28 2016
> @@ -236,7 +236,9 @@ protected:
>   /// so, and then set
>   /// breakpoint locations in this breakpoint for all the resultant addresses.
>   void SetSCMatchesByLine(SearchFilter &filter, SymbolContextList &sc_list,
> -                          bool skip_prologue, const char *log_ident);
> +                          bool skip_prologue, llvm::StringRef log_ident);
> +  void SetSCMatchesByLine(SearchFilter &, SymbolContextList &, bool,
> +                          const char *) = delete;
> 
>   lldb::BreakpointLocationSP AddLocation(Address loc_addr,
>                                          bool *new_location = NULL);
> 
> Modified: lldb/trunk/include/lldb/Core/RegularExpression.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/RegularExpression.h?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/include/lldb/Core/RegularExpression.h (original)
> +++ lldb/trunk/include/lldb/Core/RegularExpression.h Wed Sep 21 11:01:28 2016
> @@ -99,7 +99,8 @@ public:
>   //------------------------------------------------------------------
>   RegularExpression();
> 
> -  explicit RegularExpression(const char *re);
> +  explicit RegularExpression(llvm::StringRef string);
> +  explicit RegularExpression(const char *) = delete;
> 
>   //------------------------------------------------------------------
>   /// Destructor.
> @@ -131,7 +132,8 @@ public:
>   ///     \b true if the regular expression compiles successfully,
>   ///     \b false otherwise.
>   //------------------------------------------------------------------
> -  bool Compile(const char *re);
> +  bool Compile(llvm::StringRef string);
> +  bool Compile(const char *) = delete;
> 
>   //------------------------------------------------------------------
>   /// Executes a regular expression.
> @@ -154,7 +156,8 @@ public:
>   ///     \b true if \a string matches the compiled regular
>   ///     expression, \b false otherwise.
>   //------------------------------------------------------------------
> -  bool Execute(const char *string, Match *match = nullptr) const;
> +  bool Execute(llvm::StringRef string, Match *match = nullptr) const;
> +  bool Execute(const char *, Match * = nullptr) = delete;
> 
>   size_t GetErrorAsCString(char *err_str, size_t err_str_max_len) const;
> 
> @@ -176,7 +179,7 @@ public:
>   ///     The NULL terminated C string that was used to compile the
>   ///     current regular expression
>   //------------------------------------------------------------------
> -  const char *GetText() const;
> +  llvm::StringRef GetText() const;
> 
>   //------------------------------------------------------------------
>   /// Test if valid.
> 
> Modified: lldb/trunk/include/lldb/Core/Stream.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/Stream.h?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/include/lldb/Core/Stream.h (original)
> +++ lldb/trunk/include/lldb/Core/Stream.h Wed Sep 21 11:01:28 2016
> @@ -123,7 +123,7 @@ public:
>   ///     The number of bytes that were appended to the stream.
>   //------------------------------------------------------------------
>   size_t PrintfAsRawHex8(const char *format, ...)
> -      __attribute__((format(printf, 2, 3)));
> +      __attribute__((__format__(__printf__, 2, 3)));
> 
>   //------------------------------------------------------------------
>   /// Format a C string from a printf style format and variable
> 
> Modified: lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h (original)
> +++ lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h Wed Sep 21 11:01:28 2016
> @@ -259,7 +259,7 @@ protected:
>     MapIterator pos, end = m_format_map.map().end();
>     for (pos = m_format_map.map().begin(); pos != end; pos++) {
>       lldb::RegularExpressionSP regex = pos->first;
> -      if (::strcmp(type.AsCString(), regex->GetText()) == 0) {
> +      if (type.GetStringRef() == regex->GetText()) {
>         m_format_map.map().erase(pos);
>         if (m_format_map.listener)
>           m_format_map.listener->Changed();
> @@ -295,19 +295,17 @@ protected:
>     if (regex.get() == nullptr)
>       return lldb::TypeNameSpecifierImplSP();
>     return lldb::TypeNameSpecifierImplSP(
> -        new TypeNameSpecifierImpl(regex->GetText(), true));
> +        new TypeNameSpecifierImpl(regex->GetText().str().c_str(), true));
>   }
> 
>   bool Get_Impl(ConstString key, MapValueType &value,
>                 lldb::RegularExpressionSP *dummy) {
> -    const char *key_cstr = key.AsCString();
> -    if (!key_cstr)
> -      return false;
> +    llvm::StringRef key_str = key.GetStringRef();
>     std::lock_guard<std::recursive_mutex> guard(m_format_map.mutex());
>     MapIterator pos, end = m_format_map.map().end();
>     for (pos = m_format_map.map().begin(); pos != end; pos++) {
>       lldb::RegularExpressionSP regex = pos->first;
> -      if (regex->Execute(key_cstr)) {
> +      if (regex->Execute(key_str)) {
>         value = pos->second;
>         return true;
>       }
> @@ -321,7 +319,7 @@ protected:
>     MapIterator pos, end = m_format_map.map().end();
>     for (pos = m_format_map.map().begin(); pos != end; pos++) {
>       lldb::RegularExpressionSP regex = pos->first;
> -      if (strcmp(regex->GetText(), key.AsCString()) == 0) {
> +      if (regex->GetText() == key.GetStringRef()) {
>         value = pos->second;
>         return true;
>       }
> 
> Modified: lldb/trunk/include/lldb/Interpreter/OptionValueRegex.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionValueRegex.h?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/include/lldb/Interpreter/OptionValueRegex.h (original)
> +++ lldb/trunk/include/lldb/Interpreter/OptionValueRegex.h Wed Sep 21 11:01:28 2016
> @@ -22,7 +22,7 @@ namespace lldb_private {
> class OptionValueRegex : public OptionValue {
> public:
>   OptionValueRegex(const char *value = nullptr)
> -      : OptionValue(), m_regex(value) {}
> +      : OptionValue(), m_regex(llvm::StringRef::withNullAsEmpty(value)) {}
> 
>   ~OptionValueRegex() override = default;
> 
> @@ -56,7 +56,7 @@ public:
> 
>   void SetCurrentValue(const char *value) {
>     if (value && value[0])
> -      m_regex.Compile(value);
> +      m_regex.Compile(llvm::StringRef(value));
>     else
>       m_regex.Clear();
>   }
> 
> Modified: lldb/trunk/include/lldb/Interpreter/OptionValueString.h
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Interpreter/OptionValueString.h?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/include/lldb/Interpreter/OptionValueString.h (original)
> +++ lldb/trunk/include/lldb/Interpreter/OptionValueString.h Wed Sep 21 11:01:28 2016
> @@ -110,8 +110,10 @@ public:
>   }
> 
>   const char *GetCurrentValue() const { return m_current_value.c_str(); }
> +  llvm::StringRef GetCurrentValueAsRef() const { return m_current_value; }
> 
>   const char *GetDefaultValue() const { return m_default_value.c_str(); }
> +  llvm::StringRef GetDefaultValueAsRef() const { return m_default_value; }
> 
>   Error SetCurrentValue(const char *value);
> 
> 
> Modified: lldb/trunk/source/API/SBTarget.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/API/SBTarget.cpp (original)
> +++ lldb/trunk/source/API/SBTarget.cpp Wed Sep 21 11:01:28 2016
> @@ -869,7 +869,7 @@ lldb::SBBreakpoint SBTarget::BreakpointC
>   TargetSP target_sp(GetSP());
>   if (target_sp && symbol_name_regex && symbol_name_regex[0]) {
>     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
> -    RegularExpression regexp(symbol_name_regex);
> +    RegularExpression regexp((llvm::StringRef(symbol_name_regex)));
>     const bool internal = false;
>     const bool hardware = false;
>     const LazyBool skip_prologue = eLazyBoolCalculate;
> @@ -978,7 +978,7 @@ lldb::SBBreakpoint SBTarget::BreakpointC
>     std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
>     const bool hardware = false;
>     const LazyBool move_to_nearest_code = eLazyBoolCalculate;
> -    RegularExpression regexp(source_regex);
> +    RegularExpression regexp((llvm::StringRef(source_regex)));
>     std::unordered_set<std::string> func_names_set;
>     for (size_t i = 0; i < func_names.GetSize(); i++) {
>       func_names_set.insert(func_names.GetStringAtIndex(i));
> @@ -1599,18 +1599,19 @@ lldb::SBSymbolContextList SBTarget::Find
>                                                         MatchType matchtype) {
>   lldb::SBSymbolContextList sb_sc_list;
>   if (name && name[0]) {
> +    llvm::StringRef name_ref(name);
>     TargetSP target_sp(GetSP());
>     if (target_sp) {
>       std::string regexstr;
>       switch (matchtype) {
>       case eMatchTypeRegex:
> -        target_sp->GetImages().FindFunctions(RegularExpression(name), true,
> +        target_sp->GetImages().FindFunctions(RegularExpression(name_ref), true,
>                                              true, true, *sb_sc_list);
>         break;
>       case eMatchTypeStartsWith:
>         regexstr = llvm::Regex::escape(name) + ".*";
> -        target_sp->GetImages().FindFunctions(
> -            RegularExpression(regexstr.c_str()), true, true, true, *sb_sc_list);
> +        target_sp->GetImages().FindFunctions(RegularExpression(regexstr), true,
> +                                             true, true, *sb_sc_list);
>         break;
>       default:
>         target_sp->GetImages().FindFunctions(ConstString(name),
> @@ -1778,6 +1779,7 @@ SBValueList SBTarget::FindGlobalVariable
> 
>   TargetSP target_sp(GetSP());
>   if (name && target_sp) {
> +    llvm::StringRef name_ref(name);
>     VariableList variable_list;
>     const bool append = true;
> 
> @@ -1790,13 +1792,12 @@ SBValueList SBTarget::FindGlobalVariable
>       break;
>     case eMatchTypeRegex:
>       match_count = target_sp->GetImages().FindGlobalVariables(
> -          RegularExpression(name), append, max_matches, variable_list);
> +          RegularExpression(name_ref), append, max_matches, variable_list);
>       break;
>     case eMatchTypeStartsWith:
>       regexstr = llvm::Regex::escape(name) + ".*";
>       match_count = target_sp->GetImages().FindGlobalVariables(
> -          RegularExpression(regexstr.c_str()), append, max_matches,
> -          variable_list);
> +          RegularExpression(regexstr), append, max_matches, variable_list);
>       break;
>     }
> 
> 
> Modified: lldb/trunk/source/API/SBTypeCategory.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeCategory.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/API/SBTypeCategory.cpp (original)
> +++ lldb/trunk/source/API/SBTypeCategory.cpp Wed Sep 21 11:01:28 2016
> @@ -301,7 +301,8 @@ bool SBTypeCategory::AddTypeFormat(SBTyp
> 
>   if (type_name.IsRegex())
>     m_opaque_sp->GetRegexTypeFormatsContainer()->Add(
> -        lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())),
> +        lldb::RegularExpressionSP(new RegularExpression(
> +            llvm::StringRef::withNullAsEmpty(type_name.GetName()))),
>         format.GetSP());
>   else
>     m_opaque_sp->GetTypeFormatsContainer()->Add(
> @@ -373,7 +374,8 @@ bool SBTypeCategory::AddTypeSummary(SBTy
> 
>   if (type_name.IsRegex())
>     m_opaque_sp->GetRegexTypeSummariesContainer()->Add(
> -        lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())),
> +        lldb::RegularExpressionSP(new RegularExpression(
> +            llvm::StringRef::withNullAsEmpty(type_name.GetName()))),
>         summary.GetSP());
>   else
>     m_opaque_sp->GetTypeSummariesContainer()->Add(
> @@ -411,7 +413,8 @@ bool SBTypeCategory::AddTypeFilter(SBTyp
> 
>   if (type_name.IsRegex())
>     m_opaque_sp->GetRegexTypeFiltersContainer()->Add(
> -        lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())),
> +        lldb::RegularExpressionSP(new RegularExpression(
> +            llvm::StringRef::withNullAsEmpty(type_name.GetName()))),
>         filter.GetSP());
>   else
>     m_opaque_sp->GetTypeFiltersContainer()->Add(
> @@ -483,7 +486,8 @@ bool SBTypeCategory::AddTypeSynthetic(SB
> 
>   if (type_name.IsRegex())
>     m_opaque_sp->GetRegexTypeSyntheticsContainer()->Add(
> -        lldb::RegularExpressionSP(new RegularExpression(type_name.GetName())),
> +        lldb::RegularExpressionSP(new RegularExpression(
> +            llvm::StringRef::withNullAsEmpty(type_name.GetName()))),
>         synth.GetSP());
>   else
>     m_opaque_sp->GetTypeSyntheticsContainer()->Add(
> 
> Modified: lldb/trunk/source/Breakpoint/BreakpointResolver.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolver.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Breakpoint/BreakpointResolver.cpp (original)
> +++ lldb/trunk/source/Breakpoint/BreakpointResolver.cpp Wed Sep 21 11:01:28 2016
> @@ -179,7 +179,7 @@ void BreakpointResolver::ResolveBreakpoi
> void BreakpointResolver::SetSCMatchesByLine(SearchFilter &filter,
>                                             SymbolContextList &sc_list,
>                                             bool skip_prologue,
> -                                            const char *log_ident) {
> +                                            llvm::StringRef log_ident) {
>   Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
> 
>   while (sc_list.GetSize() > 0) {
> @@ -293,15 +293,14 @@ void BreakpointResolver::SetSCMatchesByL
>           } else if (log) {
>             log->Printf("Breakpoint %s at file address 0x%" PRIx64
>                         " didn't pass the filter.\n",
> -                        log_ident ? log_ident : "",
> -                        line_start.GetFileAddress());
> +                        log_ident.str().c_str(), line_start.GetFileAddress());
>           }
>         } else {
>           if (log)
>             log->Printf(
>                 "error: Unable to set breakpoint %s at file address 0x%" PRIx64
>                 "\n",
> -                log_ident ? log_ident : "", line_start.GetFileAddress());
> +                log_ident.str().c_str(), line_start.GetFileAddress());
>         }
>       }
>     }
> 
> Modified: lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp (original)
> +++ lldb/trunk/source/Breakpoint/BreakpointResolverFileLine.cpp Wed Sep 21 11:01:28 2016
> @@ -150,7 +150,7 @@ BreakpointResolverFileLine::SearchCallba
>   s.Printf("for %s:%d ", m_file_spec.GetFilename().AsCString("<Unknown>"),
>            m_line_number);
> 
> -  SetSCMatchesByLine(filter, sc_list, m_skip_prologue, s.GetData());
> +  SetSCMatchesByLine(filter, sc_list, m_skip_prologue, s.GetString());
> 
>   return Searcher::eCallbackReturnContinue;
> }
> 
> Modified: lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp (original)
> +++ lldb/trunk/source/Breakpoint/BreakpointResolverFileRegex.cpp Wed Sep 21 11:01:28 2016
> @@ -1,5 +1,4 @@
> -//===-- BreakpointResolverFileRegex.cpp --------------------------*- C++
> -//-*-===//
> +//===-- BreakpointResolverFileRegex.cpp -------------------------*- C++-*-===//
> //
> //                     The LLVM Compiler Infrastructure
> //
> @@ -48,7 +47,7 @@ BreakpointResolver *BreakpointResolverFi
>     error.SetErrorString("BRFR::CFSD: Couldn't find regex entry.");
>     return nullptr;
>   }
> -  RegularExpression regex(regex_string.c_str());
> +  RegularExpression regex(regex_string);
> 
>   bool exact_match;
>   success = options_dict.GetValueForKeyAsBoolean(
> @@ -163,8 +162,8 @@ Searcher::Depth BreakpointResolverFileRe
> }
> 
> void BreakpointResolverFileRegex::GetDescription(Stream *s) {
> -  s->Printf("source regex = \"%s\", exact_match = %d", m_regex.GetText(),
> -            m_exact_match);
> +  s->Printf("source regex = \"%s\", exact_match = %d",
> +            m_regex.GetText().str().c_str(), m_exact_match);
> }
> 
> void BreakpointResolverFileRegex::Dump(Stream *s) const {}
> 
> Modified: lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp (original)
> +++ lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp Wed Sep 21 11:01:28 2016
> @@ -35,7 +35,7 @@ BreakpointResolverName::BreakpointResolv
>       m_class_name(), m_regex(), m_match_type(type), m_language(language),
>       m_skip_prologue(skip_prologue) {
>   if (m_match_type == Breakpoint::Regexp) {
> -    if (!m_regex.Compile(name_cstr)) {
> +    if (!m_regex.Compile(llvm::StringRef::withNullAsEmpty(name_cstr))) {
>       Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
> 
>       if (log)
> @@ -126,7 +126,7 @@ BreakpointResolver *BreakpointResolverNa
>   success = options_dict.GetValueForKeyAsString(
>       GetKey(OptionNames::RegexString), regex_text);
>   if (success) {
> -    RegularExpression regex(regex_text.c_str());
> +    RegularExpression regex(regex_text);
>     return new BreakpointResolverName(bkpt, regex, language, offset,
>                                       skip_prologue);
>   } else {
> @@ -395,7 +395,7 @@ Searcher::Depth BreakpointResolverName::
> 
> void BreakpointResolverName::GetDescription(Stream *s) {
>   if (m_match_type == Breakpoint::Regexp)
> -    s->Printf("regex = '%s'", m_regex.GetText());
> +    s->Printf("regex = '%s'", m_regex.GetText().str().c_str());
>   else {
>     size_t num_names = m_lookups.size();
>     if (num_names == 1)
> 
> Modified: lldb/trunk/source/Commands/CommandCompletions.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandCompletions.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Commands/CommandCompletions.cpp (original)
> +++ lldb/trunk/source/Commands/CommandCompletions.cpp Wed Sep 21 11:01:28 2016
> @@ -511,7 +511,7 @@ CommandCompletions::SymbolCompleter::Sym
>     pos = regex_str.insert(pos, '\\');
>     pos = find_if(pos + 2, regex_str.end(), regex_chars);
>   }
> -  m_regex.Compile(regex_str.c_str());
> +  m_regex.Compile(regex_str);
> }
> 
> Searcher::Depth CommandCompletions::SymbolCompleter::GetDepth() {
> 
> Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
> +++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Wed Sep 21 11:01:28 2016
> @@ -529,7 +529,7 @@ protected:
>     case eSetTypeFunctionRegexp: // Breakpoint by regular expression function
>                                  // name
>       {
> -        RegularExpression regexp(m_options.m_func_regexp.c_str());
> +        RegularExpression regexp(m_options.m_func_regexp);
>         if (!regexp.IsValid()) {
>           char err_str[1024];
>           regexp.GetErrorAsCString(err_str, sizeof(err_str));
> @@ -564,7 +564,7 @@ protected:
>         }
>       }
> 
> -      RegularExpression regexp(m_options.m_source_text_regexp.c_str());
> +      RegularExpression regexp(m_options.m_source_text_regexp);
>       if (!regexp.IsValid()) {
>         char err_str[1024];
>         regexp.GetErrorAsCString(err_str, sizeof(err_str));
> 
> Modified: lldb/trunk/source/Commands/CommandObjectFrame.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectFrame.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Commands/CommandObjectFrame.cpp (original)
> +++ lldb/trunk/source/Commands/CommandObjectFrame.cpp Wed Sep 21 11:01:28 2016
> @@ -547,8 +547,9 @@ protected:
>              ++idx) {
>           if (m_option_variable.use_regex) {
>             const size_t regex_start_index = regex_var_list.GetSize();
> -            RegularExpression regex(name_cstr);
> -            if (regex.Compile(name_cstr)) {
> +            llvm::StringRef name_str(name_cstr);
> +            RegularExpression regex(name_str);
> +            if (regex.Compile(name_str)) {
>               size_t num_matches = 0;
>               const size_t num_new_regex_vars =
>                   variable_list->AppendVariablesIfUnique(regex, regex_var_list,
> 
> Modified: lldb/trunk/source/Commands/CommandObjectTarget.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectTarget.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Commands/CommandObjectTarget.cpp (original)
> +++ lldb/trunk/source/Commands/CommandObjectTarget.cpp Wed Sep 21 11:01:28 2016
> @@ -807,7 +807,7 @@ protected:
>         size_t matches = 0;
>         bool use_var_name = false;
>         if (m_option_variable.use_regex) {
> -          RegularExpression regex(arg);
> +          RegularExpression regex(llvm::StringRef::withNullAsEmpty(arg));
>           if (!regex.IsValid()) {
>             result.GetErrorStream().Printf(
>                 "error: invalid regular expression: '%s'\n", arg);
> @@ -941,7 +941,8 @@ protected:
>               } else if (sc.module_sp) {
>                 // Get all global variables for this module
>                 lldb_private::RegularExpression all_globals_regex(
> -                    "."); // Any global with at least one character
> +                    llvm::StringRef(
> +                        ".")); // Any global with at least one character
>                 VariableList variable_list;
>                 sc.module_sp->FindGlobalVariables(all_globals_regex, append,
>                                                   UINT32_MAX, variable_list);
> @@ -1517,7 +1518,7 @@ static uint32_t LookupSymbolInModule(Com
>         ConstString symbol_name(name);
>         uint32_t num_matches = 0;
>         if (name_is_regex) {
> -          RegularExpression name_regexp(name);
> +          RegularExpression name_regexp(symbol_name.GetStringRef());
>           num_matches = symtab->AppendSymbolIndexesMatchingRegExAndType(
>               name_regexp, eSymbolTypeAny, match_indexes);
>         } else {
> @@ -1579,7 +1580,7 @@ static size_t LookupFunctionInModule(Com
>     const bool append = true;
>     size_t num_matches = 0;
>     if (name_is_regex) {
> -      RegularExpression function_name_regex(name);
> +      RegularExpression function_name_regex((llvm::StringRef(name)));
>       num_matches = module->FindFunctions(function_name_regex, include_symbols,
>                                           include_inlines, append, sc_list);
>     } else {
> 
> Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
> +++ lldb/trunk/source/Commands/CommandObjectType.cpp Wed Sep 21 11:01:28 2016
> @@ -697,7 +697,7 @@ protected:
>       if (typeCS) {
>         if (m_command_options.m_regex) {
>           RegularExpressionSP typeRX(new RegularExpression());
> -          if (!typeRX->Compile(typeCS.GetCString())) {
> +          if (!typeRX->Compile(typeCS.GetStringRef())) {
>             result.AppendError(
>                 "regex format error (maybe this is not really a regex?)");
>             result.SetStatus(eReturnStatusFailed);
> @@ -1102,10 +1102,10 @@ protected:
>     if (m_options.m_category_regex.OptionWasSet()) {
>       category_regex.reset(new RegularExpression());
>       if (!category_regex->Compile(
> -              m_options.m_category_regex.GetCurrentValue())) {
> +              m_options.m_category_regex.GetCurrentValueAsRef())) {
>         result.AppendErrorWithFormat(
>             "syntax error in category regular expression '%s'",
> -            m_options.m_category_regex.GetCurrentValue());
> +            m_options.m_category_regex.GetCurrentValueAsRef().str().c_str());
>         result.SetStatus(eReturnStatusFailed);
>         return false;
>       }
> @@ -1114,7 +1114,7 @@ protected:
>     if (argc == 1) {
>       const char *arg = command.GetArgumentAtIndex(0);
>       formatter_regex.reset(new RegularExpression());
> -      if (!formatter_regex->Compile(arg)) {
> +      if (!formatter_regex->Compile(llvm::StringRef::withNullAsEmpty(arg))) {
>         result.AppendErrorWithFormat("syntax error in regular expression '%s'",
>                                      arg);
>         result.SetStatus(eReturnStatusFailed);
> @@ -1137,9 +1137,9 @@ protected:
>                       const FormatterSharedPointer &format_sp) -> bool {
>           if (formatter_regex) {
>             bool escape = true;
> -            if (0 == strcmp(name.AsCString(), formatter_regex->GetText())) {
> +            if (name.GetStringRef() == formatter_regex->GetText()) {
>               escape = false;
> -            } else if (formatter_regex->Execute(name.AsCString())) {
> +            } else if (formatter_regex->Execute(name.GetStringRef())) {
>               escape = false;
>             }
> 
> @@ -1159,7 +1159,7 @@ protected:
>                           const FormatterSharedPointer &format_sp) -> bool {
>           if (formatter_regex) {
>             bool escape = true;
> -            if (0 == strcmp(regex_sp->GetText(), formatter_regex->GetText())) {
> +            if (regex_sp->GetText() == formatter_regex->GetText()) {
>               escape = false;
>             } else if (formatter_regex->Execute(regex_sp->GetText())) {
>               escape = false;
> @@ -1170,7 +1170,8 @@ protected:
>           }
> 
>           any_printed = true;
> -          result.GetOutputStream().Printf("%s: %s\n", regex_sp->GetText(),
> +          result.GetOutputStream().Printf("%s: %s\n",
> +                                          regex_sp->GetText().str().c_str(),
>                                           format_sp->GetDescription().c_str());
>           return true;
>         });
> @@ -1191,9 +1192,11 @@ protected:
>               const lldb::TypeCategoryImplSP &category) -> bool {
>             if (category_regex) {
>               bool escape = true;
> -              if (0 == strcmp(category->GetName(), category_regex->GetText())) {
> +              if (category->GetName() == category_regex->GetText()) {
>                 escape = false;
> -              } else if (category_regex->Execute(category->GetName())) {
> +              } else if (category_regex->Execute(
> +                             llvm::StringRef::withNullAsEmpty(
> +                                 category->GetName()))) {
>                 escape = false;
>               }
> 
> @@ -1693,7 +1696,7 @@ bool CommandObjectTypeSummaryAdd::AddSum
> 
>   if (type == eRegexSummary) {
>     RegularExpressionSP typeRX(new RegularExpression());
> -    if (!typeRX->Compile(type_name.GetCString())) {
> +    if (!typeRX->Compile(type_name.GetStringRef())) {
>       if (error)
>         error->SetErrorString(
>             "regex format error (maybe this is not really a regex?)");
> @@ -2242,7 +2245,7 @@ protected:
>     if (argc == 1) {
>       regex.reset(new RegularExpression());
>       const char *arg = command.GetArgumentAtIndex(0);
> -      if (!regex->Compile(arg)) {
> +      if (!regex->Compile(llvm::StringRef::withNullAsEmpty(arg))) {
>         result.AppendErrorWithFormat(
>             "syntax error in category regular expression '%s'", arg);
>         result.SetStatus(eReturnStatusFailed);
> @@ -2259,9 +2262,10 @@ protected:
>         [&regex, &result](const lldb::TypeCategoryImplSP &category_sp) -> bool {
>           if (regex) {
>             bool escape = true;
> -            if (0 == strcmp(category_sp->GetName(), regex->GetText())) {
> +            if (regex->GetText() == category_sp->GetName()) {
>               escape = false;
> -            } else if (regex->Execute(category_sp->GetName())) {
> +            } else if (regex->Execute(llvm::StringRef::withNullAsEmpty(
> +                           category_sp->GetName()))) {
>               escape = false;
>             }
> 
> @@ -2510,7 +2514,7 @@ bool CommandObjectTypeSynthAdd::AddSynth
> 
>   if (type == eRegexSynth) {
>     RegularExpressionSP typeRX(new RegularExpression());
> -    if (!typeRX->Compile(type_name.GetCString())) {
> +    if (!typeRX->Compile(type_name.GetStringRef())) {
>       if (error)
>         error->SetErrorString(
>             "regex format error (maybe this is not really a regex?)");
> @@ -2652,7 +2656,7 @@ private:
> 
>     if (type == eRegexFilter) {
>       RegularExpressionSP typeRX(new RegularExpression());
> -      if (!typeRX->Compile(type_name.GetCString())) {
> +      if (!typeRX->Compile(type_name.GetStringRef())) {
>         if (error)
>           error->SetErrorString(
>               "regex format error (maybe this is not really a regex?)");
> 
> Modified: lldb/trunk/source/Core/AddressResolverName.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/AddressResolverName.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Core/AddressResolverName.cpp (original)
> +++ lldb/trunk/source/Core/AddressResolverName.cpp Wed Sep 21 11:01:28 2016
> @@ -28,7 +28,7 @@ AddressResolverName::AddressResolverName
>     : AddressResolver(), m_func_name(func_name), m_class_name(nullptr),
>       m_regex(), m_match_type(type) {
>   if (m_match_type == AddressResolver::Regexp) {
> -    if (!m_regex.Compile(m_func_name.AsCString())) {
> +    if (!m_regex.Compile(m_func_name.GetStringRef())) {
>       Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_BREAKPOINTS));
> 
>       if (log)
> @@ -186,7 +186,7 @@ void AddressResolverName::GetDescription
>   s->PutCString("Address by function name: ");
> 
>   if (m_match_type == AddressResolver::Regexp)
> -    s->Printf("'%s' (regular expression)", m_regex.GetText());
> +    s->Printf("'%s' (regular expression)", m_regex.GetText().str().c_str());
>   else
>     s->Printf("'%s'", m_func_name.AsCString());
> }
> 
> Modified: lldb/trunk/source/Core/Disassembler.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Disassembler.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Core/Disassembler.cpp (original)
> +++ lldb/trunk/source/Core/Disassembler.cpp Wed Sep 21 11:01:28 2016
> @@ -781,9 +781,10 @@ OptionValueSP Instruction::ReadArray(FIL
> 
>     if (!line.empty()) {
>       std::string value;
> -      static RegularExpression g_reg_exp("^[ \t]*([^ \t]+)[ \t]*$");
> +      static RegularExpression g_reg_exp(
> +          llvm::StringRef("^[ \t]*([^ \t]+)[ \t]*$"));
>       RegularExpression::Match regex_match(1);
> -      bool reg_exp_success = g_reg_exp.Execute(line.c_str(), &regex_match);
> +      bool reg_exp_success = g_reg_exp.Execute(line, &regex_match);
>       if (reg_exp_success)
>         regex_match.GetMatchAtIndex(line.c_str(), 1, value);
>       else
> @@ -843,11 +844,11 @@ OptionValueSP Instruction::ReadDictionar
>     // Try to find a key-value pair in the current line and add it to the
>     // dictionary.
>     if (!line.empty()) {
> -      static RegularExpression g_reg_exp(
> -          "^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*=[ \t]*(.*)[ \t]*$");
> +      static RegularExpression g_reg_exp(llvm::StringRef(
> +          "^[ \t]*([a-zA-Z_][a-zA-Z0-9_]*)[ \t]*=[ \t]*(.*)[ \t]*$"));
>       RegularExpression::Match regex_match(2);
> 
> -      bool reg_exp_success = g_reg_exp.Execute(line.c_str(), &regex_match);
> +      bool reg_exp_success = g_reg_exp.Execute(line, &regex_match);
>       std::string key;
>       std::string value;
>       if (reg_exp_success) {
> 
> Modified: lldb/trunk/source/Core/Module.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/Module.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Core/Module.cpp (original)
> +++ lldb/trunk/source/Core/Module.cpp Wed Sep 21 11:01:28 2016
> @@ -1398,7 +1398,7 @@ size_t Module::FindSymbolsMatchingRegExA
>   Timer scoped_timer(
>       LLVM_PRETTY_FUNCTION,
>       "Module::FindSymbolsMatchingRegExAndType (regex = %s, type = %i)",
> -      regex.GetText(), symbol_type);
> +      regex.GetText().str().c_str(), symbol_type);
>   const size_t initial_size = sc_list.GetSize();
>   SymbolVendor *sym_vendor = GetSymbolVendor();
>   if (sym_vendor) {
> 
> Modified: lldb/trunk/source/Core/RegularExpression.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/RegularExpression.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Core/RegularExpression.cpp (original)
> +++ lldb/trunk/source/Core/RegularExpression.cpp Wed Sep 21 11:01:28 2016
> @@ -40,10 +40,10 @@ RegularExpression::RegularExpression() :
> // Constructor that compiles "re" using "flags" and stores the
> // resulting compiled regular expression into this object.
> //----------------------------------------------------------------------
> -RegularExpression::RegularExpression(const char *re)
> +RegularExpression::RegularExpression(llvm::StringRef str)
>     : m_re(), m_comp_err(1), m_preg() {
>   memset(&m_preg, 0, sizeof(m_preg));
> -  Compile(re);
> +  Compile(str);
> }
> 
> RegularExpression::RegularExpression(const RegularExpression &rhs) {
> @@ -78,12 +78,12 @@ RegularExpression::~RegularExpression()
> //  True if the regular expression compiles successfully, false
> //  otherwise.
> //----------------------------------------------------------------------
> -bool RegularExpression::Compile(const char *re) {
> +bool RegularExpression::Compile(llvm::StringRef str) {
>   Free();
> 
> -  if (re && re[0]) {
> -    m_re = re;
> -    m_comp_err = ::regcomp(&m_preg, re, DEFAULT_COMPILE_FLAGS);
> +  if (!str.empty()) {
> +    m_re = str;
> +    m_comp_err = ::regcomp(&m_preg, m_re.c_str(), DEFAULT_COMPILE_FLAGS);
>   } else {
>     // No valid regular expression
>     m_comp_err = 1;
> @@ -100,13 +100,16 @@ bool RegularExpression::Compile(const ch
> // values that are present in "match_ptr". The regular expression
> // will be executed using the "execute_flags".
> //---------------------------------------------------------------------
> -bool RegularExpression::Execute(const char *s, Match *match) const {
> +bool RegularExpression::Execute(llvm::StringRef str, Match *match) const {
>   int err = 1;
> -  if (s != nullptr && m_comp_err == 0) {
> +  if (!str.empty() && m_comp_err == 0) {
> +    // Argument to regexec must be null-terminated.
> +    std::string reg_str = str;
>     if (match) {
> -      err = ::regexec(&m_preg, s, match->GetSize(), match->GetData(), 0);
> +      err = ::regexec(&m_preg, reg_str.c_str(), match->GetSize(),
> +                      match->GetData(), 0);
>     } else {
> -      err = ::regexec(&m_preg, s, 0, nullptr, 0);
> +      err = ::regexec(&m_preg, reg_str.c_str(), 0, nullptr, 0);
>     }
>   }
> 
> @@ -176,9 +179,7 @@ bool RegularExpression::IsValid() const
> // Returns the text that was used to compile the current regular
> // expression.
> //----------------------------------------------------------------------
> -const char *RegularExpression::GetText() const {
> -  return (m_re.empty() ? nullptr : m_re.c_str());
> -}
> +llvm::StringRef RegularExpression::GetText() const { return m_re; }
> 
> //----------------------------------------------------------------------
> // Free any contained compiled regular expressions.
> 
> Modified: lldb/trunk/source/Core/SourceManager.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/SourceManager.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Core/SourceManager.cpp (original)
> +++ lldb/trunk/source/Core/SourceManager.cpp Wed Sep 21 11:01:28 2016
> @@ -464,7 +464,7 @@ void SourceManager::File::FindLinesMatch
>     std::string buffer;
>     if (!GetLine(line_no, buffer))
>       break;
> -    if (regex.Execute(buffer.c_str())) {
> +    if (regex.Execute(buffer)) {
>       match_lines.push_back(line_no);
>     }
>   }
> 
> Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
> +++ lldb/trunk/source/DataFormatters/FormatManager.cpp Wed Sep 21 11:01:28 2016
> @@ -1003,9 +1003,9 @@ void FormatManager::LoadSystemFormatters
>       new StringSummaryFormat(string_array_flags, "${var%s}"));
> 
>   lldb::RegularExpressionSP any_size_char_arr(
> -      new RegularExpression("char \\[[0-9]+\\]"));
> +      new RegularExpression(llvm::StringRef("char \\[[0-9]+\\]")));
>   lldb::RegularExpressionSP any_size_wchar_arr(
> -      new RegularExpression("wchar_t \\[[0-9]+\\]"));
> +      new RegularExpression(llvm::StringRef("wchar_t \\[[0-9]+\\]")));
> 
>   TypeCategoryImpl::SharedPointer sys_category_sp =
>       GetCategory(m_system_category_name);
> 
> Modified: lldb/trunk/source/DataFormatters/FormattersHelpers.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormattersHelpers.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/DataFormatters/FormattersHelpers.cpp (original)
> +++ lldb/trunk/source/DataFormatters/FormattersHelpers.cpp Wed Sep 21 11:01:28 2016
> @@ -34,7 +34,7 @@ void lldb_private::formatters::AddFormat
> 
>   if (regex)
>     category_sp->GetRegexTypeFormatsContainer()->Add(
> -        RegularExpressionSP(new RegularExpression(type_name.AsCString())),
> +        RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
>         format_sp);
>   else
>     category_sp->GetTypeFormatsContainer()->Add(type_name, format_sp);
> @@ -45,7 +45,7 @@ void lldb_private::formatters::AddSummar
>     ConstString type_name, bool regex) {
>   if (regex)
>     category_sp->GetRegexTypeSummariesContainer()->Add(
> -        RegularExpressionSP(new RegularExpression(type_name.AsCString())),
> +        RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
>         summary_sp);
>   else
>     category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
> @@ -58,7 +58,7 @@ void lldb_private::formatters::AddString
> 
>   if (regex)
>     category_sp->GetRegexTypeSummariesContainer()->Add(
> -        RegularExpressionSP(new RegularExpression(type_name.AsCString())),
> +        RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
>         summary_sp);
>   else
>     category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
> @@ -72,7 +72,7 @@ void lldb_private::formatters::AddOneLin
> 
>   if (regex)
>     category_sp->GetRegexTypeSummariesContainer()->Add(
> -        RegularExpressionSP(new RegularExpression(type_name.AsCString())),
> +        RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
>         summary_sp);
>   else
>     category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
> @@ -87,7 +87,7 @@ void lldb_private::formatters::AddCXXSum
>       new CXXFunctionSummaryFormat(flags, funct, description));
>   if (regex)
>     category_sp->GetRegexTypeSummariesContainer()->Add(
> -        RegularExpressionSP(new RegularExpression(type_name.AsCString())),
> +        RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
>         summary_sp);
>   else
>     category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
> @@ -102,7 +102,7 @@ void lldb_private::formatters::AddCXXSyn
>       new CXXSyntheticChildren(flags, description, generator));
>   if (regex)
>     category_sp->GetRegexTypeSyntheticsContainer()->Add(
> -        RegularExpressionSP(new RegularExpression(type_name.AsCString())),
> +        RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
>         synth_sp);
>   else
>     category_sp->GetTypeSyntheticsContainer()->Add(type_name, synth_sp);
> @@ -117,7 +117,7 @@ void lldb_private::formatters::AddFilter
>     filter_sp->AddExpressionPath(child);
>   if (regex)
>     category_sp->GetRegexTypeFiltersContainer()->Add(
> -        RegularExpressionSP(new RegularExpression(type_name.AsCString())),
> +        RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
>         filter_sp);
>   else
>     category_sp->GetTypeFiltersContainer()->Add(type_name, filter_sp);
> 
> Modified: lldb/trunk/source/Host/common/FileSpec.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/FileSpec.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Host/common/FileSpec.cpp (original)
> +++ lldb/trunk/source/Host/common/FileSpec.cpp Wed Sep 21 11:01:28 2016
> @@ -1422,15 +1422,15 @@ void FileSpec::RemoveLastPathComponent()
> //------------------------------------------------------------------
> bool FileSpec::IsSourceImplementationFile() const {
>   ConstString extension(GetFileNameExtension());
> -  if (extension) {
> -    static RegularExpression g_source_file_regex(
> -        "^([cC]|[mM]|[mM][mM]|[cC][pP][pP]|[cC]\\+\\+|[cC][xX][xX]|[cC][cC]|["
> -        "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.GetCString());
> -  }
> -  return false;
> +  if (!extension)
> +    return false;
> +
> +  static RegularExpression g_source_file_regex(llvm::StringRef(
> +      "^([cC]|[mM]|[mM][mM]|[cC][pP][pP]|[cC]\\+\\+|[cC][xX][xX]|[cC][cC]|["
> +      "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());
> }
> 
> bool FileSpec::IsRelative() const {
> 
> Modified: lldb/trunk/source/Host/common/Socket.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Socket.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Host/common/Socket.cpp (original)
> +++ lldb/trunk/source/Host/common/Socket.cpp Wed Sep 21 11:01:28 2016
> @@ -253,9 +253,9 @@ Error Socket::UnixAbstractAccept(llvm::S
> bool Socket::DecodeHostAndPort(llvm::StringRef host_and_port,
>                                std::string &host_str, std::string &port_str,
>                                int32_t &port, Error *error_ptr) {
> -  static RegularExpression g_regex("([^:]+):([0-9]+)");
> +  static RegularExpression g_regex(llvm::StringRef("([^:]+):([0-9]+)"));
>   RegularExpression::Match regex_match(2);
> -  if (g_regex.Execute(host_and_port.data(), &regex_match)) {
> +  if (g_regex.Execute(host_and_port, &regex_match)) {
>     if (regex_match.GetMatchAtIndex(host_and_port.data(), 1, host_str) &&
>         regex_match.GetMatchAtIndex(host_and_port.data(), 2, port_str)) {
>       bool ok = false;
> 
> Modified: lldb/trunk/source/Interpreter/Args.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/Args.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Interpreter/Args.cpp (original)
> +++ lldb/trunk/source/Interpreter/Args.cpp Wed Sep 21 11:01:28 2016
> @@ -608,6 +608,8 @@ lldb::addr_t Args::StringToAddress(const
>                                    Error *error_ptr) {
>   bool error_set = false;
>   if (s && s[0]) {
> +    llvm::StringRef sref = s;
> +
>     char *end = nullptr;
>     lldb::addr_t addr = ::strtoull(s, &end, 0);
>     if (*end == '\0') {
> @@ -662,10 +664,10 @@ lldb::addr_t Args::StringToAddress(const
>           // Since the compiler can't handle things like "main + 12" we should
>           // try to do this for now. The compiler doesn't like adding offsets
>           // to function pointer types.
> -          static RegularExpression g_symbol_plus_offset_regex(
> -              "^(.*)([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*$");
> +          static RegularExpression g_symbol_plus_offset_regex(llvm::StringRef(
> +              "^(.*)([-\\+])[[:space:]]*(0x[0-9A-Fa-f]+|[0-9]+)[[:space:]]*$"));
>           RegularExpression::Match regex_match(3);
> -          if (g_symbol_plus_offset_regex.Execute(s, &regex_match)) {
> +          if (g_symbol_plus_offset_regex.Execute(sref, &regex_match)) {
>             uint64_t offset = 0;
>             bool add = true;
>             std::string name;
> 
> Modified: lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp (original)
> +++ lldb/trunk/source/Interpreter/CommandObjectRegexCommand.cpp Wed Sep 21 11:01:28 2016
> @@ -89,7 +89,8 @@ bool CommandObjectRegexCommand::AddRegex
>                                                 const char *command_cstr) {
>   m_entries.resize(m_entries.size() + 1);
>   // Only add the regular expression if it compiles
> -  if (m_entries.back().regex.Compile(re_cstr)) {
> +  if (m_entries.back().regex.Compile(
> +          llvm::StringRef::withNullAsEmpty(re_cstr))) {
>     m_entries.back().command.assign(command_cstr);
>     return true;
>   }
> 
> Modified: lldb/trunk/source/Interpreter/OptionValueRegex.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Interpreter/OptionValueRegex.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Interpreter/OptionValueRegex.cpp (original)
> +++ lldb/trunk/source/Interpreter/OptionValueRegex.cpp Wed Sep 21 11:01:28 2016
> @@ -26,10 +26,8 @@ void OptionValueRegex::DumpValue(const E
>     if (dump_mask & eDumpOptionType)
>       strm.PutCString(" = ");
>     if (m_regex.IsValid()) {
> -      const char *regex_text = m_regex.GetText();
> -      if (regex_text && regex_text[0])
> -        strm.Printf("%s", regex_text);
> -    } else {
> +      llvm::StringRef regex_text = m_regex.GetText();
> +      strm.Printf("%s", regex_text.str().c_str());
>     }
>   }
> }
> @@ -53,7 +51,7 @@ Error OptionValueRegex::SetValueFromStri
> 
>   case eVarSetOperationReplace:
>   case eVarSetOperationAssign:
> -    if (m_regex.Compile(value.str().c_str())) {
> +    if (m_regex.Compile(value)) {
>       m_value_was_set = true;
>       NotifyValueChanged();
>     } else {
> @@ -70,5 +68,5 @@ Error OptionValueRegex::SetValueFromStri
> }
> 
> lldb::OptionValueSP OptionValueRegex::DeepCopy() const {
> -  return OptionValueSP(new OptionValueRegex(m_regex.GetText()));
> +  return OptionValueSP(new OptionValueRegex(m_regex.GetText().str().c_str()));
> }
> 
> Modified: lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp (original)
> +++ lldb/trunk/source/Plugins/Disassembler/llvm/DisassemblerLLVMC.cpp Wed Sep 21 11:01:28 2016
> @@ -371,11 +371,12 @@ public:
>           }
>         }
> 
> -        static RegularExpression s_regex("[ \t]*([^ ^\t]+)[ \t]*([^ ^\t].*)?");
> +        static RegularExpression s_regex(
> +            llvm::StringRef("[ \t]*([^ ^\t]+)[ \t]*([^ ^\t].*)?"));
> 
>         RegularExpression::Match matches(3);
> 
> -        if (s_regex.Execute(out_string.c_str(), &matches)) {
> +        if (s_regex.Execute(out_string, &matches)) {
>           matches.GetMatchAtIndex(out_string.c_str(), 1, m_opcode_name);
>           matches.GetMatchAtIndex(out_string.c_str(), 2, m_mnemonics);
>         }
> 
> Modified: lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp (original)
> +++ lldb/trunk/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp Wed Sep 21 11:01:28 2016
> @@ -999,7 +999,7 @@ size_t DynamicLoaderDarwin::FindEquivale
>   equivalent_regex_buf.append(trampoline_name.GetCString());
>   equivalent_regex_buf.append(resolver_name_regex);
> 
> -  RegularExpression equivalent_name_regex(equivalent_regex_buf.c_str());
> +  RegularExpression equivalent_name_regex(equivalent_regex_buf);
>   const bool append = true;
>   images.FindSymbolsMatchingRegExAndType(equivalent_name_regex, eSymbolTypeCode,
>                                          equivalent_symbols, append);
> 
> Modified: lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp (original)
> +++ lldb/trunk/source/Plugins/InstrumentationRuntime/AddressSanitizer/AddressSanitizerRuntime.cpp Wed Sep 21 11:01:28 2016
> @@ -57,7 +57,8 @@ AddressSanitizerRuntime::~AddressSanitiz
> const RegularExpression &
> AddressSanitizerRuntime::GetPatternForRuntimeLibrary() {
>   // FIXME: This shouldn't include the "dylib" suffix.
> -  static RegularExpression regex("libclang_rt.asan_(.*)_dynamic\\.dylib");
> +  static RegularExpression regex(
> +      llvm::StringRef("libclang_rt.asan_(.*)_dynamic\\.dylib"));
>   return regex;
> }
> 
> 
> Modified: lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp (original)
> +++ lldb/trunk/source/Plugins/InstrumentationRuntime/ThreadSanitizer/ThreadSanitizerRuntime.cpp Wed Sep 21 11:01:28 2016
> @@ -832,7 +832,7 @@ bool ThreadSanitizerRuntime::NotifyBreak
> }
> 
> const RegularExpression &ThreadSanitizerRuntime::GetPatternForRuntimeLibrary() {
> -  static RegularExpression regex("libclang_rt.tsan_");
> +  static RegularExpression regex(llvm::StringRef("libclang_rt.tsan_"));
>   return regex;
> }
> 
> 
> Modified: lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp (original)
> +++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Wed Sep 21 11:01:28 2016
> @@ -153,12 +153,13 @@ static bool IsValidBasename(const llvm::
>   if (!basename.startswith("operator"))
>     return false;
> 
> -  static RegularExpression g_operator_regex("^(operator)( "
> -                                            "?)([A-Za-z_][A-Za-z_0-9]*|\\(\\)|"
> -                                            "\\[\\]|[\\^<>=!\\/"
> -                                            "*+-]+)(<.*>)?(\\[\\])?$");
> +  static RegularExpression g_operator_regex(
> +      llvm::StringRef("^(operator)( "
> +                      "?)([A-Za-z_][A-Za-z_0-9]*|\\(\\)|"
> +                      "\\[\\]|[\\^<>=!\\/"
> +                      "*+-]+)(<.*>)?(\\[\\])?$"));
>   std::string basename_str(basename.str());
> -  return g_operator_regex.Execute(basename_str.c_str(), nullptr);
> +  return g_operator_regex.Execute(basename_str, nullptr);
> }
> 
> void CPlusPlusLanguage::MethodName::Parse() {
> @@ -289,10 +290,11 @@ bool CPlusPlusLanguage::IsCPPMangledName
> 
> bool CPlusPlusLanguage::ExtractContextAndIdentifier(
>     const char *name, llvm::StringRef &context, llvm::StringRef &identifier) {
> -  static RegularExpression g_basename_regex(
> -      "^(([A-Za-z_][A-Za-z_0-9]*::)*)(~?[A-Za-z_~][A-Za-z_0-9]*)$");
> +  static RegularExpression g_basename_regex(llvm::StringRef(
> +      "^(([A-Za-z_][A-Za-z_0-9]*::)*)(~?[A-Za-z_~][A-Za-z_0-9]*)$"));
>   RegularExpression::Match match(4);
> -  if (g_basename_regex.Execute(name, &match)) {
> +  if (g_basename_regex.Execute(llvm::StringRef::withNullAsEmpty(name),
> +                               &match)) {
>     match.GetMatchAtIndex(name, 1, context);
>     match.GetMatchAtIndex(name, 3, identifier);
>     return true;
> @@ -564,8 +566,8 @@ static void LoadLibCxxFormatters(lldb::T
>       ConstString("^std::__(ndk)?1::atomic<.+>$"), stl_synth_flags, true);
> 
>   cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
> -      RegularExpressionSP(
> -          new RegularExpression("^(std::__(ndk)?1::)deque<.+>(( )?&)?$")),
> +      RegularExpressionSP(new RegularExpression(
> +          llvm::StringRef("^(std::__(ndk)?1::)deque<.+>(( )?&)?$"))),
>       SyntheticChildrenSP(new ScriptedSyntheticChildren(
>           stl_synth_flags,
>           "lldb.formatters.cpp.libcxx.stddeque_SynthProvider")));
> @@ -750,34 +752,38 @@ static void LoadLibStdcppFormatters(lldb
>       false);
> 
>   cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
> -      RegularExpressionSP(new RegularExpression("^std::vector<.+>(( )?&)?$")),
> +      RegularExpressionSP(
> +          new RegularExpression(llvm::StringRef("^std::vector<.+>(( )?&)?$"))),
>       SyntheticChildrenSP(new ScriptedSyntheticChildren(
>           stl_synth_flags,
>           "lldb.formatters.cpp.gnu_libstdcpp.StdVectorSynthProvider")));
>   cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
> -      RegularExpressionSP(new RegularExpression("^std::map<.+> >(( )?&)?$")),
> +      RegularExpressionSP(
> +          new RegularExpression(llvm::StringRef("^std::map<.+> >(( )?&)?$"))),
>       SyntheticChildrenSP(new ScriptedSyntheticChildren(
>           stl_synth_flags,
>           "lldb.formatters.cpp.gnu_libstdcpp.StdMapSynthProvider")));
>   cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
> -      RegularExpressionSP(
> -          new RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$")),
> +      RegularExpressionSP(new RegularExpression(
> +          llvm::StringRef("^std::(__cxx11::)?list<.+>(( )?&)?$"))),
>       SyntheticChildrenSP(new ScriptedSyntheticChildren(
>           stl_synth_flags,
>           "lldb.formatters.cpp.gnu_libstdcpp.StdListSynthProvider")));
>   stl_summary_flags.SetDontShowChildren(false);
>   stl_summary_flags.SetSkipPointers(true);
>   cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
> -      RegularExpressionSP(new RegularExpression("^std::vector<.+>(( )?&)?$")),
> +      RegularExpressionSP(
> +          new RegularExpression(llvm::StringRef("^std::vector<.+>(( )?&)?$"))),
>       TypeSummaryImplSP(
>           new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
>   cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
> -      RegularExpressionSP(new RegularExpression("^std::map<.+> >(( )?&)?$")),
> +      RegularExpressionSP(
> +          new RegularExpression(llvm::StringRef("^std::map<.+> >(( )?&)?$"))),
>       TypeSummaryImplSP(
>           new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
>   cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
> -      RegularExpressionSP(
> -          new RegularExpression("^std::(__cxx11::)?list<.+>(( )?&)?$")),
> +      RegularExpressionSP(new RegularExpression(
> +          llvm::StringRef("^std::(__cxx11::)?list<.+>(( )?&)?$"))),
>       TypeSummaryImplSP(
>           new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
> 
> 
> Modified: lldb/trunk/source/Plugins/Language/Java/JavaLanguage.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Language/Java/JavaLanguage.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Language/Java/JavaLanguage.cpp (original)
> +++ lldb/trunk/source/Plugins/Language/Java/JavaLanguage.cpp Wed Sep 21 11:01:28 2016
> @@ -70,7 +70,7 @@ lldb::TypeCategoryImplSP JavaLanguage::G
>   std::call_once(g_initialize, [this]() -> void {
>     DataVisualization::Categories::GetCategory(GetPluginName(), g_category);
>     if (g_category) {
> -      const char *array_regexp = "^.*\\[\\]&?$";
> +      llvm::StringRef array_regexp("^.*\\[\\]&?$");
> 
>       lldb::TypeSummaryImplSP string_summary_sp(new CXXFunctionSummaryFormat(
>           TypeSummaryImpl::Flags().SetDontShowChildren(true),
> 
> Modified: lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp (original)
> +++ lldb/trunk/source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCRuntimeV2.cpp Wed Sep 21 11:01:28 2016
> @@ -542,7 +542,8 @@ protected:
>       break;
>     case 1: {
>       regex_up.reset(new RegularExpression());
> -      if (!regex_up->Compile(command.GetArgumentAtIndex(0))) {
> +      if (!regex_up->Compile(llvm::StringRef::withNullAsEmpty(
> +              command.GetArgumentAtIndex(0)))) {
>         result.AppendError(
>             "invalid argument - please provide a valid regular expression");
>         result.SetStatus(lldb::eReturnStatusFailed);
> @@ -567,7 +568,8 @@ protected:
>         if (iterator->second) {
>           const char *class_name =
>               iterator->second->GetClassName().AsCString("<unknown>");
> -          if (regex_up && class_name && !regex_up->Execute(class_name))
> +          if (regex_up && class_name &&
> +              !regex_up->Execute(llvm::StringRef(class_name)))
>             continue;
>           std_out.Printf("isa = 0x%" PRIx64, iterator->first);
>           std_out.Printf(" name = %s", class_name);
> @@ -607,7 +609,7 @@ protected:
>                 nullptr);
>           }
>         } else {
> -          if (regex_up && !regex_up->Execute(""))
> +          if (regex_up && !regex_up->Execute(llvm::StringRef()))
>             continue;
>           std_out.Printf("isa = 0x%" PRIx64 " has no associated class.\n",
>                          iterator->first);
> 
> Modified: lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp (original)
> +++ lldb/trunk/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp Wed Sep 21 11:01:28 2016
> @@ -1964,8 +1964,9 @@ void RenderScriptRuntime::FindStructType
>   // Find all the global variables from the script rs modules
>   VariableList variable_list;
>   for (auto module_sp : m_rsmodules)
> -    module_sp->m_module->FindGlobalVariables(RegularExpression("."), true,
> -                                             UINT32_MAX, variable_list);
> +    module_sp->m_module->FindGlobalVariables(
> +        RegularExpression(llvm::StringRef(".")), true, UINT32_MAX,
> +        variable_list);
> 
>   // Iterate over all the global variables looking for one with a matching type
>   // to the Element.
> @@ -3741,15 +3742,16 @@ public:
>       RegularExpression regex;
>       RegularExpression::Match regex_match(3);
> 
> +      llvm::StringRef id_ref = llvm::StringRef::withNullAsEmpty(id_cstr);
>       bool matched = false;
> -      if (regex.Compile("^([0-9]+),([0-9]+),([0-9]+)$") &&
> -          regex.Execute(id_cstr, &regex_match))
> +      if (regex.Compile(llvm::StringRef("^([0-9]+),([0-9]+),([0-9]+)$")) &&
> +          regex.Execute(id_ref, &regex_match))
>         matched = true;
> -      else if (regex.Compile("^([0-9]+),([0-9]+)$") &&
> -               regex.Execute(id_cstr, &regex_match))
> +      else if (regex.Compile(llvm::StringRef("^([0-9]+),([0-9]+)$")) &&
> +               regex.Execute(id_ref, &regex_match))
>         matched = true;
> -      else if (regex.Compile("^([0-9]+)$") &&
> -               regex.Execute(id_cstr, &regex_match))
> +      else if (regex.Compile(llvm::StringRef("^([0-9]+)$")) &&
> +               regex.Execute(id_ref, &regex_match))
>         matched = true;
>       for (uint32_t i = 0; i < 3; i++) {
>         std::string group;
> 
> Modified: lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp (original)
> +++ lldb/trunk/source/Plugins/Process/Utility/DynamicRegisterInfo.cpp Wed Sep 21 11:01:28 2016
> @@ -125,9 +125,9 @@ DynamicRegisterInfo::SetRegisterInfo(con
>         // LSBIT - the least significant bit at which the current register value
>         // ends at
>         static RegularExpression g_bitfield_regex(
> -            "([A-Za-z_][A-Za-z0-9_]*)\\[([0-9]+):([0-9]+)\\]");
> +            llvm::StringRef("([A-Za-z_][A-Za-z0-9_]*)\\[([0-9]+):([0-9]+)\\]"));
>         RegularExpression::Match regex_match(3);
> -        if (g_bitfield_regex.Execute(slice_str.c_str(), &regex_match)) {
> +        if (g_bitfield_regex.Execute(slice_str, &regex_match)) {
>           llvm::StringRef reg_name_str;
>           std::string msbit_str;
>           std::string lsbit_str;
> 
> Modified: lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp (original)
> +++ lldb/trunk/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp Wed Sep 21 11:01:28 2016
> @@ -404,11 +404,11 @@ GDBRemoteCommunication::WaitForPacketWit
>             std::string regex_str = "^";
>             regex_str += echo_packet;
>             regex_str += "$";
> -            response_regex.Compile(regex_str.c_str());
> +            response_regex.Compile(regex_str);
>           } else {
>             echo_packet_len =
>                 ::snprintf(echo_packet, sizeof(echo_packet), "qC");
> -            response_regex.Compile("^QC[0-9A-Fa-f]+$");
> +            response_regex.Compile(llvm::StringRef("^QC[0-9A-Fa-f]+$"));
>           }
> 
>           PacketResult echo_packet_result =
> @@ -422,8 +422,7 @@ GDBRemoteCommunication::WaitForPacketWit
>                   echo_response, timeout_usec, false);
>               if (echo_packet_result == PacketResult::Success) {
>                 ++successful_responses;
> -                if (response_regex.Execute(
> -                        echo_response.GetStringRef().c_str())) {
> +                if (response_regex.Execute(echo_response.GetStringRef())) {
>                   sync_success = true;
>                   break;
>                 } else if (successful_responses == 1) {
> 
> Modified: lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp (original)
> +++ lldb/trunk/source/Plugins/StructuredData/DarwinLog/StructuredDataDarwinLog.cpp Wed Sep 21 11:01:28 2016
> @@ -312,7 +312,7 @@ private:
>     }
> 
>     // Instantiate the regex so we can report any errors.
> -    auto regex = RegularExpression(op_arg.c_str());
> +    auto regex = RegularExpression(op_arg);
>     if (!regex.IsValid()) {
>       char error_text[256];
>       error_text[0] = '\0';
> 
> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp (original)
> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp Wed Sep 21 11:01:28 2016
> @@ -999,16 +999,18 @@ void DWARFCompileUnit::ParseProducerInfo
>     const char *producer_cstr = die->GetAttributeValueAsString(
>         m_dwarf2Data, this, DW_AT_producer, NULL);
>     if (producer_cstr) {
> -      RegularExpression llvm_gcc_regex("^4\\.[012]\\.[01] \\(Based on Apple "
> -                                       "Inc\\. build [0-9]+\\) \\(LLVM build "
> -                                       "[\\.0-9]+\\)$");
> -      if (llvm_gcc_regex.Execute(producer_cstr)) {
> +      RegularExpression llvm_gcc_regex(
> +          llvm::StringRef("^4\\.[012]\\.[01] \\(Based on Apple "
> +                          "Inc\\. build [0-9]+\\) \\(LLVM build "
> +                          "[\\.0-9]+\\)$"));
> +      if (llvm_gcc_regex.Execute(llvm::StringRef(producer_cstr))) {
>         m_producer = eProducerLLVMGCC;
>       } else if (strstr(producer_cstr, "clang")) {
>         static RegularExpression g_clang_version_regex(
> -            "clang-([0-9]+)\\.([0-9]+)\\.([0-9]+)");
> +            llvm::StringRef("clang-([0-9]+)\\.([0-9]+)\\.([0-9]+)"));
>         RegularExpression::Match regex_match(3);
> -        if (g_clang_version_regex.Execute(producer_cstr, &regex_match)) {
> +        if (g_clang_version_regex.Execute(llvm::StringRef(producer_cstr),
> +                                          &regex_match)) {
>           std::string str;
>           if (regex_match.GetMatchAtIndex(producer_cstr, 1, str))
>             m_producer_version_major =
> 
> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp (original)
> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp Wed Sep 21 11:01:28 2016
> @@ -535,18 +535,20 @@ FindCallbackString(SymbolFileDWARF *dwar
>                    const uint32_t curr_depth, void *userData) {
>   FindCallbackStringInfo *info = (FindCallbackStringInfo *)userData;
> 
> -  if (die) {
> -    const char *die_name = die->GetName(dwarf2Data, cu);
> -    if (die_name) {
> -      if (info->regex) {
> -        if (info->regex->Execute(die_name))
> -          info->die_offsets.push_back(die->GetOffset());
> -      } else {
> -        if ((info->ignore_case ? strcasecmp(die_name, info->name)
> -                               : strcmp(die_name, info->name)) == 0)
> -          info->die_offsets.push_back(die->GetOffset());
> -      }
> -    }
> +  if (!die)
> +    return next_offset;
> +
> +  const char *die_name = die->GetName(dwarf2Data, cu);
> +  if (!die_name)
> +    return next_offset;
> +
> +  if (info->regex) {
> +    if (info->regex->Execute(llvm::StringRef(die_name)))
> +      info->die_offsets.push_back(die->GetOffset());
> +  } else {
> +    if ((info->ignore_case ? strcasecmp(die_name, info->name)
> +                           : strcmp(die_name, info->name)) == 0)
> +      info->die_offsets.push_back(die->GetOffset());
>   }
> 
>   // Just return the current offset to parse the next CU or DIE entry
> 
> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp (original)
> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/HashedNameToDIE.cpp Wed Sep 21 11:01:28 2016
> @@ -8,6 +8,7 @@
> //===----------------------------------------------------------------------===//
> 
> #include "HashedNameToDIE.h"
> +#include "llvm/ADT/StringRef.h"
> 
> void DWARFMappedHash::ExtractDIEArray(const DIEInfoArray &die_info_array,
>                                       DIEArray &die_offsets) {
> @@ -469,7 +470,7 @@ DWARFMappedHash::MemoryTable::AppendHash
>   if (count > 0 &&
>       m_data.ValidOffsetForDataOfSize(*hash_data_offset_ptr,
>                                       min_total_hash_data_size)) {
> -    const bool match = regex.Execute(strp_cstr);
> +    const bool match = regex.Execute(llvm::StringRef(strp_cstr));
> 
>     if (!match && m_header.header_data.HashDataHasFixedByteSize()) {
>       // If the regex doesn't match and we have fixed size data,
> 
> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp (original)
> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp Wed Sep 21 11:01:28 2016
> @@ -2198,7 +2198,7 @@ uint32_t SymbolFileDWARF::FindGlobalVari
>     GetObjectFile()->GetModule()->LogMessage(
>         log, "SymbolFileDWARF::FindGlobalVariables (regex=\"%s\", append=%u, "
>              "max_matches=%u, variables)",
> -        regex.GetText(), append, max_matches);
> +        regex.GetText().str().c_str(), append, max_matches);
>   }
> 
>   DWARFDebugInfo *info = DebugInfo();
> @@ -2252,7 +2252,7 @@ uint32_t SymbolFileDWARF::FindGlobalVari
>           GetObjectFile()->GetModule()->ReportErrorIfModifyDetected(
>               "the DWARF debug information has been modified (.apple_names "
>               "accelerator table had bad die 0x%8.8x for regex '%s')\n",
> -              die_ref.die_offset, regex.GetText());
> +              die_ref.die_offset, regex.GetText().str().c_str());
>         }
>       }
>     }
> @@ -2673,7 +2673,7 @@ uint32_t SymbolFileDWARF::FindFunctions(
>                                         SymbolContextList &sc_list) {
>   Timer scoped_timer(LLVM_PRETTY_FUNCTION,
>                      "SymbolFileDWARF::FindFunctions (regex = '%s')",
> -                     regex.GetText());
> +                     regex.GetText().str().c_str());
> 
>   Log *log(LogChannelDWARF::GetLogIfAll(DWARF_LOG_LOOKUPS));
> 
> @@ -2681,7 +2681,7 @@ uint32_t SymbolFileDWARF::FindFunctions(
>     GetObjectFile()->GetModule()->LogMessage(
>         log,
>         "SymbolFileDWARF::FindFunctions (regex=\"%s\", append=%u, sc_list)",
> -        regex.GetText(), append);
> +        regex.GetText().str().c_str(), append);
>   }
> 
>   // If we aren't appending the results to this list, then clear the list
> 
> Modified: lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp (original)
> +++ lldb/trunk/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp Wed Sep 21 11:01:28 2016
> @@ -1020,7 +1020,7 @@ uint32_t SymbolFileDWARFDebugMap::FindFu
>                                                 SymbolContextList &sc_list) {
>   Timer scoped_timer(LLVM_PRETTY_FUNCTION,
>                      "SymbolFileDWARFDebugMap::FindFunctions (regex = '%s')",
> -                     regex.GetText());
> +                     regex.GetText().str().c_str());
> 
>   uint32_t initial_size = 0;
>   if (append)
> 
> Modified: lldb/trunk/source/Symbol/ObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ObjectFile.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Symbol/ObjectFile.cpp (original)
> +++ lldb/trunk/source/Symbol/ObjectFile.cpp Wed Sep 21 11:01:28 2016
> @@ -574,9 +574,10 @@ bool ObjectFile::SplitArchivePathWithObj
>                                             FileSpec &archive_file,
>                                             ConstString &archive_object,
>                                             bool must_exist) {
> -  RegularExpression g_object_regex("(.*)\\(([^\\)]+)\\)$");
> +  RegularExpression g_object_regex(llvm::StringRef("(.*)\\(([^\\)]+)\\)$"));
>   RegularExpression::Match regex_match(2);
> -  if (g_object_regex.Execute(path_with_object, &regex_match)) {
> +  if (g_object_regex.Execute(llvm::StringRef::withNullAsEmpty(path_with_object),
> +                             &regex_match)) {
>     std::string path;
>     std::string obj;
>     if (regex_match.GetMatchAtIndex(path_with_object, 1, path) &&
> 
> Modified: lldb/trunk/source/Symbol/Variable.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/Variable.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Symbol/Variable.cpp (original)
> +++ lldb/trunk/source/Symbol/Variable.cpp Wed Sep 21 11:01:28 2016
> @@ -382,9 +382,11 @@ Error Variable::GetValuesForVariableExpr
>     } break;
> 
>     default: {
> -      static RegularExpression g_regex("^([A-Za-z_:][A-Za-z_0-9:]*)(.*)");
> +      static RegularExpression g_regex(
> +          llvm::StringRef("^([A-Za-z_:][A-Za-z_0-9:]*)(.*)"));
>       RegularExpression::Match regex_match(1);
> -      if (g_regex.Execute(variable_expr_path, &regex_match)) {
> +      if (g_regex.Execute(llvm::StringRef::withNullAsEmpty(variable_expr_path),
> +                          &regex_match)) {
>         std::string variable_name;
>         if (regex_match.GetMatchAtIndex(variable_expr_path, 1, variable_name)) {
>           variable_list.Clear();
> 
> Modified: lldb/trunk/source/Target/ThreadPlanStepInRange.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ThreadPlanStepInRange.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Target/ThreadPlanStepInRange.cpp (original)
> +++ lldb/trunk/source/Target/ThreadPlanStepInRange.cpp Wed Sep 21 11:01:28 2016
> @@ -298,10 +298,11 @@ bool ThreadPlanStepInRange::ShouldStop(E
> }
> 
> void ThreadPlanStepInRange::SetAvoidRegexp(const char *name) {
> +  auto name_ref = llvm::StringRef::withNullAsEmpty(name);
>   if (!m_avoid_regexp_ap)
> -    m_avoid_regexp_ap.reset(new RegularExpression(name));
> +    m_avoid_regexp_ap.reset(new RegularExpression(name_ref));
> 
> -  m_avoid_regexp_ap->Compile(name);
> +  m_avoid_regexp_ap->Compile(name_ref);
> }
> 
> void ThreadPlanStepInRange::SetDefaultFlagValue(uint32_t new_value) {
> @@ -361,7 +362,8 @@ bool ThreadPlanStepInRange::FrameMatches
>             regex_match.GetMatchAtIndex(frame_function_name, 0, match);
>             log->Printf("Stepping out of function \"%s\" because it matches "
>                         "the avoid regexp \"%s\" - match substring: \"%s\".",
> -                        frame_function_name, avoid_regexp_to_use->GetText(),
> +                        frame_function_name,
> +                        avoid_regexp_to_use->GetText().str().c_str(),
>                         match.c_str());
>           }
>         }
> 
> Modified: lldb/trunk/source/Utility/NameMatches.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/NameMatches.cpp?rev=282079&r1=282078&r2=282079&view=diff
> ==============================================================================
> --- lldb/trunk/source/Utility/NameMatches.cpp (original)
> +++ lldb/trunk/source/Utility/NameMatches.cpp Wed Sep 21 11:01:28 2016
> @@ -36,8 +36,8 @@ bool lldb_private::NameMatches(const cha
>     case eNameMatchEndsWith:
>       return name_sref.endswith(match_sref);
>     case eNameMatchRegularExpression: {
> -      RegularExpression regex(match);
> -      return regex.Execute(name);
> +      RegularExpression regex(match_sref);
> +      return regex.Execute(name_sref);
>     } break;
>     }
>   }
> 
> 
> _______________________________________________
> lldb-commits mailing list
> lldb-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits



More information about the lldb-commits mailing list