[lld] [lld-macho][ObjC] Implement category merging into base class (PR #92448)

Kyungwoo Lee via llvm-commits llvm-commits at lists.llvm.org
Fri May 17 14:40:42 PDT 2024


================
@@ -1302,3 +1336,96 @@ void objc::mergeCategories() {
 }
 
 void objc::doCleanup() { ObjcCategoryMerger::doCleanup(); }
+
+void ObjcCategoryMerger::mergeCategoriesIntoBaseClass(
+    const Defined *baseClass, std::vector<InfoInputCategory> &categories) {
+  assert(categories.size() >= 1 && "Expected at least one category to merge");
+
+  // Collect all the info from the categories
+  ClassExtensionInfo extInfo(catLayout);
+  for (auto &catInfo : categories) {
+    parseCatInfoToExtInfo(catInfo, extInfo);
+  }
+
+  // Get metadata for the base class
+  Defined *metaRo = getClassRo(baseClass, /*getMetaRo=*/true);
+  ConcatInputSection *metaIsec = dyn_cast<ConcatInputSection>(metaRo->isec());
+  Defined *classRo = getClassRo(baseClass, /*getMetaRo=*/false);
+  ConcatInputSection *classIsec = dyn_cast<ConcatInputSection>(classRo->isec());
+
+  // Now collect the info from the base class from the various lists in the
+  // class metadata
+  parseProtocolListInfo(classIsec, roClassLayout.baseProtocolsOffset,
----------------
kyulee-com wrote:

I'm seeing you get this protocol info for `classIsec`, but not for `metaIsec` unlike methods or properties. Is it because the info has the same (as you wrote the same protocol info for the meta RO and the class RO below? 
Then can we also read these two and assert they're identical?

https://github.com/llvm/llvm-project/pull/92448


More information about the llvm-commits mailing list