[Lldb-commits] [lldb] f021cb5 - [NFC] Remove duplicate code in SBTypeCategory

Jorge Gorbe Moya via lldb-commits lldb-commits at lists.llvm.org
Fri Sep 2 16:05:41 PDT 2022


Author: Jorge Gorbe Moya
Date: 2022-09-02T16:04:04-07:00
New Revision: f021cb57ce786f7d5a6c921a19bbcf56709b6ce0

URL: https://github.com/llvm/llvm-project/commit/f021cb57ce786f7d5a6c921a19bbcf56709b6ce0
DIFF: https://github.com/llvm/llvm-project/commit/f021cb57ce786f7d5a6c921a19bbcf56709b6ce0.diff

LOG: [NFC] Remove duplicate code in SBTypeCategory

TypeCategoryImpl has its own implementation of these, so it makes no
sense to have the same logic inlined in SBTypeCategory.

There are other methods in SBTypeCategory that are directly implemented
there, instead of delegating to TypeCategoryImpl (which IMO kinda
defeats the point of having an "opaque" member pointer in the SB type),
but they don't have equivalent implementations in TypeCategoryImpl, so
this patch only picks the low-hanging fruit for now.

Added: 
    

Modified: 
    lldb/source/API/SBTypeCategory.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/API/SBTypeCategory.cpp b/lldb/source/API/SBTypeCategory.cpp
index 7d929fe497954..c6b13498bb1ee 100644
--- a/lldb/source/API/SBTypeCategory.cpp
+++ b/lldb/source/API/SBTypeCategory.cpp
@@ -185,14 +185,8 @@ SBTypeFilter SBTypeCategory::GetFilterForType(SBTypeNameSpecifier spec) {
   if (!spec.IsValid())
     return SBTypeFilter();
 
-  lldb::TypeFilterImplSP children_sp;
-
-  if (spec.IsRegex())
-    m_opaque_sp->GetRegexTypeFiltersContainer()->GetExact(
-        ConstString(spec.GetName()), children_sp);
-  else
-    m_opaque_sp->GetTypeFiltersContainer()->GetExact(
-        ConstString(spec.GetName()), children_sp);
+  lldb::TypeFilterImplSP children_sp =
+      m_opaque_sp->GetFilterForType(spec.GetSP());
 
   if (!children_sp)
     return lldb::SBTypeFilter();
@@ -211,14 +205,8 @@ SBTypeFormat SBTypeCategory::GetFormatForType(SBTypeNameSpecifier spec) {
   if (!spec.IsValid())
     return SBTypeFormat();
 
-  lldb::TypeFormatImplSP format_sp;
-
-  if (spec.IsRegex())
-    m_opaque_sp->GetRegexTypeFormatsContainer()->GetExact(
-        ConstString(spec.GetName()), format_sp);
-  else
-    m_opaque_sp->GetTypeFormatsContainer()->GetExact(
-        ConstString(spec.GetName()), format_sp);
+  lldb::TypeFormatImplSP format_sp =
+      m_opaque_sp->GetFormatForType(spec.GetSP());
 
   if (!format_sp)
     return lldb::SBTypeFormat();
@@ -235,14 +223,8 @@ SBTypeSummary SBTypeCategory::GetSummaryForType(SBTypeNameSpecifier spec) {
   if (!spec.IsValid())
     return SBTypeSummary();
 
-  lldb::TypeSummaryImplSP summary_sp;
-
-  if (spec.IsRegex())
-    m_opaque_sp->GetRegexTypeSummariesContainer()->GetExact(
-        ConstString(spec.GetName()), summary_sp);
-  else
-    m_opaque_sp->GetTypeSummariesContainer()->GetExact(
-        ConstString(spec.GetName()), summary_sp);
+  lldb::TypeSummaryImplSP summary_sp =
+      m_opaque_sp->GetSummaryForType(spec.GetSP());
 
   if (!summary_sp)
     return lldb::SBTypeSummary();
@@ -259,14 +241,8 @@ SBTypeSynthetic SBTypeCategory::GetSyntheticForType(SBTypeNameSpecifier spec) {
   if (!spec.IsValid())
     return SBTypeSynthetic();
 
-  lldb::SyntheticChildrenSP children_sp;
-
-  if (spec.IsRegex())
-    m_opaque_sp->GetRegexTypeSyntheticsContainer()->GetExact(
-        ConstString(spec.GetName()), children_sp);
-  else
-    m_opaque_sp->GetTypeSyntheticsContainer()->GetExact(
-        ConstString(spec.GetName()), children_sp);
+  lldb::SyntheticChildrenSP children_sp =
+      m_opaque_sp->GetSyntheticForType(spec.GetSP());
 
   if (!children_sp)
     return lldb::SBTypeSynthetic();


        


More information about the lldb-commits mailing list