bulbazord updated this revision to Diff 351696.
bulbazord added a comment.

Addressing comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104067/new/

https://reviews.llvm.org/D104067

Files:
  lldb/include/lldb/Target/Language.h
  lldb/source/Breakpoint/BreakpointResolverName.cpp
  lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
  lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
  lldb/source/Symbol/CMakeLists.txt
  lldb/source/Symbol/Symtab.cpp

Index: lldb/source/Symbol/Symtab.cpp
===================================================================
--- lldb/source/Symbol/Symtab.cpp
+++ lldb/source/Symbol/Symtab.cpp
@@ -9,8 +9,6 @@
 #include <map>
 #include <set>
 
-#include "Plugins/Language/ObjC/ObjCLanguage.h"
-
 #include "lldb/Core/Module.h"
 #include "lldb/Core/RichManglingContext.h"
 #include "lldb/Core/Section.h"
@@ -18,6 +16,7 @@
 #include "lldb/Symbol/Symbol.h"
 #include "lldb/Symbol/SymbolContext.h"
 #include "lldb/Symbol/Symtab.h"
+#include "lldb/Target/Language.h"
 #include "lldb/Utility/RegularExpression.h"
 #include "lldb/Utility/Stream.h"
 #include "lldb/Utility/Timer.h"
@@ -330,14 +329,21 @@
 
         // If the demangled name turns out to be an ObjC name, and is a category
         // name, add the version without categories to the index too.
-        ObjCLanguage::MethodName objc_method(name.GetStringRef(), true);
-        if (objc_method.IsValid(true)) {
-          selector_to_index.Append(objc_method.GetSelector(), value);
+        auto map_variant_names = [&](Language *lang) {
+          for (auto variant : lang->GetMethodNameVariants(name)) {
+            if (variant.GetType() & lldb::eFunctionNameTypeSelector)
+              selector_to_index.Append(variant.GetName(), value);
+            else if (variant.GetType() & lldb::eFunctionNameTypeFull)
+              name_to_index.Append(variant.GetName(), value);
+            else if (variant.GetType() & lldb::eFunctionNameTypeMethod)
+              method_to_index.Append(variant.GetName(), value);
+            else if (variant.GetType() & lldb::eFunctionNameTypeBase)
+              basename_to_index.Append(variant.GetName(), value);
+          }
+          return true;
+        };
 
-          if (ConstString objc_method_no_category =
-                  objc_method.GetFullNameWithoutCategory(true))
-            name_to_index.Append(objc_method_no_category, value);
-        }
+        Language::ForEach(map_variant_names);
       }
     }
 
Index: lldb/source/Symbol/CMakeLists.txt
===================================================================
--- lldb/source/Symbol/CMakeLists.txt
+++ lldb/source/Symbol/CMakeLists.txt
@@ -44,7 +44,6 @@
     lldbHost
     lldbTarget
     lldbUtility
-    lldbPluginObjCLanguage
 
   LINK_COMPONENTS
     Support
Index: lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
===================================================================
--- lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
+++ lldb/source/Plugins/Language/ObjC/ObjCLanguage.h
@@ -100,7 +100,8 @@
   //  variant_names[1] => "-[NSString(my_additions) myStringWithCString:]"
   //  variant_names[2] => "+[NSString myStringWithCString:]"
   //  variant_names[3] => "-[NSString myStringWithCString:]"
-  std::vector<ConstString>
+  // We also return the FunctionNameType of each possible name.
+  std::vector<Language::MethodNameVariant>
   GetMethodNameVariants(ConstString method_name) const override;
 
   bool SymbolNameFitsToLanguage(Mangled mangled) const override;
Index: lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
===================================================================
--- lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
+++ lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp
@@ -225,14 +225,17 @@
   return ConstString();
 }
 
-std::vector<ConstString>
+std::vector<Language::MethodNameVariant>
 ObjCLanguage::GetMethodNameVariants(ConstString method_name) const {
-  std::vector<ConstString> variant_names;
+  std::vector<Language::MethodNameVariant> variant_names;
   ObjCLanguage::MethodName objc_method(method_name.GetCString(), false);
   if (!objc_method.IsValid(false)) {
     return variant_names;
   }
 
+  variant_names.emplace_back(objc_method.GetSelector(),
+                             lldb::eFunctionNameTypeSelector);
+
   const bool is_class_method =
       objc_method.GetType() == MethodName::eTypeClassMethod;
   const bool is_instance_method =
@@ -242,25 +245,30 @@
 
   if (is_class_method || is_instance_method) {
     if (name_sans_category)
-      variant_names.emplace_back(name_sans_category);
+      variant_names.emplace_back(name_sans_category,
+                                 lldb::eFunctionNameTypeFull);
   } else {
     StreamString strm;
 
     strm.Printf("+%s", objc_method.GetFullName().GetCString());
-    variant_names.emplace_back(strm.GetString());
+    variant_names.emplace_back(ConstString(strm.GetString()),
+                               lldb::eFunctionNameTypeFull);
     strm.Clear();
 
     strm.Printf("-%s", objc_method.GetFullName().GetCString());
-    variant_names.emplace_back(strm.GetString());
+    variant_names.emplace_back(ConstString(strm.GetString()),
+                               lldb::eFunctionNameTypeFull);
     strm.Clear();
 
     if (name_sans_category) {
       strm.Printf("+%s", name_sans_category.GetCString());
-      variant_names.emplace_back(strm.GetString());
+      variant_names.emplace_back(ConstString(strm.GetString()),
+                                 lldb::eFunctionNameTypeFull);
       strm.Clear();
 
       strm.Printf("-%s", name_sans_category.GetCString());
-      variant_names.emplace_back(strm.GetString());
+      variant_names.emplace_back(ConstString(strm.GetString()),
+                                 lldb::eFunctionNameTypeFull);
     }
   }
 
Index: lldb/source/Breakpoint/BreakpointResolverName.cpp
===================================================================
--- lldb/source/Breakpoint/BreakpointResolverName.cpp
+++ lldb/source/Breakpoint/BreakpointResolverName.cpp
@@ -220,11 +220,15 @@
   m_lookups.emplace_back(lookup);
 
   auto add_variant_funcs = [&](Language *lang) {
-    for (ConstString variant_name : lang->GetMethodNameVariants(name)) {
-      Module::LookupInfo variant_lookup(name, name_type_mask,
-                                        lang->GetLanguageType());
-      variant_lookup.SetLookupName(variant_name);
-      m_lookups.emplace_back(variant_lookup);
+    for (Language::MethodNameVariant variant :
+         lang->GetMethodNameVariants(name)) {
+      // FIXME: Should we be adding variants that aren't of type Full?
+      if (variant.GetType() & lldb::eFunctionNameTypeFull) {
+        Module::LookupInfo variant_lookup(name, variant.GetType(),
+                                          lang->GetLanguageType());
+        variant_lookup.SetLookupName(variant.GetName());
+        m_lookups.emplace_back(variant_lookup);
+      }
     }
     return true;
   };
Index: lldb/include/lldb/Target/Language.h
===================================================================
--- lldb/include/lldb/Target/Language.h
+++ lldb/include/lldb/Target/Language.h
@@ -184,12 +184,22 @@
 
   virtual const char *GetLanguageSpecificTypeLookupHelp();
 
+  class MethodNameVariant {
+    ConstString m_name;
+    lldb::FunctionNameType m_type;
+
+  public:
+    MethodNameVariant(ConstString name, lldb::FunctionNameType type)
+        : m_name(name), m_type(type) {}
+    ConstString GetName() { return m_name; }
+    lldb::FunctionNameType GetType() { return m_type; }
+  };
   // If a language can have more than one possible name for a method, this
   // function can be used to enumerate them. This is useful when doing name
   // lookups.
-  virtual std::vector<ConstString>
+  virtual std::vector<Language::MethodNameVariant>
   GetMethodNameVariants(ConstString method_name) const {
-    return std::vector<ConstString>();
+    return std::vector<Language::MethodNameVariant>();
   };
 
   /// Returns true iff the given symbol name is compatible with the mangling
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to