[Lldb-commits] [lldb] r370863 - Code cleanup: Change FormattersContainer::KeyType from SP to rvalue

Jan Kratochvil via lldb-commits lldb-commits at lists.llvm.org
Wed Sep 4 02:47:18 PDT 2019


Author: jankratochvil
Date: Wed Sep  4 02:47:18 2019
New Revision: 370863

URL: http://llvm.org/viewvc/llvm-project?rev=370863&view=rev
Log:
Code cleanup: Change FormattersContainer::KeyType from SP to rvalue

There is now std::shared_ptr passed around which is expensive for manycore
CPUs. Most of the times (except for 3 cases) it is now just std::moved with no
CPU locks needed. It also makes it possible to sort the keys (which is now not
needed much after D66398).

Differential revision: https://reviews.llvm.org/D67049

Modified:
    lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h
    lldb/trunk/include/lldb/DataFormatters/TypeCategory.h
    lldb/trunk/include/lldb/Target/Target.h
    lldb/trunk/include/lldb/Utility/RegularExpression.h
    lldb/trunk/source/API/SBTarget.cpp
    lldb/trunk/source/API/SBTypeCategory.cpp
    lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
    lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
    lldb/trunk/source/Commands/CommandObjectType.cpp
    lldb/trunk/source/DataFormatters/FormatManager.cpp
    lldb/trunk/source/DataFormatters/FormattersHelpers.cpp
    lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp
    lldb/trunk/source/Target/Target.cpp

Modified: lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h?rev=370863&r1=370862&r2=370863&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/FormattersContainer.h Wed Sep  4 02:47:18 2019
@@ -67,7 +67,7 @@ public:
   typedef typename ValueType::SharedPointer ValueSP;
   typedef std::map<KeyType, ValueSP> MapType;
   typedef typename MapType::iterator MapIterator;
-  typedef std::function<bool(KeyType, const ValueSP &)> ForEachCallback;
+  typedef std::function<bool(const KeyType &, const ValueSP &)> ForEachCallback;
 
   FormatMap(IFormatChangeListener *lst)
       : m_map(), m_map_mutex(), listener(lst) {}
@@ -79,7 +79,7 @@ public:
       entry->GetRevision() = 0;
 
     std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
-    m_map[name] = entry;
+    m_map[std::move(name)] = entry;
     if (listener)
       listener->Changed();
   }
@@ -116,7 +116,7 @@ public:
       std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
       MapIterator pos, end = m_map.end();
       for (pos = m_map.begin(); pos != end; pos++) {
-        KeyType type = pos->first;
+        const KeyType &type = pos->first;
         if (!callback(type, pos->second))
           break;
       }
@@ -138,6 +138,7 @@ public:
     return iter->second;
   }
 
+  // If caller holds the mutex we could return a reference without copy ctor.
   KeyType GetKeyAtIndex(size_t index) {
     std::lock_guard<std::recursive_mutex> guard(m_map_mutex);
     MapIterator iter = m_map.begin();
@@ -182,8 +183,8 @@ public:
   FormattersContainer(std::string name, IFormatChangeListener *lst)
       : m_format_map(lst), m_name(name) {}
 
-  void Add(const MapKeyType &type, const MapValueType &entry) {
-    Add_Impl(type, entry, static_cast<KeyType *>(nullptr));
+  void Add(MapKeyType type, const MapValueType &entry) {
+    Add_Impl(std::move(type), entry, static_cast<KeyType *>(nullptr));
   }
 
   bool Delete(ConstString type) {
@@ -233,9 +234,9 @@ protected:
 
   DISALLOW_COPY_AND_ASSIGN(FormattersContainer);
 
-  void Add_Impl(const MapKeyType &type, const MapValueType &entry,
-                lldb::RegularExpressionSP *dummy) {
-    m_format_map.Add(type, entry);
+  void Add_Impl(MapKeyType type, const MapValueType &entry,
+                RegularExpression *dummy) {
+    m_format_map.Add(std::move(type), entry);
   }
 
   void Add_Impl(ConstString type, const MapValueType &entry,
@@ -247,12 +248,12 @@ protected:
     return m_format_map.Delete(type);
   }
 
-  bool Delete_Impl(ConstString type, lldb::RegularExpressionSP *dummy) {
+  bool Delete_Impl(ConstString type, RegularExpression *dummy) {
     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 (type.GetStringRef() == regex->GetText()) {
+      const RegularExpression &regex = pos->first;
+      if (type.GetStringRef() == regex.GetText()) {
         m_format_map.map().erase(pos);
         if (m_format_map.listener)
           m_format_map.listener->Changed();
@@ -282,23 +283,22 @@ protected:
   }
 
   lldb::TypeNameSpecifierImplSP
-  GetTypeNameSpecifierAtIndex_Impl(size_t index,
-                                   lldb::RegularExpressionSP *dummy) {
-    lldb::RegularExpressionSP regex = m_format_map.GetKeyAtIndex(index);
-    if (regex.get() == nullptr)
+  GetTypeNameSpecifierAtIndex_Impl(size_t index, RegularExpression *dummy) {
+    RegularExpression regex = m_format_map.GetKeyAtIndex(index);
+    if (regex == RegularExpression())
       return lldb::TypeNameSpecifierImplSP();
     return lldb::TypeNameSpecifierImplSP(
-        new TypeNameSpecifierImpl(regex->GetText().str().c_str(), true));
+        new TypeNameSpecifierImpl(regex.GetText().str().c_str(), true));
   }
 
   bool Get_Impl(ConstString key, MapValueType &value,
-                lldb::RegularExpressionSP *dummy) {
+                RegularExpression *dummy) {
     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_str)) {
+      const RegularExpression &regex = pos->first;
+      if (regex.Execute(key_str)) {
         value = pos->second;
         return true;
       }
@@ -307,12 +307,12 @@ protected:
   }
 
   bool GetExact_Impl(ConstString key, MapValueType &value,
-                     lldb::RegularExpressionSP *dummy) {
+                     RegularExpression *dummy) {
     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->GetText() == key.GetStringRef()) {
+      const RegularExpression &regex = pos->first;
+      if (regex.GetText() == key.GetStringRef()) {
         value = pos->second;
         return true;
       }

Modified: lldb/trunk/include/lldb/DataFormatters/TypeCategory.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/DataFormatters/TypeCategory.h?rev=370863&r1=370862&r2=370863&view=diff
==============================================================================
--- lldb/trunk/include/lldb/DataFormatters/TypeCategory.h (original)
+++ lldb/trunk/include/lldb/DataFormatters/TypeCategory.h Wed Sep  4 02:47:18 2019
@@ -26,7 +26,7 @@ namespace lldb_private {
 template <typename FormatterImpl> class FormatterContainerPair {
 public:
   typedef FormattersContainer<ConstString, FormatterImpl> ExactMatchContainer;
-  typedef FormattersContainer<lldb::RegularExpressionSP, FormatterImpl>
+  typedef FormattersContainer<RegularExpression, FormatterImpl>
       RegexMatchContainer;
 
   typedef typename ExactMatchContainer::MapType ExactMatchMap;

Modified: lldb/trunk/include/lldb/Target/Target.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Target/Target.h?rev=370863&r1=370862&r2=370863&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Target/Target.h (original)
+++ lldb/trunk/include/lldb/Target/Target.h Wed Sep  4 02:47:18 2019
@@ -598,7 +598,7 @@ public:
       const FileSpecList *containingModules,
       const FileSpecList *source_file_list,
       const std::unordered_set<std::string> &function_names,
-      RegularExpression &source_regex, bool internal, bool request_hardware,
+      RegularExpression source_regex, bool internal, bool request_hardware,
       LazyBool move_to_nearest_code);
 
   // Use this to create a breakpoint from a load address
@@ -621,7 +621,7 @@ public:
   // target setting, else we use the values passed in
   lldb::BreakpointSP CreateFuncRegexBreakpoint(
       const FileSpecList *containingModules,
-      const FileSpecList *containingSourceFiles, RegularExpression &func_regexp,
+      const FileSpecList *containingSourceFiles, RegularExpression func_regexp,
       lldb::LanguageType requested_language, LazyBool skip_prologue,
       bool internal, bool request_hardware);
 

Modified: lldb/trunk/include/lldb/Utility/RegularExpression.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Utility/RegularExpression.h?rev=370863&r1=370862&r2=370863&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Utility/RegularExpression.h (original)
+++ lldb/trunk/include/lldb/Utility/RegularExpression.h Wed Sep  4 02:47:18 2019
@@ -78,6 +78,14 @@ public:
   ///     otherwise.
   llvm::Error GetError() const;
 
+  bool operator<(const RegularExpression &rhs) const {
+    return GetText() < rhs.GetText();
+  }
+
+  bool operator==(const RegularExpression &rhs) const {
+    return GetText() == rhs.GetText();
+  }
+
 private:
   /// A copy of the original regular expression text.
   std::string m_regex_text;

Modified: lldb/trunk/source/API/SBTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTarget.cpp?rev=370863&r1=370862&r2=370863&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTarget.cpp (original)
+++ lldb/trunk/source/API/SBTarget.cpp Wed Sep  4 02:47:18 2019
@@ -960,8 +960,8 @@ lldb::SBBreakpoint SBTarget::BreakpointC
     const LazyBool skip_prologue = eLazyBoolCalculate;
 
     sb_bp = target_sp->CreateFuncRegexBreakpoint(
-        module_list.get(), comp_unit_list.get(), regexp, symbol_language,
-        skip_prologue, internal, hardware);
+        module_list.get(), comp_unit_list.get(), std::move(regexp),
+        symbol_language, skip_prologue, internal, hardware);
   }
 
   return LLDB_RECORD_RESULT(sb_bp);
@@ -1061,8 +1061,8 @@ lldb::SBBreakpoint SBTarget::BreakpointC
     }
 
     sb_bp = target_sp->CreateSourceRegexBreakpoint(
-        module_list.get(), source_file_list.get(), func_names_set, regexp,
-        false, hardware, move_to_nearest_code);
+        module_list.get(), source_file_list.get(), func_names_set,
+        std::move(regexp), false, hardware, move_to_nearest_code);
   }
 
   return LLDB_RECORD_RESULT(sb_bp);

Modified: lldb/trunk/source/API/SBTypeCategory.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/API/SBTypeCategory.cpp?rev=370863&r1=370862&r2=370863&view=diff
==============================================================================
--- lldb/trunk/source/API/SBTypeCategory.cpp (original)
+++ lldb/trunk/source/API/SBTypeCategory.cpp Wed Sep  4 02:47:18 2019
@@ -364,8 +364,8 @@ bool SBTypeCategory::AddTypeFormat(SBTyp
 
   if (type_name.IsRegex())
     m_opaque_sp->GetRegexTypeFormatsContainer()->Add(
-        lldb::RegularExpressionSP(new RegularExpression(
-            llvm::StringRef::withNullAsEmpty(type_name.GetName()))),
+        RegularExpression(
+            llvm::StringRef::withNullAsEmpty(type_name.GetName())),
         format.GetSP());
   else
     m_opaque_sp->GetTypeFormatsContainer()->Add(
@@ -443,8 +443,8 @@ bool SBTypeCategory::AddTypeSummary(SBTy
 
   if (type_name.IsRegex())
     m_opaque_sp->GetRegexTypeSummariesContainer()->Add(
-        lldb::RegularExpressionSP(new RegularExpression(
-            llvm::StringRef::withNullAsEmpty(type_name.GetName()))),
+        RegularExpression(
+            llvm::StringRef::withNullAsEmpty(type_name.GetName())),
         summary.GetSP());
   else
     m_opaque_sp->GetTypeSummariesContainer()->Add(
@@ -488,8 +488,8 @@ bool SBTypeCategory::AddTypeFilter(SBTyp
 
   if (type_name.IsRegex())
     m_opaque_sp->GetRegexTypeFiltersContainer()->Add(
-        lldb::RegularExpressionSP(new RegularExpression(
-            llvm::StringRef::withNullAsEmpty(type_name.GetName()))),
+        RegularExpression(
+            llvm::StringRef::withNullAsEmpty(type_name.GetName())),
         filter.GetSP());
   else
     m_opaque_sp->GetTypeFiltersContainer()->Add(
@@ -567,8 +567,8 @@ bool SBTypeCategory::AddTypeSynthetic(SB
 
   if (type_name.IsRegex())
     m_opaque_sp->GetRegexTypeSyntheticsContainer()->Add(
-        lldb::RegularExpressionSP(new RegularExpression(
-            llvm::StringRef::withNullAsEmpty(type_name.GetName()))),
+        RegularExpression(
+            llvm::StringRef::withNullAsEmpty(type_name.GetName())),
         synth.GetSP());
   else
     m_opaque_sp->GetTypeSyntheticsContainer()->Add(

Modified: lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp?rev=370863&r1=370862&r2=370863&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointResolverName.cpp Wed Sep  4 02:47:18 2019
@@ -126,9 +126,8 @@ BreakpointResolver *BreakpointResolverNa
   success = options_dict.GetValueForKeyAsString(
       GetKey(OptionNames::RegexString), regex_text);
   if (success) {
-    RegularExpression regex(regex_text);
-    return new BreakpointResolverName(bkpt, regex, language, offset,
-                                      skip_prologue);
+    return new BreakpointResolverName(bkpt, RegularExpression(regex_text),
+                                      language, offset, skip_prologue);
   } else {
     StructuredData::Array *names_array;
     success = options_dict.GetValueForKeyAsArray(

Modified: lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp?rev=370863&r1=370862&r2=370863&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectBreakpoint.cpp Wed Sep  4 02:47:18 2019
@@ -668,7 +668,7 @@ protected:
         }
 
         bp_sp = target.CreateFuncRegexBreakpoint(
-            &(m_options.m_modules), &(m_options.m_filenames), regexp,
+            &(m_options.m_modules), &(m_options.m_filenames), std::move(regexp),
             m_options.m_language, m_options.m_skip_prologue, internal,
             m_options.m_hardware);
       }
@@ -699,7 +699,7 @@ protected:
       }
       bp_sp = target.CreateSourceRegexBreakpoint(
           &(m_options.m_modules), &(m_options.m_filenames),
-          m_options.m_source_regex_func_names, regexp, internal,
+          m_options.m_source_regex_func_names, std::move(regexp), internal,
           m_options.m_hardware, m_options.m_move_to_nearest_code);
     } break;
     case eSetTypeException: {

Modified: lldb/trunk/source/Commands/CommandObjectType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Commands/CommandObjectType.cpp?rev=370863&r1=370862&r2=370863&view=diff
==============================================================================
--- lldb/trunk/source/Commands/CommandObjectType.cpp (original)
+++ lldb/trunk/source/Commands/CommandObjectType.cpp Wed Sep  4 02:47:18 2019
@@ -687,17 +687,18 @@ protected:
 
       ConstString typeCS(arg_entry.ref);
       if (m_command_options.m_regex) {
-        RegularExpressionSP typeRX(new RegularExpression(arg_entry.ref));
-        if (!typeRX->IsValid()) {
+        RegularExpression typeRX(arg_entry.ref);
+        if (!typeRX.IsValid()) {
           result.AppendError(
               "regex format error (maybe this is not really a regex?)");
           result.SetStatus(eReturnStatusFailed);
           return false;
         }
         category_sp->GetRegexTypeSummariesContainer()->Delete(typeCS);
-        category_sp->GetRegexTypeFormatsContainer()->Add(typeRX, entry);
+        category_sp->GetRegexTypeFormatsContainer()->Add(std::move(typeRX),
+                                                         entry);
       } else
-        category_sp->GetTypeFormatsContainer()->Add(typeCS, entry);
+        category_sp->GetTypeFormatsContainer()->Add(std::move(typeCS), entry);
     }
 
     result.SetStatus(eReturnStatusSuccessFinishNoResult);
@@ -1089,13 +1090,13 @@ protected:
 
       foreach
         .SetWithRegex([&result, &formatter_regex, &any_printed](
-                          RegularExpressionSP regex_sp,
+                          const RegularExpression &regex,
                           const FormatterSharedPointer &format_sp) -> bool {
           if (formatter_regex) {
             bool escape = true;
-            if (regex_sp->GetText() == formatter_regex->GetText()) {
+            if (regex.GetText() == formatter_regex->GetText()) {
               escape = false;
-            } else if (formatter_regex->Execute(regex_sp->GetText())) {
+            } else if (formatter_regex->Execute(regex.GetText())) {
               escape = false;
             }
 
@@ -1105,7 +1106,7 @@ protected:
 
           any_printed = true;
           result.GetOutputStream().Printf("%s: %s\n",
-                                          regex_sp->GetText().str().c_str(),
+                                          regex.GetText().str().c_str(),
                                           format_sp->GetDescription().c_str());
           return true;
         });
@@ -1619,8 +1620,8 @@ bool CommandObjectTypeSummaryAdd::AddSum
   }
 
   if (type == eRegexSummary) {
-    RegularExpressionSP typeRX(new RegularExpression(type_name.GetStringRef()));
-    if (!typeRX->IsValid()) {
+    RegularExpression typeRX(type_name.GetStringRef());
+    if (!typeRX.IsValid()) {
       if (error)
         error->SetErrorString(
             "regex format error (maybe this is not really a regex?)");
@@ -1628,7 +1629,7 @@ bool CommandObjectTypeSummaryAdd::AddSum
     }
 
     category->GetRegexTypeSummariesContainer()->Delete(type_name);
-    category->GetRegexTypeSummariesContainer()->Add(typeRX, entry);
+    category->GetRegexTypeSummariesContainer()->Add(std::move(typeRX), entry);
 
     return true;
   } else if (type == eNamedSummary) {
@@ -1636,7 +1637,7 @@ bool CommandObjectTypeSummaryAdd::AddSum
     DataVisualization::NamedSummaryFormats::Add(type_name, entry);
     return true;
   } else {
-    category->GetTypeSummariesContainer()->Add(type_name, entry);
+    category->GetTypeSummariesContainer()->Add(std::move(type_name), entry);
     return true;
   }
 }
@@ -2353,8 +2354,8 @@ bool CommandObjectTypeSynthAdd::AddSynth
   }
 
   if (type == eRegexSynth) {
-    RegularExpressionSP typeRX(new RegularExpression(type_name.GetStringRef()));
-    if (!typeRX->IsValid()) {
+    RegularExpression typeRX(type_name.GetStringRef());
+    if (!typeRX.IsValid()) {
       if (error)
         error->SetErrorString(
             "regex format error (maybe this is not really a regex?)");
@@ -2362,11 +2363,11 @@ bool CommandObjectTypeSynthAdd::AddSynth
     }
 
     category->GetRegexTypeSyntheticsContainer()->Delete(type_name);
-    category->GetRegexTypeSyntheticsContainer()->Add(typeRX, entry);
+    category->GetRegexTypeSyntheticsContainer()->Add(std::move(typeRX), entry);
 
     return true;
   } else {
-    category->GetTypeSyntheticsContainer()->Add(type_name, entry);
+    category->GetTypeSyntheticsContainer()->Add(std::move(type_name), entry);
     return true;
   }
 }
@@ -2479,9 +2480,8 @@ private:
     }
 
     if (type == eRegexFilter) {
-      RegularExpressionSP typeRX(
-          new RegularExpression(type_name.GetStringRef()));
-      if (!typeRX->IsValid()) {
+      RegularExpression typeRX(type_name.GetStringRef());
+      if (!typeRX.IsValid()) {
         if (error)
           error->SetErrorString(
               "regex format error (maybe this is not really a regex?)");
@@ -2489,11 +2489,11 @@ private:
       }
 
       category->GetRegexTypeFiltersContainer()->Delete(type_name);
-      category->GetRegexTypeFiltersContainer()->Add(typeRX, entry);
+      category->GetRegexTypeFiltersContainer()->Add(std::move(typeRX), entry);
 
       return true;
     } else {
-      category->GetTypeFiltersContainer()->Add(type_name, entry);
+      category->GetTypeFiltersContainer()->Add(std::move(type_name), entry);
       return true;
     }
   }

Modified: lldb/trunk/source/DataFormatters/FormatManager.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormatManager.cpp?rev=370863&r1=370862&r2=370863&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormatManager.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormatManager.cpp Wed Sep  4 02:47:18 2019
@@ -952,10 +952,7 @@ void FormatManager::LoadSystemFormatters
   lldb::TypeSummaryImplSP string_array_format(
       new StringSummaryFormat(string_array_flags, "${var%s}"));
 
-  lldb::RegularExpressionSP any_size_char_arr(
-      new RegularExpression(llvm::StringRef("char \\[[0-9]+\\]")));
-  lldb::RegularExpressionSP any_size_wchar_arr(
-      new RegularExpression(llvm::StringRef("wchar_t \\[[0-9]+\\]")));
+  RegularExpression any_size_char_arr(llvm::StringRef("char \\[[0-9]+\\]"));
 
   TypeCategoryImpl::SharedPointer sys_category_sp =
       GetCategory(m_system_category_name);
@@ -964,8 +961,8 @@ void FormatManager::LoadSystemFormatters
                                                     string_format);
   sys_category_sp->GetTypeSummariesContainer()->Add(
       ConstString("unsigned char *"), string_format);
-  sys_category_sp->GetRegexTypeSummariesContainer()->Add(any_size_char_arr,
-                                                         string_array_format);
+  sys_category_sp->GetRegexTypeSummariesContainer()->Add(
+      std::move(any_size_char_arr), string_array_format);
 
   lldb::TypeSummaryImplSP ostype_summary(
       new StringSummaryFormat(TypeSummaryImpl::Flags()

Modified: lldb/trunk/source/DataFormatters/FormattersHelpers.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/FormattersHelpers.cpp?rev=370863&r1=370862&r2=370863&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/FormattersHelpers.cpp (original)
+++ lldb/trunk/source/DataFormatters/FormattersHelpers.cpp Wed Sep  4 02:47:18 2019
@@ -29,10 +29,10 @@ void lldb_private::formatters::AddFormat
 
   if (regex)
     category_sp->GetRegexTypeFormatsContainer()->Add(
-        RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
-        format_sp);
+        RegularExpression(type_name.GetStringRef()), format_sp);
   else
-    category_sp->GetTypeFormatsContainer()->Add(type_name, format_sp);
+    category_sp->GetTypeFormatsContainer()->Add(std::move(type_name),
+                                                format_sp);
 }
 
 void lldb_private::formatters::AddSummary(
@@ -40,10 +40,10 @@ void lldb_private::formatters::AddSummar
     ConstString type_name, bool regex) {
   if (regex)
     category_sp->GetRegexTypeSummariesContainer()->Add(
-        RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
-        summary_sp);
+        RegularExpression(type_name.GetStringRef()), summary_sp);
   else
-    category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
+    category_sp->GetTypeSummariesContainer()->Add(std::move(type_name),
+                                                  summary_sp);
 }
 
 void lldb_private::formatters::AddStringSummary(
@@ -53,10 +53,10 @@ void lldb_private::formatters::AddString
 
   if (regex)
     category_sp->GetRegexTypeSummariesContainer()->Add(
-        RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
-        summary_sp);
+        RegularExpression(type_name.GetStringRef()), summary_sp);
   else
-    category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
+    category_sp->GetTypeSummariesContainer()->Add(std::move(type_name),
+                                                  summary_sp);
 }
 
 void lldb_private::formatters::AddOneLineSummary(
@@ -67,10 +67,10 @@ void lldb_private::formatters::AddOneLin
 
   if (regex)
     category_sp->GetRegexTypeSummariesContainer()->Add(
-        RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
-        summary_sp);
+        RegularExpression(type_name.GetStringRef()), summary_sp);
   else
-    category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
+    category_sp->GetTypeSummariesContainer()->Add(std::move(type_name),
+                                                  summary_sp);
 }
 
 void lldb_private::formatters::AddCXXSummary(
@@ -81,10 +81,10 @@ void lldb_private::formatters::AddCXXSum
       new CXXFunctionSummaryFormat(flags, funct, description));
   if (regex)
     category_sp->GetRegexTypeSummariesContainer()->Add(
-        RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
-        summary_sp);
+        RegularExpression(type_name.GetStringRef()), summary_sp);
   else
-    category_sp->GetTypeSummariesContainer()->Add(type_name, summary_sp);
+    category_sp->GetTypeSummariesContainer()->Add(std::move(type_name),
+                                                  summary_sp);
 }
 
 void lldb_private::formatters::AddCXXSynthetic(
@@ -96,10 +96,10 @@ void lldb_private::formatters::AddCXXSyn
       new CXXSyntheticChildren(flags, description, generator));
   if (regex)
     category_sp->GetRegexTypeSyntheticsContainer()->Add(
-        RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
-        synth_sp);
+        RegularExpression(type_name.GetStringRef()), synth_sp);
   else
-    category_sp->GetTypeSyntheticsContainer()->Add(type_name, synth_sp);
+    category_sp->GetTypeSyntheticsContainer()->Add(std::move(type_name),
+                                                   synth_sp);
 }
 
 void lldb_private::formatters::AddFilter(
@@ -111,10 +111,10 @@ void lldb_private::formatters::AddFilter
     filter_sp->AddExpressionPath(child);
   if (regex)
     category_sp->GetRegexTypeFiltersContainer()->Add(
-        RegularExpressionSP(new RegularExpression(type_name.GetStringRef())),
-        filter_sp);
+        RegularExpression(type_name.GetStringRef()), filter_sp);
   else
-    category_sp->GetTypeFiltersContainer()->Add(type_name, filter_sp);
+    category_sp->GetTypeFiltersContainer()->Add(std::move(type_name),
+                                                filter_sp);
 }
 
 size_t lldb_private::formatters::ExtractIndexFromString(const char *item_name) {

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=370863&r1=370862&r2=370863&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp (original)
+++ lldb/trunk/source/Plugins/Language/CPlusPlus/CPlusPlusLanguage.cpp Wed Sep  4 02:47:18 2019
@@ -550,8 +550,8 @@ static void LoadLibCxxFormatters(lldb::T
       ConstString("^std::__[[:alnum:]]+::atomic<.+>$"), stl_synth_flags, true);
 
   cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
-      RegularExpressionSP(new RegularExpression(
-          llvm::StringRef("^(std::__[[:alnum:]]+::)deque<.+>(( )?&)?$"))),
+      RegularExpression(
+          llvm::StringRef("^(std::__[[:alnum:]]+::)deque<.+>(( )?&)?$")),
       SyntheticChildrenSP(new ScriptedSyntheticChildren(
           stl_synth_flags,
           "lldb.formatters.cpp.libcxx.stddeque_SynthProvider")));
@@ -750,38 +750,32 @@ static void LoadLibStdcppFormatters(lldb
       false);
 
   cpp_category_sp->GetRegexTypeSyntheticsContainer()->Add(
-      RegularExpressionSP(
-          new RegularExpression(llvm::StringRef("^std::vector<.+>(( )?&)?$"))),
+      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(llvm::StringRef("^std::map<.+> >(( )?&)?$"))),
+      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(
-          llvm::StringRef("^std::(__cxx11::)?list<.+>(( )?&)?$"))),
+      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(llvm::StringRef("^std::vector<.+>(( )?&)?$"))),
+      RegularExpression(llvm::StringRef("^std::vector<.+>(( )?&)?$")),
       TypeSummaryImplSP(
           new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
   cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
-      RegularExpressionSP(
-          new RegularExpression(llvm::StringRef("^std::map<.+> >(( )?&)?$"))),
+      RegularExpression(llvm::StringRef("^std::map<.+> >(( )?&)?$")),
       TypeSummaryImplSP(
           new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
   cpp_category_sp->GetRegexTypeSummariesContainer()->Add(
-      RegularExpressionSP(new RegularExpression(
-          llvm::StringRef("^std::(__cxx11::)?list<.+>(( )?&)?$"))),
+      RegularExpression(llvm::StringRef("^std::(__cxx11::)?list<.+>(( )?&)?$")),
       TypeSummaryImplSP(
           new StringSummaryFormat(stl_summary_flags, "size=${svar%#}")));
 

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=370863&r1=370862&r2=370863&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Wed Sep  4 02:47:18 2019
@@ -305,14 +305,14 @@ BreakpointSP Target::CreateSourceRegexBr
     const FileSpecList *containingModules,
     const FileSpecList *source_file_spec_list,
     const std::unordered_set<std::string> &function_names,
-    RegularExpression &source_regex, bool internal, bool hardware,
+    RegularExpression source_regex, bool internal, bool hardware,
     LazyBool move_to_nearest_code) {
   SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList(
       containingModules, source_file_spec_list));
   if (move_to_nearest_code == eLazyBoolCalculate)
     move_to_nearest_code = GetMoveToNearestCode() ? eLazyBoolYes : eLazyBoolNo;
   BreakpointResolverSP resolver_sp(new BreakpointResolverFileRegex(
-      nullptr, source_regex, function_names,
+      nullptr, std::move(source_regex), function_names,
       !static_cast<bool>(move_to_nearest_code)));
 
   return CreateBreakpoint(filter_sp, resolver_sp, internal, hardware, true);
@@ -547,7 +547,7 @@ SearchFilterSP Target::GetSearchFilterFo
 
 BreakpointSP Target::CreateFuncRegexBreakpoint(
     const FileSpecList *containingModules,
-    const FileSpecList *containingSourceFiles, RegularExpression &func_regex,
+    const FileSpecList *containingSourceFiles, RegularExpression func_regex,
     lldb::LanguageType requested_language, LazyBool skip_prologue,
     bool internal, bool hardware) {
   SearchFilterSP filter_sp(GetSearchFilterForModuleAndCUList(
@@ -556,7 +556,7 @@ BreakpointSP Target::CreateFuncRegexBrea
                   ? GetSkipPrologue()
                   : static_cast<bool>(skip_prologue);
   BreakpointResolverSP resolver_sp(new BreakpointResolverName(
-      nullptr, func_regex, requested_language, 0, skip));
+      nullptr, std::move(func_regex), requested_language, 0, skip));
 
   return CreateBreakpoint(filter_sp, resolver_sp, internal, hardware, true);
 }




More information about the lldb-commits mailing list