[Lldb-commits] [PATCH] D63171: Don't try to parse ObjC method if CU isn't ObjC

Greg Clayton via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Jun 11 14:56:27 PDT 2019


clayborg created this revision.
clayborg added reviewers: labath, aprantl, jingham.
Herald added a subscriber: arphaman.

Improve manual indexing performance when indexing non objective C code. One question I have is all Darwin compilers currently support the apple DWARF indexes, so do we even need the objective C parsing code here?


https://reviews.llvm.org/D63171

Files:
  source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp


Index: source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
===================================================================
--- source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
+++ source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp
@@ -113,6 +113,9 @@
 void ManualDWARFIndex::IndexUnitImpl(
     DWARFUnit &unit, const LanguageType cu_language,
     const dw_offset_t cu_offset, IndexSet &set) {
+
+  const bool check_objc = cu_language == eLanguageTypeObjC ||
+                          cu_language == eLanguageTypeObjC_plus_plus;
   for (const DWARFDebugInfoEntry &die : unit.dies()) {
     const dw_tag_t tag = die.Tag();
 
@@ -248,26 +251,29 @@
     case DW_TAG_subprogram:
       if (has_address) {
         if (name) {
-          ObjCLanguage::MethodName objc_method(name, true);
-          if (objc_method.IsValid(true)) {
-            ConstString objc_class_name_with_category(
-                objc_method.GetClassNameWithCategory());
-            ConstString objc_selector_name(objc_method.GetSelector());
-            ConstString objc_fullname_no_category_name(
-                objc_method.GetFullNameWithoutCategory(true));
-            ConstString objc_class_name_no_category(objc_method.GetClassName());
-            set.function_fullnames.Insert(ConstString(name), ref);
-            if (objc_class_name_with_category)
-              set.objc_class_selectors.Insert(objc_class_name_with_category,
+          bool is_objc_method = false;
+          if (check_objc) {
+            ObjCLanguage::MethodName objc_method(name, true);
+            if (objc_method.IsValid(true)) {
+              is_objc_method = true;
+              ConstString class_name_with_category(
+                  objc_method.GetClassNameWithCategory());
+              ConstString objc_selector_name(objc_method.GetSelector());
+              ConstString objc_fullname_no_category_name(
+                  objc_method.GetFullNameWithoutCategory(true));
+              ConstString class_name_no_category(objc_method.GetClassName());
+              set.function_fullnames.Insert(ConstString(name), ref);
+              if (class_name_with_category)
+                set.objc_class_selectors.Insert(class_name_with_category, ref);
+              if (class_name_no_category &&
+                  class_name_no_category != class_name_with_category)
+                set.objc_class_selectors.Insert(class_name_no_category, ref);
+              if (objc_selector_name)
+                set.function_selectors.Insert(objc_selector_name, ref);
+              if (objc_fullname_no_category_name)
+                set.function_fullnames.Insert(objc_fullname_no_category_name,
                                               ref);
-            if (objc_class_name_no_category &&
-                objc_class_name_no_category != objc_class_name_with_category)
-              set.objc_class_selectors.Insert(objc_class_name_no_category, ref);
-            if (objc_selector_name)
-              set.function_selectors.Insert(objc_selector_name, ref);
-            if (objc_fullname_no_category_name)
-              set.function_fullnames.Insert(objc_fullname_no_category_name,
-                                            ref);
+            }
           }
           // If we have a mangled name, then the DW_AT_name attribute is
           // usually the method name without the class or any parameters
@@ -278,7 +284,7 @@
           else
             set.function_basenames.Insert(ConstString(name), ref);
 
-          if (!is_method && !mangled_cstr && !objc_method.IsValid(true))
+          if (!is_method && !mangled_cstr && !is_objc_method)
             set.function_fullnames.Insert(ConstString(name), ref);
         }
         if (mangled_cstr) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63171.204175.patch
Type: text/x-patch
Size: 3737 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190611/93ae2de6/attachment.bin>


More information about the lldb-commits mailing list